Skip to content

Commit

Permalink
plugin to print the top 10
Browse files Browse the repository at this point in the history
Signed-off-by: David A. Cuadrado <krawek@gmail.com>
  • Loading branch information
dcu committed Jan 25, 2011
1 parent 3670695 commit 95f5b19
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions plugins/karma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def usage

match /karma (.+)/, :method => :stats
match /fans (.+)/, :method => :fans
match /top/, :method => :top
match /\b(\S+)\s*(\+\+|\-\-|\+1|lol|thanks|thx|gracias)(\s|$)/, :use_prefix => false

def stats(m, nick)
Expand All @@ -25,6 +26,19 @@ def fans(m, nick)
end
end

def top(m)
if m.channel
channel = Channel.find(m.channel.name.downcase)
buffer = ""
count = 0
channel.users.all(:limit => 10, :order => "karma_up desc").each do |user|
buffer << "#{count+=1}. #{user.nick} [#{user.karma_up}] | "
end

m.reply buffer
end
end

def execute(m, nick, oper)
return if m.channel.nil?

Expand Down

0 comments on commit 95f5b19

Please sign in to comment.