the choice command can be used with a string or in a pipeline
make a random choice out of different words or list elements.
# plugs/choice.py # # """ the choice command can be used with a string or in a pipeline """ __status__ = "seen"
from gozerbot.utils.generic import waitforqueue from gozerbot.commands import cmnds from gozerbot.examples import examples from gozerbot.plughelp import plughelp from gozerbot.tests import tests
import random
plughelp.add('choice', 'make a random choice')
def handle_choice(bot, ievent): """ make a random choice out of different words or list elements. """ result = [] if ievent.inqueue: result = waitforqueue(ievent.inqueue, 5) elif not ievent.args: ievent.missing('<space seperated list>') ; return else: result = ievent.args if result: ievent.reply(random.choice(result)) else: ievent.reply('nothing to choose from') cmnds.add('choice', handle_choice, ['USER', 'WEB', 'CLOUD'], threaded=True) examples.add('choice', 'make a random choice', '1) choice a b c 2) list | choice') tests.add('choice a ab ac', 'a') tests.add('list | choice')