forked from milosivanovic/xbot
-
Notifications
You must be signed in to change notification settings - Fork 2
/
bot
executable file
·34 lines (28 loc) · 881 Bytes
/
bot
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
#!/usr/bin/python
import StringIO
import xbot
import re
from ConfigParser import ConfigParser
default_cfg = StringIO.StringIO("""\
[module: botdb]
type = sqlite
path = xbot.db
[module: usage]
two_degrees = off
orcon = off
[general]
prefix = !
""")
if __name__ == "__main__":
config = ConfigParser()
config.readfp(default_cfg)
if config.read('xbot.conf'):
for conf in config.__dict__['_sections']:
possible_network = re.match('^network:(.*?)$', conf)
if possible_network:
possible_network = possible_network.group(0).strip()
config.active_network = possible_network
bot = xbot.Initialise([server.strip().split(':') for server in config.get(possible_network, 'servers').split(',')], config)
bot.run()
else:
print "Error: Cannot read configuration file."