cosmicbot/commands/challenge.py

33 lines
710 B
Python

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,30)
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")))