From: Giuseppe Bilotta Date: Sun, 6 Apr 2008 23:02:13 +0000 (+0200) Subject: + use the message() delegate instead of listen() when possible X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=e00ea339ca3baaa9cfe74f6cec85c36e83307b61;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git + use the message() delegate instead of listen() when possible --- diff --git a/data/rbot/plugins/games/azgame.rb b/data/rbot/plugins/games/azgame.rb index b1bb09e5..4f60278f 100644 --- a/data/rbot/plugins/games/azgame.rb +++ b/data/rbot/plugins/games/azgame.rb @@ -144,8 +144,7 @@ class AzGamePlugin < Plugin @registry[:wordcache] = @wordcache end - def listen(m) - return unless m.kind_of?(PrivMessage) + def message(m) return if m.channel.nil? or m.address? k = m.channel.downcase.to_s # to_sym? return unless @games.key?(k) diff --git a/data/rbot/plugins/games/quiz.rb b/data/rbot/plugins/games/quiz.rb index 792b75ae..a9ceddaf 100644 --- a/data/rbot/plugins/games/quiz.rb +++ b/data/rbot/plugins/games/quiz.rb @@ -360,9 +360,7 @@ class QuizPlugin < Plugin # Reimplemented from Plugin # - def listen( m ) - return unless m.kind_of?(PrivMessage) - + def message(m) chan = m.channel return unless @quizzes.has_key?( chan ) q = @quizzes[chan] diff --git a/data/rbot/plugins/games/shiritori.rb b/data/rbot/plugins/games/shiritori.rb index 71016e54..84ee9620 100644 --- a/data/rbot/plugins/games/shiritori.rb +++ b/data/rbot/plugins/games/shiritori.rb @@ -453,8 +453,7 @@ class ShiritoriPlugin < Plugin end # all messages from a channel is sent to its shiritori game if any - def listen(m) - return unless m.kind_of?(PrivMessage) + def message(m) return unless @games.has_key?(m.channel) # send the message to the game in the channel to handle it @games[m.channel].handle_message m diff --git a/data/rbot/plugins/games/wheelfortune.rb b/data/rbot/plugins/games/wheelfortune.rb index 37eb63b5..cc9a1446 100644 --- a/data/rbot/plugins/games/wheelfortune.rb +++ b/data/rbot/plugins/games/wheelfortune.rb @@ -506,8 +506,8 @@ class WheelOfFortune < Plugin end end - def listen(m) - return unless m.kind_of?(PrivMessage) and not m.address? + def message(m) + return if m.address? ch = m.channel.irc_downcase(m.server.casemap).intern return unless game = @games[ch] return unless game.running? diff --git a/data/rbot/plugins/karma.rb b/data/rbot/plugins/karma.rb index 2bd5f9f7..d8d378e3 100644 --- a/data/rbot/plugins/karma.rb +++ b/data/rbot/plugins/karma.rb @@ -59,8 +59,8 @@ class KarmaPlugin < Plugin "karma module: Listens to everyone's chat. ++/-- => increase/decrease karma for , karma for ? => show karma for , karmastats => show stats. Karma is a community rating system - only in-channel messages can affect karma and you cannot adjust your own." end - def listen(m) - return unless m.kind_of?(PrivMessage) && m.public? && m.message.match(/\+\+|--/) + def message(m) + return unless m.public? && m.message.match(/\+\+|--/) arg = nil op = nil ac = Hash.new diff --git a/data/rbot/plugins/linkbot.rb b/data/rbot/plugins/linkbot.rb index f36aa919..670be36d 100644 --- a/data/rbot/plugins/linkbot.rb +++ b/data/rbot/plugins/linkbot.rb @@ -45,11 +45,10 @@ class LinkBot < Plugin end # Main method - def listen(m) + def message(m) linkbots = @bot.config['linkbot.nicks'] return if linkbots.empty? return unless linkbots.include?(m.sourcenick) - return unless m.kind_of?(PrivMessage) # Now we know that _m_ is a PRIVMSG from a linkbot. Let's split it # in nick, network, message if @message_patterns.any? {|p| m.message =~ p} diff --git a/data/rbot/plugins/markov.rb b/data/rbot/plugins/markov.rb index e340d8b8..dcf3b776 100644 --- a/data/rbot/plugins/markov.rb +++ b/data/rbot/plugins/markov.rb @@ -190,8 +190,8 @@ class MarkovPlugin < Plugin end end - def listen(m) - return unless m.kind_of?(PrivMessage) && m.public? + def message(m) + return unless m.public? return if m.address? return if ignore? m.source diff --git a/data/rbot/plugins/quotes.rb b/data/rbot/plugins/quotes.rb index 73f1b9e7..1c5d9c99 100644 --- a/data/rbot/plugins/quotes.rb +++ b/data/rbot/plugins/quotes.rb @@ -142,9 +142,7 @@ class QuotePlugin < Plugin end end - def listen(m) - return unless(m.kind_of? PrivMessage) - + def message(m) command = m.message.dup if(m.address? && m.private?) case command diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb index d08c24e8..2cee5f4f 100644 --- a/data/rbot/plugins/url.rb +++ b/data/rbot/plugins/url.rb @@ -180,8 +180,7 @@ class UrlPlugin < Plugin Thread.new { handle_urls(m, urls, params[:urls].length) } end - def listen(m) - return unless m.kind_of?(PrivMessage) + def message(m) return if m.address? escaped = URI.escape(m.message, OUR_UNSAFE)