]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
seen plugin: check if there's a previous action before using it
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 24 May 2009 11:49:38 +0000 (13:49 +0200)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 24 May 2009 11:52:15 +0000 (13:52 +0200)
If the registry data is not an Array, there will be no 'before'
information stored, so just use the normal output.

data/rbot/plugins/seen.rb

index babf74843386cf18d9fb2211854cb785ed90d6ee..0fc6f0760f4dfcc91e8ac622f3e5f0fac3764c5c 100644 (file)
@@ -81,14 +81,16 @@ class SeenPlugin < Plugin
       reg.last
     end
 
-    before = reg.first
+    if reg.kind_of? Array
+      before = reg.first
+    end
 
     formats = {
       :normal      => _("%{nick} was last seen %{when}, %{doing}"),
       :with_before => _("%{nick} was last seen %{when}, %{doing} and %{time} before %{did_before}")
     }
 
-    if [:PART, :QUIT].include?(saw.type.to_sym) &&
+    if before && [:PART, :QUIT].include?(saw.type.to_sym) &&
        [:PUBLIC, :ACTION].include?(before.type.to_sym)
       did_before = case before.type.to_sym
       when :PUBLIC