diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-07-24 23:21:43 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-07-24 23:21:43 +0000 |
commit | dcbda9f1deb184db5c5f7c93123bcf7414463701 (patch) | |
tree | 7f362c39fc944a99815a8de34f40213074b97e86 /lib | |
parent | 72ac58a7eaad2fb6c855167bf41cb30354af76c0 (diff) |
Implement map! properly this time
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/messagemapper.rb | 2 | ||||
-rw-r--r-- | lib/rbot/plugins.rb | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/rbot/messagemapper.rb b/lib/rbot/messagemapper.rb index ce33c881..5c3ddc05 100644 --- a/lib/rbot/messagemapper.rb +++ b/lib/rbot/messagemapper.rb @@ -54,7 +54,7 @@ module Irc # somethingelse" # # Dynamic parameters can be specified by a colon ':' to match a single - # component (whitespace seperated), or a * to such up all following + # component (whitespace seperated), or a * to suck up all following # parameters into an array. Example: # map 'myplugin :parameter1 *rest' # diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index 160a2dcd..7b54d1fc 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -128,6 +128,7 @@ module Plugins @handler.map(*args) # register this map name = @handler.last.items[0] + self.register name, {:hidden => true} unless self.respond_to?('privmsg') def self.privmsg(m) @handler.handle(m) @@ -153,10 +154,11 @@ module Plugins # register the plugin as a handler for messages prefixed +name+ # this can be called multiple times for a plugin to handle multiple # message prefixes - def register(name) + def register(name,opts={}) + raise ArgumentError, "Second argument must be a hash!" unless opts.kind_of?(Hash) return if Plugins.plugins.has_key?(name) Plugins.plugins[name] = self - @names << name + @names << name unless opts.fetch(:hidden, false) end # default usage method provided as a utility for simple plugins. The |