From 72ac58a7eaad2fb6c855167bf41cb30354af76c0 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 24 Jul 2006 22:43:11 +0000 Subject: Add mapsvn diff method for plugins: just like map, but doesn't add synonyms to the plugin name --- lib/rbot/plugins.rb | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'lib/rbot') diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index f2dba5d4..160a2dcd 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -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 -- cgit v1.2.3