summaryrefslogtreecommitdiff
path: root/lib/rbot/plugins.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbot/plugins.rb')
-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