Add highscore leaderboard for wrote
This commit is contained in:
parent
4827d81831
commit
8dc1cfb01f
|
@ -15,3 +15,19 @@ def _wrote(bot,channel,nick,*args):
|
||||||
wrote[nick]=get_wordcount(nick)+int(args[0])
|
wrote[nick]=get_wordcount(nick)+int(args[0])
|
||||||
else:
|
else:
|
||||||
bot.say(channel,"{}: _{}_ has wrote {!s} words".format(nick,args[0],get_wordcount(args[0])))
|
bot.say(channel,"{}: _{}_ has wrote {!s} words".format(nick,args[0],get_wordcount(args[0])))
|
||||||
|
|
||||||
|
@plugin.command("highscore")
|
||||||
|
def highscore(bot,channel,nick,*args):
|
||||||
|
count = 5
|
||||||
|
if len(args)==1:
|
||||||
|
c = int(args[0])
|
||||||
|
if c>10: # cap count at 10
|
||||||
|
c = 10
|
||||||
|
elif c<1: # floor count at 1
|
||||||
|
c = 1
|
||||||
|
check = [(k,wrote[k]) for k in wrote]
|
||||||
|
check.sort(key=lambda x: -x[1])
|
||||||
|
ret = []
|
||||||
|
for user in check[:5]:
|
||||||
|
ret.append("_{}_ ({!s} words)".format(*user))
|
||||||
|
bot.say(channel,nick+": "+", ".join(ret))
|
||||||
|
|
Loading…
Reference in New Issue