summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-07-24 22:43:11 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-07-24 22:43:11 +0000
commit72ac58a7eaad2fb6c855167bf41cb30354af76c0 (patch)
tree9dfb2e5c0209b18f1f579b6970659a4bda46cb02 /lib/rbot
parentddf83775bb3f38f6c930a4dade190bd0950d1336 (diff)
Add mapsvn diff method for plugins: just like map, but doesn't add synonyms to the plugin name
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/plugins.rb23
1 files changed, 17 insertions, 6 deletions
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