2010-01-17 04:24:36 +00:00
|
|
|
import re
|
|
|
|
import random
|
|
|
|
|
|
|
|
from util import hook
|
|
|
|
|
2010-03-01 02:32:41 +00:00
|
|
|
|
2010-01-17 04:24:36 +00:00
|
|
|
@hook.command
|
|
|
|
def choose(inp):
|
|
|
|
".choose <choice1>, <choice2>, ... <choicen> -- makes a decision"
|
|
|
|
|
|
|
|
if not inp:
|
|
|
|
return choose.__doc__
|
2010-03-01 02:32:41 +00:00
|
|
|
|
2010-01-17 04:24:36 +00:00
|
|
|
c = re.findall(r'([^,]+)', inp)
|
|
|
|
if len(c) == 1:
|
|
|
|
c = re.findall(r'(\S+)', inp)
|
|
|
|
if len(c) == 1:
|
|
|
|
return 'the decision is up to you'
|
|
|
|
|
|
|
|
return random.choice(c).strip()
|