X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fseen.rb;h=aec5a064fa8ebbd7c990119a71ad87a17ccbecb9;hb=360bed41ac8ac97419ac40cb971fba94a425ca19;hp=80d52f6595767540124a5214b1a2e90b35501707;hpb=676dd61e6b0bea5f506d064039a685944aefd6fb;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/seen.rb b/data/rbot/plugins/seen.rb index 80d52f65..aec5a064 100644 --- a/data/rbot/plugins/seen.rb +++ b/data/rbot/plugins/seen.rb @@ -1,23 +1,6 @@ Saw = Struct.new("Saw", :nick, :time, :type, :where, :message) class SeenPlugin < Plugin - # turn a number of seconds into a human readable string, e.g - # 2 days, 3 hours, 18 minutes, 10 seconds - def secs_to_string(secs) - ret = "" - days = (secs / (60 * 60 * 24)).to_i - secs = secs % (60 * 60 * 24) - hours = (secs / (60 * 60)).to_i - secs = (secs % (60 * 60)) - mins = (secs / 60).to_i - secs = (secs % 60).to_i - ret += "#{days} days, " if days > 0 - ret += "#{hours} hours, " if hours > 0 || days > 0 - ret += "#{mins} minutes and " if mins > 0 || hours > 0 || days > 0 - ret += "#{secs} seconds" - return ret - end - def help(plugin, topic="") "seen => have you seen, or when did you last see " end @@ -38,6 +21,7 @@ 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? @@ -80,7 +64,7 @@ class SeenPlugin < Plugin if (ago.to_i == 0) ret += "just now, " else - ret += secs_to_string(ago) + " ago, " + ret += Utils.secs_to_string(ago) + " ago, " end case saw.type @@ -95,7 +79,7 @@ class SeenPlugin < Plugin when "JOIN" ret += "joining #{saw.where}" when "QUIT" - ret += "quiting IRC (#{saw.message})" + ret += "quitting IRC (#{saw.message})" when "TOPIC" ret += "changing the topic of #{saw.where} to #{saw.message}" end