42 lines
946 B
Python
42 lines
946 B
Python
from connection.xmpp import XMPPConnection
|
|
|
|
import signal, sys
|
|
from config import config
|
|
|
|
class ModuleManager:
|
|
def __init__(self, config):
|
|
self.config = config
|
|
self.modules = {}
|
|
|
|
for mod in config['modules']:
|
|
self.get(mod)
|
|
|
|
def get(self, name):
|
|
if not name in self.modules:
|
|
mod = __import__('modules.' + name, globals(), locals(), ['Module'])
|
|
self.modules[name] = mod.Module(self)
|
|
|
|
return self.modules[name]
|
|
|
|
|
|
run = True
|
|
|
|
def exithandler(signum, frame):
|
|
global run
|
|
run = False
|
|
|
|
signal.signal(signal.SIGINT, exithandler)
|
|
signal.signal(signal.SIGTERM, exithandler)
|
|
signal.signal(signal.SIGQUIT, exithandler)
|
|
|
|
modman = ModuleManager(config)
|
|
|
|
connection = XMPPConnection(config, modman)
|
|
connection.connect()
|
|
|
|
while run:
|
|
act = connection.stream.loop_iter(1)
|
|
if not act:
|
|
connection.idle()
|
|
|
|
connection.disconnect()
|