]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/plugins.rb
New unreplied() method for plugins that want to handle PRIVMSGs unreplied by any...
[user/henk/code/ruby/rbot.git] / lib / rbot / plugins.rb
index 0dc8832461ce7334aa0479ce156271340ac2e2e0..e101e627772d0cf977689f9b5173216abacd84b7 100644 (file)
@@ -61,11 +61,14 @@ module Plugins
                          etc.
 
   privmsg(PrivMessage)::
-                         called for a PRIVMSG if the first word matches one
+                         Called for a PRIVMSG if the first word matches one
                          the plugin register()d for. Use m.plugin to get
                          that word and m.params for the rest of the message,
                          if applicable.
 
+  unreplied(PrivMessage)::
+                         Called for a PRIVMSG which has not been replied to.
+
   kick(KickMessage)::
                          Called when a user (or the bot) is kicked from a
                          channel the bot is in.
@@ -88,6 +91,10 @@ module Plugins
   connect()::            Called when a server is joined successfully, but
                          before autojoin channels are joined (no params)
 
+  set_language(String)::
+                         Called when the user sets a new language
+                         whose name is the given String
+
   save::                 Called when you are required to save your plugin's
                          state, if you maintain data between sessions
 
@@ -111,6 +118,9 @@ module Plugins
       @registry = BotRegistryAccessor.new(@bot, self.class.to_s.gsub(/^.*::/, ""))
 
       @manager.add_botmodule(self)
+      if self.respond_to?('set_language')
+        self.set_language(@bot.lang.language)
+      end
     end
 
     def botmodule_class
@@ -245,19 +255,28 @@ module Plugins
     attr_reader :botmodules
 
     def initialize
-      bot_associate(nil)
-
-      @dirs = []
-    end
-
-    # Reset lists of botmodules
-    def reset_botmodule_lists
       @botmodules = {
         :CoreBotModule => [],
         :Plugin => []
       }
+
       @names_hash = Hash.new
       @commandmappers = Hash.new
+
+      @dirs = []
+
+      @failed = Array.new
+      @ignored = Array.new
+
+      bot_associate(nil)
+    end
+
+    # Reset lists of botmodules
+    def reset_botmodule_lists
+      @botmodules[:CoreBotModule].clear
+      @botmodules[:Plugin].clear
+      @names_hash.clear
+      @commandmappers.clear
     end
 
     # Associate with bot _bot_
@@ -373,8 +392,8 @@ module Plugins
 
     # load plugins from pre-assigned list of directories
     def scan
-      @failed = Array.new
-      @ignored = Array.new
+      @failed.clear
+      @ignored.clear
       processed = Hash.new
 
       @bot.config['plugins.blacklist'].each { |p|
@@ -533,7 +552,7 @@ module Plugins
         if commands.has_key?(k)
           p = commands[k][:botmodule] 
           begin
-            return p.help(p.name, topic)
+            return p.help(key, params)
           rescue Exception => err
             #rescue TimeoutError, StandardError, NameError, SyntaxError => err
             error report_error("#{p.botmodule_class} #{p.name} help() failed:", err)