~ubuntu-branches/ubuntu/utopic/gozerbot/utopic

« back to all changes in this revision

Viewing changes to debian/gozerbot/usr/lib/python2.5/site-packages/gozerplugs/plugs/to.py

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Malcolm
  • Date: 2009-09-14 09:00:29 UTC
  • mfrom: (1.1.4 upstream) (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090914090029-uval0ekt72kmklxw
Tags: 0.9.1.3-3
Changed dependency on python-setuptools to python-pkg-resources
(Closes: #546435) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# plugs/to.py
2
 
#
3
 
#
4
 
 
5
 
__copyright__ = 'this file is in the public domain'
6
 
 
7
 
from gozerbot.commands import cmnds
8
 
from gozerbot.generic import getwho, waitforqueue
9
 
from gozerbot.examples import examples
10
 
from gozerbot.plughelp import plughelp
11
 
 
12
 
plughelp.add('to', 'send the output to another user .. used in a pipeline')
13
 
 
14
 
def handle_to(bot, ievent):
15
 
    """ direct pipeline output to <nick> """
16
 
    if not ievent.inqueue:
17
 
        ievent.reply('use to in a pipeline')
18
 
        return
19
 
    try:
20
 
        nick = ievent.args[0]
21
 
    except IndexError:
22
 
        ievent.reply('to <nick>')
23
 
        return
24
 
    if nick == 'me':
25
 
        nick = ievent.nick
26
 
    if not getwho(bot, nick):
27
 
        ievent.reply("don't know %s" % nick)
28
 
        return
29
 
    result = waitforqueue(ievent.inqueue, 5)
30
 
    if result:
31
 
        ievent.reply("%s sends you this:" % ievent.nick, nick=nick)
32
 
        ievent.reply(result, nick=nick, dot=True)
33
 
        if len(result) == 1:
34
 
            ievent.reply('1 element sent')
35
 
        else:
36
 
            ievent.reply('%s elements sent' % len(result))
37
 
    else:
38
 
        ievent.reply('nothing to send')
39
 
 
40
 
cmnds.add('to', handle_to, 'USER')
41
 
examples.add('to', 'send pipeline output to another user', 'list | to dunker')