5
""" the choice command can be used with a string or in a pipeline """
7
__copyright__ = 'this file is in the public domain'
10
from gozerbot.utils.generic import waitforqueue
11
from gozerbot.commands import cmnds
12
from gozerbot.examples import examples
13
from gozerbot.plughelp import plughelp
14
from gozerbot.tests import tests
19
plughelp.add('choice', 'make a random choice')
21
def handle_choice(bot, ievent):
23
""" make a random choice out of different words or list elements. """
28
result = waitforqueue(ievent.inqueue, 5)
30
ievent.missing('<space seperated list>')
36
ievent.reply(random.choice(result))
38
ievent.reply('nothing to choose from')
40
cmnds.add('choice', handle_choice, ['USER', 'WEB', 'CLOUD'], threaded=True)
41
examples.add('choice', 'make a random choice', '1) choice a b c 2) list | choice')
42
tests.add('choice a ab ac', 'a')
43
tests.add('list | choice')