]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/plugins.rb
remotectl plugin: use fake_message()
[user/henk/code/ruby/rbot.git] / lib / rbot / plugins.rb
index 9d633c1b838c9bb4365a1dc1d904aeb5cdb8c443..567724f8b19db1e056ae6e834ee5e44dfb89e9dc 100644 (file)
@@ -82,6 +82,11 @@ module Plugins
                          use message.ctcp_reply, which sends a private NOTICE
                          to the sender.
 
+  message(PrivMessage)::
+                         Called for all PRIVMSG. Hook on this method if you
+                         need to handle PRIVMSGs regardless of whether they are
+                         addressed to the bot or not, and regardless of
+
   privmsg(PrivMessage)::
                          Called for a PRIVMSG if the first word matches one
                          the plugin #register()ed for. Use m.plugin to get
@@ -130,6 +135,8 @@ module Plugins
 
   class BotModule
     attr_reader :bot   # the associated bot
+    attr_reader :registry # the plugin registry
+    attr_reader :handler # the message map handler
 
     # Initialise your bot module. Always call super if you override this method,
     # as important variables are set up for you:
@@ -815,6 +822,21 @@ module Plugins
       return false
       # debug "Finished delegating privmsg with key #{m.plugin.inspect}"
     end
+
+    # delegate IRC messages, by delegating 'listen' first, and the actual method
+    # afterwards. Delegating 'privmsg' also delegates ctcp_listen and message
+    # as appropriate.
+    def irc_delegate(method, m)
+      delegate('listen', m)
+      if method.to_sym == :privmsg
+        delegate('ctcp_listen', m) if m.ctcp
+        delegate('message', m)
+        privmsg(m) if m.address?
+        delegate('unreplied', m) unless m.replied
+      else
+        delegate(method, m)
+      end
+    end
   end
 
   # Returns the only PluginManagerClass instance