5
__copyright__ = 'this file is in the public domain'
7
from gozerbot.generic import waitforqueue
8
from gozerbot.commands import cmnds
9
from gozerbot.plughelp import plughelp
10
from gozerbot.examples import examples
12
plughelp.add('tail', 'show last <nr> elements of pipeline')
14
def handle_tail(bot, ievent):
15
""" used in a pipeline .. show last <nr> elements """
16
if not ievent.inqueue:
17
ievent.reply("use tail in a pipeline")
20
nr = int(ievent.args[0])
21
except (ValueError, IndexError):
22
ievent.reply('tail <nr>')
24
result = waitforqueue(ievent.inqueue, 30)
26
ievent.reply('no data to tail')
28
ievent.reply(result[-nr:])
30
cmnds.add('tail', handle_tail, ['USER', 'ANON'])
31
examples.add('tail', 'show last <nr> lines of pipeline output', \