5
""" count number of items in result queue. """
7
__copyright__ = 'this file is in the public domain'
10
from gozerbot.commands import cmnds
11
from gozerbot.utils.generic import waitforqueue
12
from gozerbot.examples import examples
13
from gozerbot.plughelp import plughelp
14
from gozerbot.tests import tests
16
plughelp.add('count', 'the count command counts the number of results in a \
19
def handle_count(bot, ievent):
21
""" show nr of elements in result list. """
23
if not ievent.inqueue:
24
ievent.reply("use count in a pipeline")
27
result = waitforqueue(ievent.inqueue, 5)
28
ievent.reply(str(len(result)))
30
cmnds.add('count', handle_count, ['USER', 'WEB', 'CLOUD'], threaded=True)
31
examples.add('count', 'count nr of items', 'todo | count')
32
tests.add('list | count')