This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
2013-09-10 03:29:38 +02:00
|
|
|
import re
|
2011-11-20 10:23:31 +01:00
|
|
|
import random
|
|
|
|
|
|
|
|
from util import hook
|
|
|
|
|
|
|
|
|
|
|
|
@hook.command
|
|
|
|
def choose(inp):
|
2013-11-12 07:06:06 +01:00
|
|
|
"""choose <choice1>, [choice2], [choice3], [choice4], ... --
|
2013-09-04 12:30:04 +02:00
|
|
|
Randomly picks one of the given choices."""
|
2011-11-20 10:23:31 +01:00
|
|
|
|
2013-09-10 03:29:38 +02:00
|
|
|
c = re.findall(r'([^,]+)', inp)
|
2011-11-20 10:23:31 +01:00
|
|
|
if len(c) == 1:
|
2013-09-10 03:29:38 +02:00
|
|
|
c = re.findall(r'(\S+)', inp)
|
|
|
|
if len(c) == 1:
|
|
|
|
return 'The decision is up to you!'
|
|
|
|
|
2013-11-12 07:06:06 +01:00
|
|
|
return random.choice(c).strip()
|