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

« back to all changes in this revision

Viewing changes to build/lib/gozerbot/xmpp/monitor.py

  • Committer: Package Import Robot
  • Author(s): Jeremy Malcolm
  • Date: 2012-04-03 21:58:28 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20120403215828-6mik0tzug5na93la
Tags: 0.99.1-2
* Removes logfiles on purge (Closes: #668767)
* Reverted location of installed files back to /usr/lib/gozerbot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# gozerbot/xmpp/monitor.py
 
2
#
 
3
#
 
4
 
 
5
""" monitors .. call callback on bot output. """
 
6
 
 
7
__copyright__ = 'this file is in the public domain'
 
8
 
 
9
# gozerbot imports
 
10
from gozerbot.utils.exception import handle_exception
 
11
from gozerbot.monitor import Monitor
 
12
from gozerbot.config import config
 
13
from gozerbot.eventbase import EventBase
 
14
from message import Message
 
15
 
 
16
class XMPPmonitor(Monitor):
 
17
 
 
18
    """ monitor jabber output """
 
19
 
 
20
    def handle(self, bot, event):
 
21
 
 
22
        """ fire jabber monitor callbacks. """
 
23
 
 
24
        try:
 
25
            #event.fromm = event['from'] = event.to
 
26
            e = Message()
 
27
            e.copyin(event)
 
28
            e.isreply = True
 
29
            e.iscmnd = True
 
30
            e.remotecmnd = True
 
31
            e.remoteout = bot.jid
 
32
            e.channel = event.to
 
33
            e.fromm = e['from'] = bot.jid
 
34
            e.nick = bot.nick
 
35
            e.botoutput = True
 
36
            Monitor.handle(self, bot, e)
 
37
        except AttributeError:
 
38
            handle_exception()
 
39
 
 
40
# xmpp monitor
 
41
xmppmonitor = XMPPmonitor('xmppmonitor')