X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fplugins.rb;h=893bb4142650da70c11f6f3137db7314a8c6e9d3;hb=dc37f783e46f0c75ba92e18463f7626fb3adfc20;hp=d98630e1641eb7a9b913437224fbc1e2574f0530;hpb=dd0b318cfd3df017b1ec4e44afc2f4e412fd2033;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index d98630e1..893bb414 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -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 @@ -170,14 +173,20 @@ module Plugins # load plugins from pre-assigned list of directories def scan + processed = Array.new dirs = Array.new dirs << Config::datadir + "/plugins" dirs += @dirs - dirs.each {|dir| + dirs.reverse.each {|dir| if(FileTest.directory?(dir)) d = Dir.new(dir) d.sort.each {|file| next if(file =~ /^\./) + next if(processed.include?(file)) + if(file =~ /^(.+\.rb)\.disabled$/) + processed << $1 + next + end next unless(file =~ /\.rb$/) tmpfilename = "#{dir}/#{file}" @@ -190,6 +199,7 @@ module Plugins plugin_string = IO.readlines(tmpfilename).join("") debug "loading plugin #{tmpfilename}" plugin_module.module_eval(plugin_string) + processed << file rescue TimeoutError, StandardError, NameError, LoadError, SyntaxError => err puts "warning: plugin #{tmpfilename} load failed: " + err puts err.backtrace.join("\n")