X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fplugins.rb;h=e101e627772d0cf977689f9b5173216abacd84b7;hb=da4d97f0652bddcee269b6d99863f21a1021056c;hp=8aa75d203f656790673b2abf4a9a826328e56c4e;hpb=6cd8a9744dc12e27e97393f2f854e9ae07e9cccc;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index 8aa75d20..e101e627 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -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|