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

« back to all changes in this revision

Viewing changes to gozerbot/plugs/inform.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
# gozerbot/plugs/inform.py
 
2
#
 
3
#
 
4
 
 
5
""" prepend nick: to the output of a command. """
 
6
 
 
7
# gozerbot imports
 
8
from gozerbot.commands import cmnds
 
9
from gozerbot.examples import examples
 
10
from gozerbot.plugins import plugins
 
11
from gozerbot.plughelp import plughelp
 
12
from gozerbot.tests import tests
 
13
 
 
14
import copy
 
15
 
 
16
plughelp.add('inform', 'inform <nick> the output of a command')
 
17
 
 
18
def handle_inform(bot, ievent):
 
19
 
 
20
    """ prepend nick: to the output of command to another user """
 
21
 
 
22
    try:
 
23
        nick, cmnd = ievent.rest.split(' ', 1)
 
24
    except ValueError:
 
25
        ievent.missing('<nick> <command>')
 
26
        return
 
27
 
 
28
    event = copy.deepcopy(ievent)
 
29
    event.txt = cmnd
 
30
    event.onlyqueues = True
 
31
    result = plugins.cmnd(bot, event)
 
32
 
 
33
    if not result:
 
34
        ievent.reply("no result for %s" % cmnd)
 
35
        return
 
36
 
 
37
    ievent.reply("%s: " % nick, result, dot=True)
 
38
 
 
39
cmnds.add('inform', handle_inform, 'USER', threaded=True)
 
40
examples.add('inform', 'inform <nick> <command> .. inform <nick> the output of command', 'inform dunker version')
 
41
tests.add('inform dunker version', 'dunker')