# File contrib/plugins/stats.rb, line 136 def handle_stats(m) if not m.private? total = 0 tokens = @channels[m.target] hsh = tokens[m.params] msg1 = "" if not hsh.empty? sorted = hsh.sort { |i, j| j[1] <=> i[1] } sorted.each { |a| total += a[1] } msg = "Stats for #{m.params}. Said #{total} times. The top sayers are " if sorted[0..2] msg << "#{sorted[0].join ':'}" if sorted[0] msg << ", #{sorted[1].join ':'}" if sorted[1] msg << ", and #{sorted[2].join ':'}" if sorted[2] msg << "." msg1 << "#{m.sourcenick} has said it " if hsh[m.sourcenick] msg1 << "#{hsh[m.sourcenick]} times." else msg1 << "0 times." end else msg << "#{m.params} has not been said yet!" end @bot.action m.replyto, msg @bot.action m.replyto, msg1 if msg1 else m.reply "#{m.params} is not currently being tracked." end end end