]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
+ use the message() delegate instead of listen() when possible
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 6 Apr 2008 23:02:13 +0000 (01:02 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 6 Apr 2008 23:02:13 +0000 (01:02 +0200)
data/rbot/plugins/games/azgame.rb
data/rbot/plugins/games/quiz.rb
data/rbot/plugins/games/shiritori.rb
data/rbot/plugins/games/wheelfortune.rb
data/rbot/plugins/karma.rb
data/rbot/plugins/linkbot.rb
data/rbot/plugins/markov.rb
data/rbot/plugins/quotes.rb
data/rbot/plugins/url.rb

index b1bb09e5f934e92aa202e7770d8644211516ac66..4f60278fcb2a72900bfdd1a3102579e97ed2a19a 100644 (file)
@@ -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)
index 792b75ae2e9f809e7e9efed79cf7d5ed46068948..a9ceddaf2af3529a16a4b3a391c119312fdd9565 100644 (file)
@@ -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]
index 71016e5434ecbde960aa44197641f04c31853fe8..84ee9620d869b566f258529345a0b8c566daad51 100644 (file)
@@ -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
index 37eb63b5e67ca80cfcbe7c56c2b3837b930d4e88..cc9a1446e8c322583ab5d9268088ad1f98fea0e2 100644 (file)
@@ -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?
index 2bd5f9f71584cf1026cacab01b330ff0e55e3493..d8d378e332c223ef54ea0997892905610ab73d15 100644 (file)
@@ -59,8 +59,8 @@ class KarmaPlugin < Plugin
     "karma module: Listens to everyone's chat. <thing>++/<thing>-- => increase/decrease karma for <thing>, karma for <thing>? => show karma for <thing>, 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
index f36aa9197ae0915112ea1764fa3c8052575b9b5b..670be36d564571915e5dd744ac96d03795cb31b4 100644 (file)
@@ -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}
index e340d8b8dde858399ec04a2368d4ca89d3d5ed55..dcf3b77679dc7e5ad304fa96a74f5efd8ba16d3b 100644 (file)
@@ -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
 
index 73f1b9e7f7c9e397d4a32f35c080966328d87af3..1c5d9c99045c9b2f45bcc343765fe965e520d1b4 100644 (file)
@@ -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
index d08c24e837fea4fe2bb88b6829a7ba5e322fef8a..2cee5f4f5d37b2d1443b16355fe9ae60c086fc20 100644 (file)
@@ -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)