diff --git a/commands/challenge.py b/commands/challenge.py new file mode 100644 index 0000000..2ba0220 --- /dev/null +++ b/commands/challenge.py @@ -0,0 +1,32 @@ +import plugin +from pluralslib import plural + +import random +WPMS = { + "easy": 5, + "normal": 10, + "hard": 20, + "hardcore": 40, + "insane": 60 +} + +def pick_random_wpm(): + return random.randint(5,60) + +def pick_random_time(): + return random.randint(1,6)*5 + +@plugin.command("challenge","") +def challenge(bot,channel,nick,*args): + args = list(args) + wpm = pick_random_wpm() + time = pick_random_time() + for arg in args: + if arg in WPMS: # preset + wpm = WPMS[arg] + elif arg.isdigit(): # give specific WPM + wpm = int(arg) + elif arg[0]=="t" and arg[1:].isdigit(): # specific time + time = int(arg[1:]) + words = wpm*time + bot.say(channel,"{}: Write {} in {}".format(nick,plural(words,"word"),plural(time,"minute")))