]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/seen.rb
plugins/keywords: add method that was missing from commit 7cac523563de6473d2f93fd2d05 ...
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / seen.rb
index 6bd86a7094a4dc03311a389e8fdf91cf744b50f7..704b83241a9d5a9ba659f8481643efe6e2eda8e0 100644 (file)
@@ -1,4 +1,4 @@
-Saw = Struct.new("Saw", :nick, :time, :type, :where, :message)
+define_structure :Saw, :nick, :time, :type, :where, :message
 
 class SeenPlugin < Plugin
   def help(plugin, topic="")
@@ -21,9 +21,10 @@ class SeenPlugin < Plugin
   end
 
   def listen(m)
+    return if m.sourcenick.nil?
     # keep database up to date with who last said what
     if m.kind_of?(PrivMessage)
-      return if m.private? || m.address?
+      return if m.private?
       if m.action?
         @registry[m.sourcenick] = Saw.new(m.sourcenick.dup, Time.new, "ACTION", 
                                           m.target, m.message.dup)
@@ -66,20 +67,20 @@ class SeenPlugin < Plugin
       ret += Utils.secs_to_string(ago) + " ago, "
     end
 
-    case saw.type
-    when "PUBLIC"
+    case saw.type.to_sym
+    when :PUBLIC
       ret += "saying #{saw.message}"
-    when "ACTION"
+    when :ACTION
       ret += "doing #{saw.nick} #{saw.message}"
-    when "NICK"
+    when :NICK
       ret += "changing nick from #{saw.nick} to #{saw.message}"
-    when "PART"
+    when :PART
       ret += "leaving #{saw.where}"
-    when "JOIN"
+    when :JOIN
       ret += "joining #{saw.where}"
-    when "QUIT"
-      ret += "quiting IRC (#{saw.message})"
-    when "TOPIC"
+    when :QUIT
+      ret += "quitting IRC (#{saw.message})"
+    when :TOPIC
       ret += "changing the topic of #{saw.where} to #{saw.message}"
     end
   end