]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/plugins.rb
New Irc Framework: netmask generalization now takes into consideration AzzurraNet...
[user/henk/code/ruby/rbot.git] / lib / rbot / plugins.rb
index 96f61efc24a54d00dc068d8b205b6a59a05604b4..12fade3e211cb64db61d4f3bf094297238d90503 100644 (file)
@@ -6,7 +6,8 @@
 require 'singleton'
 
 module Irc
-    BotConfig.register BotConfigArrayValue.new('plugins.blacklist',
+class Bot
+    Config.register Config::ArrayValue.new('plugins.blacklist',
       :default => [], :wizard => false, :requires_rescan => true,
       :desc => "Plugins that should not be loaded")
 module Plugins
@@ -17,7 +18,7 @@ module Plugins
   functionality. Rather than subclassing BotModule, however, one should
   subclass either CoreBotModule (reserved for system modules) or Plugin
   (for user plugins).
-  
+
   A BotModule interacts with Irc events by defining one or more of the following
   methods, which get called as appropriate when the corresponding Irc event
   happens.
@@ -27,7 +28,7 @@ module Plugins
      map is the new, cleaner way to respond to specific message formats without
      littering your plugin code with regexps, and should be used instead of
      #register() and #privmsg() (see below) when possible.
-     
+
      The difference between map and map! is that map! will not register the new
      command as an alternative name for the plugin.
 
@@ -134,7 +135,7 @@ module Plugins
     #   the rbot instance
     # @registry::
     #   the botmodule's registry, which can be used to store permanent data
-    #   (see BotRegistryAccessor for additional documentation)
+    #   (see Registry::Accessor for additional documentation)
     #
     # Other instance variables which are defined and should not be overwritten
     # byt the user, but aren't usually accessed directly, are:
@@ -153,7 +154,7 @@ module Plugins
       @botmodule_triggers = Array.new
 
       @handler = MessageMapper.new(self)
-      @registry = BotRegistryAccessor.new(@bot, self.class.to_s.gsub(/^.*::/, ""))
+      @registry = Registry::Accessor.new(@bot, self.class.to_s.gsub(/^.*::/, ""))
 
       @manager.add_botmodule(self)
       if self.respond_to?('set_language')
@@ -368,6 +369,19 @@ module Plugins
       bot_associate(nil)
     end
 
+    def inspect
+      ret = self.to_s[0..-2]
+      ret << ' corebotmodules='
+      ret << @botmodules[:CoreBotModule].map { |m|
+        m.name
+      }.inspect
+      ret << ' plugins='
+      ret << @botmodules[:Plugin].map { |m|
+        m.name
+      }.inspect
+      ret << ">"
+    end
+
     # Reset lists of botmodules
     def reset_botmodule_lists
       @botmodules[:CoreBotModule].clear
@@ -683,9 +697,9 @@ module Plugins
         key = $1
         params = $2
 
-       # Let's see if we can match a plugin by the given name
+        # Let's see if we can match a plugin by the given name
         (core_modules + plugins).each { |p|
-         next unless p.name == key
+          next unless p.name == key
           begin
             return p.help(key, params)
           rescue Exception => err
@@ -694,7 +708,7 @@ module Plugins
           end
         }
 
-       # Nope, let's see if it's a command, and ask for help at the corresponding botmodule
+        # Nope, let's see if it's a command, and ask for help at the corresponding botmodule
         k = key.to_sym
         if commands.has_key?(k)
           p = commands[k][:botmodule]
@@ -792,3 +806,4 @@ module Plugins
 
 end
 end
+end