]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/seen.rb
seen plugin: fix seen data for nick change
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / seen.rb
index aec5a064fa8ebbd7c990119a71ad87a17ccbecb9..18d75d7e396761b0aad53f1ea4de5ffc85498f11 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="")
@@ -38,10 +38,10 @@ class SeenPlugin < Plugin
                                         nil, m.message.dup)
     elsif m.kind_of?(NickMessage)
       return if m.address?
-      @registry[m.message] = Saw.new(m.sourcenick.dup, Time.new, "NICK", 
-                                        nil, m.message.dup)
-      @registry[m.sourcenick] = Saw.new(m.sourcenick.dup, Time.new, "NICK", 
-                                        nil, m.message.dup)
+      @registry[m.oldnick] = Saw.new(m.oldnick, Time.new, "NICK", 
+                                        nil, m.newnick)
+      @registry[m.newnick] = Saw.new(m.oldnick, Time.new, "NICK", 
+                                        nil, m.newnick)
     elsif m.kind_of?(PartMessage)
       return if m.address?
       @registry[m.sourcenick] = Saw.new(m.sourcenick.dup, Time.new, "PART", 
@@ -67,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"
+    when :QUIT
       ret += "quitting IRC (#{saw.message})"
-    when "TOPIC"
+    when :TOPIC
       ret += "changing the topic of #{saw.where} to #{saw.message}"
     end
   end