diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-12-13 10:33:19 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-12-13 10:33:19 +0000 |
commit | afeb2476d6a25220b20d27030a61bf49335e2e33 (patch) | |
tree | dd2b00a39be0cc7ae34263f2eefc3297febcf039 | |
parent | 8020192562fbdd963ad08cb68165c382e6fcadfd (diff) |
plugins: refactor common code in #map() and #map!() to auxiliary #do_map() method
-rw-r--r-- | lib/rbot/plugins.rb | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index 12fade3e..81e29bd1 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -204,15 +204,7 @@ module Plugins # responds to appropriately-formed messages on Irc. # def map(*args) - @handler.map(self, *args) - # register this map - name = @handler.last.items[0] - self.register name, :auth => nil - unless self.respond_to?('privmsg') - def self.privmsg(m) #:nodoc: - handle(m) - end - end + do_map(false, *args) end # call-seq: map!(template, options) @@ -221,10 +213,15 @@ module Plugins # as an alternative name for the plugin. # def map!(*args) + do_map(true, *args) + end + + # Auxiliary method called by #map and #map! + def do_map(silent, *args) @handler.map(self, *args) # register this map name = @handler.last.items[0] - self.register name, :auth => nil, :hidden => true + self.register name, :auth => nil, :hidden => silent unless self.respond_to?('privmsg') def self.privmsg(m) #:nodoc: handle(m) |