From afeb2476d6a25220b20d27030a61bf49335e2e33 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 13 Dec 2007 10:33:19 +0000 Subject: [PATCH] plugins: refactor common code in #map() and #map!() to auxiliary #do_map() method --- lib/rbot/plugins.rb | 17 +++++++---------- 1 file 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) -- 2.39.5