2
# -*- coding: iso-8859-1 -*-
4
MoinMoin - jabber bot main file
6
@copyright: 2007 by Karol Nowak <grywacz@gmail.com>
7
@license: GNU GPL, see COPYING for details.
10
import logging, os, sys, time
11
from Queue import Queue
13
from jabberbot.config import BotConfig
14
from jabberbot.i18n import init_i18n
15
from jabberbot.xmppbot import XMPPBot
16
from jabberbot.xmlrpcbot import XMLRPCServer, XMLRPCClient
19
def _check_xmpp_version():
20
"""Checks if available version of pyxmpp is recent enough
22
Since __revision__ is broken in current trunk, we can't rely on it.
23
Therefore a simple check for known problems is used to determine if
24
we can start the bot with it.
29
msg = pyxmpp.message.Message()
30
form = pyxmpp.jabber.dataforms.Form()
35
print 'Your version of pyxmpp is too old!'
36
print 'You need a least revision 665 to run this bot. Exiting...'
40
"""Starts the jabber bot"""
46
print """MoinMoin notification bot
48
Usage: %(myname)s [--server server] [--xmpp_port port] [--user user] [--resource resource] [--password pass] [--xmlrpc_host host] [--xmlrpc_port port]
49
""" % {"myname": os.path.basename(args[0])}
53
log = logging.getLogger(__name__)
54
log.setLevel(logging.DEBUG)
55
log.addHandler(logging.StreamHandler())
59
# TODO: actually accept options from the help string
60
commands_from_xmpp = Queue()
61
commands_to_xmpp = Queue()
69
if not xmpp_bot or not xmpp_bot.isAlive():
70
log.info("(Re)starting XMPP thread...")
71
xmpp_bot = XMPPBot(BotConfig, commands_from_xmpp, commands_to_xmpp)
72
xmpp_bot.setDaemon(True)
75
if not xmlrpc_client or not xmlrpc_client.isAlive():
76
log.info("(Re)starting XMLRPC client thread...")
77
xmlrpc_client = XMLRPCClient(BotConfig, commands_from_xmpp, commands_to_xmpp)
78
xmlrpc_client.setDaemon(True)
81
if not xmlrpc_server or not xmlrpc_server.isAlive():
82
log.info("(Re)starting XMLRPC server thread...")
83
xmlrpc_server = XMLRPCServer(BotConfig, commands_to_xmpp)
84
xmlrpc_server.setDaemon(True)
89
except KeyboardInterrupt, i:
93
log.info("Stopping XMPP bot thread, please wait...")
95
log.info("Stopping XMLRPC client thread, please wait...")
101
if __name__ == "__main__":