This repository has been archived on 2023-04-13. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
CloudBot/disabled_stuff/choose.py
2015-02-18 22:53:13 +01:00

18 lines
397 B
Python

import re
import random
from util import hook
@hook.command
def choose(inp):
"""choose <choice1>, [choice2], [choice3], [choice4], ... --
Randomly picks one of the given choices."""
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()