2019-10-31 16:51:15 +00:00
|
|
|
import plugin
|
|
|
|
from dictdata import DictData
|
|
|
|
|
|
|
|
wrote = DictData("wrote.json")
|
|
|
|
|
|
|
|
def get_wordcount(nick):
|
|
|
|
return wrote.get(nick,0)
|
|
|
|
|
|
|
|
@plugin.command("wrote")
|
2019-10-31 17:58:11 +00:00
|
|
|
def _wrote(bot,channel,nick,*args):
|
2019-10-31 16:51:15 +00:00
|
|
|
args = list(args)
|
|
|
|
if len(args)!=1:
|
|
|
|
bot.say(channel,"Usage: !wrote <name/number>")
|
2019-10-31 17:57:32 +00:00
|
|
|
if args[0].isdigit():
|
2019-10-31 16:51:15 +00:00
|
|
|
wrote[nick]=get_wordcount(nick)+int(args[0])
|
|
|
|
else:
|
2019-11-01 14:57:00 +00:00
|
|
|
bot.say(channel,"{}: _{}_ has written {!s} words".format(nick,args[0],get_wordcount(args[0])))
|
2019-10-31 18:12:00 +00:00
|
|
|
|
|
|
|
@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
|
2019-10-31 18:14:27 +00:00
|
|
|
check = [(k,wrote[k]) for k in wrote.value.keys()]
|
2019-10-31 18:12:00 +00:00
|
|
|
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))
|