view jabberbot/main.py @ 2121:ae2134211ac1

XMPP -> wiki XML RPC, the beginning...
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Thu, 14 Jun 2007 01:19:20 +0200
parents a4d95b9d8f37
children 01f05e74aa9c 4b4868ae88f0
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - jabber bot main file

    @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
    @license: GNU GPL, see COPYING for details.
"""

import sys
import os
from Queue import Queue

from jabberbot.config import BotConfig
from jabberbot.xmppbot import XMPPBot
from jabberbot.xmlrpcbot import XMLRPCServer, XMLRPCClient


def main():
    args = sys.argv
    
    if "--help" in args:
        print """MoinMoin notification bot
        
        Usage: %(myname)s [--server server] [--xmpp_port port] [--user user] [--resource resource] [--password pass] [--xmlrpc_host host] [--xmlrpc_port port]
        """ % { "myname": os.path.basename(args[0]) }
        
        raise SystemExit
    
    # TODO: actually accept options from the help string

    commands_from_xmpp = Queue()
    commands_to_xmpp = Queue()
    
    try:
        xmpp_bot = XMPPBot(BotConfig, commands_from_xmpp, commands_to_xmpp)
        xmlrpc_client = XMLRPCClient(BotConfig, commands_from_xmpp, commands_to_xmpp)
        xmlrpc_server = XMLRPCServer(BotConfig, commands_to_xmpp)
        
        xmpp_bot.start()
        xmlrpc_client.start()
        xmlrpc_server.start()
    
    except KeyboardInterrupt, i:
        print i
        sys.exit(0)

        
if __name__ == "__main__": main()