]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/plugins.rb
patch from Alexey Froloff to use homedir from /etc/passwd (oops!) instead of
[user/henk/code/ruby/rbot.git] / lib / rbot / plugins.rb
index ba01aa7d5c83a2c6e37f6c59e4a2b85c1f6c80e5..bffba2273994e98d658bee176583c54c080f3509 100644 (file)
@@ -8,8 +8,8 @@ module Plugins
   #
   # map(template, options)::
   #    map is the new, cleaner way to respond to specific message formats
-  #    without littering your plugin code with regexps
-  #    examples:
+  #    without littering your plugin code with regexps. examples:
+  #
   #      plugin.map 'karmastats', :action => 'karma_stats'
   #
   #      # while in the plugin...
@@ -78,6 +78,9 @@ module Plugins
   # topic(TopicMessage)::
   #                        Called when a user (or the bot) changes a channel
   #                        topic
+  #
+  # connect()::            Called when a server is joined successfully, but
+  #                        before autojoin channels are joined (no params)
   # 
   # save::                 Called when you are required to save your plugin's
   #                        state, if you maintain data between sessions
@@ -171,7 +174,7 @@ module Plugins
     # load plugins from pre-assigned list of directories
     def scan
       dirs = Array.new
-      dirs << Config::DATADIR + "/plugins"
+      dirs << Config::datadir + "/plugins"
       dirs += @dirs
       dirs.each {|dir|
         if(FileTest.directory?(dir))
@@ -179,7 +182,7 @@ module Plugins
           d.sort.each {|file|
             next if(file =~ /^\./)
             next unless(file =~ /\.rb$/)
-            @tmpfilename = "#{dir}/#{file}"
+            tmpfilename = "#{dir}/#{file}"
 
             # create a new, anonymous module to "house" the plugin
             # the idea here is to prevent namespace pollution. perhaps there
@@ -187,11 +190,11 @@ module Plugins
             plugin_module = Module.new
             
             begin
-              plugin_string = IO.readlines(@tmpfilename).join("")
-              debug "loading module: #{@tmpfilename}"
+              plugin_string = IO.readlines(tmpfilename).join("")
+              debug "loading plugin #{tmpfilename}"
               plugin_module.module_eval(plugin_string)
-            rescue StandardError, NameError, LoadError, SyntaxError => err
-              puts "warning: plugin #{@tmpfilename} load failed: " + err
+            rescue TimeoutError, StandardError, NameError, LoadError, SyntaxError => err
+              puts "warning: plugin #{tmpfilename} load failed: " + err
               puts err.backtrace.join("\n")
             end
           }
@@ -240,7 +243,7 @@ module Plugins
         if(@@plugins.has_key?(key))
           begin
             return @@plugins[key].help(key, params)
-          rescue StandardError, NameError, SyntaxError => err
+          rescue TimeoutError, StandardError, NameError, SyntaxError => err
             puts "plugin #{@@plugins[key].name} help() failed: " + err
             puts err.backtrace.join("\n")
           end
@@ -257,7 +260,7 @@ module Plugins
         if(p.respond_to? method)
           begin
             p.send method, *args
-          rescue StandardError, NameError, SyntaxError => err
+          rescue TimeoutError, StandardError, NameError, SyntaxError => err
             puts "plugin #{p.name} #{method}() failed: " + err
             puts err.backtrace.join("\n")
           end
@@ -274,7 +277,7 @@ module Plugins
           @@bot.auth.allow?(m.plugin, m.source, m.replyto))
         begin
           @@plugins[m.plugin].privmsg(m)
-        rescue StandardError, NameError, SyntaxError => err
+        rescue TimeoutError, StandardError, NameError, SyntaxError => err
           puts "plugin #{@@plugins[m.plugin].name} privmsg() failed: " + err
           puts err.backtrace.join("\n")
         end