.. _fbf.plugs.core.choice: choice ~~~~~~ .. automodule:: fbf.plugs.core.choice :show-inheritance: :members: :undoc-members: CODE ---- :: # fbf/plugs/core/choice.py # # """ the choice command can be used with a string or in a pipeline. """ .. _fbf.plugs.core.choice_fbf_imports: fbf imports -------------- :: from fbf.utils.generic import waitforqueue from fbf.lib.commands import cmnds from fbf.lib.examples import examples .. _fbf.plugs.core.choice_basic_imports: basic imports ---------------- :: import random import time .. _fbf.plugs.core.choice_choice_command: choice command ----------------- :: def handle_choice(bot, ievent): """ arguments: [] - make a random choice out of different words or list elements. when used in a pipeline will choose from that. """ result = [] if ievent.prev: ievent.prev.wait() result = ievent.inqueue else: result = ievent.args if result: ievent.reply(random.choice(result)) else: ievent.reply("no result") cmnds.add('choice', handle_choice, ['OPER', 'USER', 'GUEST']) examples.add('choice', 'make a random choice', '1) choice a b c 2) list ! choice')