blob: 7f6a69912b47e41418c97c44cc3c26876c14af27 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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.load(mod)
def load(self, name):
mod = __import__('modules.' + name, globals(), locals(), ['Module'])
self.modules.append(mod.Module(self))
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()
|