]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Add mapsvn diff method for plugins: just like map, but doesn't add synonyms to the...
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 24 Jul 2006 22:43:11 +0000 (22:43 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 24 Jul 2006 22:43:11 +0000 (22:43 +0000)
lib/rbot/plugins.rb

index f2dba5d4f1605bc770d51ee67109ebe3d0fbaa0e..160a2dcdbcc6012246e2818648a62f1a843fffaa 100644 (file)
@@ -10,8 +10,13 @@ module Plugins
   # the following methods, it will be called as appropriate:
   #
   # map(template, options)::
+  # 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. The difference
+  #    between map and map! is that map! will not register the new command
+  #    as an alternative name for the plugin.
+  #
+  #    Examples:
   #
   #      plugin.map 'karmastats', :action => 'karma_stats'
   #
@@ -45,11 +50,6 @@ module Plugins
   #      plugin.map 'karmastats', :public false,
   #    end
   #
-  #    To activate your maps, you simply register them
-  #    plugin.register_maps
-  #    This also sets the privmsg handler to use the map lookups for
-  #    handling messages. You can still use listen(), kick() etc methods
-  #
   # listen(UserMessage)::
   #                        Called for all messages of any type. To
   #                        differentiate them, use message.kind_of? It'll be
@@ -124,6 +124,17 @@ module Plugins
       end
     end
 
+    def map!(*args)
+      @handler.map(*args)
+      # register this map
+      name = @handler.last.items[0]
+      unless self.respond_to?('privmsg')
+        def self.privmsg(m)
+          @handler.handle(m)
+        end
+      end
+    end
+
     # return an identifier for this plugin, defaults to a list of the message
     # prefixes handled (used for error messages etc)
     def name