From: Giuseppe Bilotta Date: Thu, 13 Dec 2007 10:33:19 +0000 (+0000) Subject: plugins: refactor common code in #map() and #map!() to auxiliary #do_map() method X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=afeb2476d6a25220b20d27030a61bf49335e2e33;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git plugins: refactor common code in #map() and #map!() to auxiliary #do_map() method --- 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)