I'm sure there was a reason this was complicated.

This commit is contained in:
Fletcher Boyd 2013-09-05 08:53:07 +08:00
parent 8c60a923ba
commit a211115b7e

View file

@ -1,4 +1,3 @@
import re
import random import random
from util import hook from util import hook
@ -6,13 +5,10 @@ from util import hook
@hook.command @hook.command
def choose(inp): def choose(inp):
"""choose <choice1>, [choice2], [choice3] ... [choiceN] """choose <choice1>, [choice2], [choice3]
Randomly picks one of the given choices.""" Randomly picks one of the given choices."""
c = re.findall(r'([^,]+)', inp) c = inp.split(" ")
if len(c) == 1: if len(c) == 1:
c = re.findall(r'(\S+)', inp) return 'banana'
if len(c) == 1:
return 'The decision is up to you!'
return random.choice(c).strip() return random.choice(c).strip()