summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfot.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/fot.py b/fot.py
index 8412e8c..ff0b798 100755
--- a/fot.py
+++ b/fot.py
@@ -120,20 +120,26 @@ class BotFactory(protocol.ReconnectingClientFactory):
print 'Connection lost:', reason
protocol.ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
-print 'Starting per-network instances...'
-for server in (server for server in config.sections() if server.startswith('server/')):
- if not config.has_option(server,'host') or not config.has_option(server, 'port') or not config.has_option(server, 'channels') or config.has_option(server, 'disabled'):
- continue
+def start_server(server):
+ if not config.has_option(server,'host') or not config.has_option(server, 'port') \
+ or not config.has_option(server, 'channels') or config.has_option(server, 'disabled'):
+ return
+
channels = []
- ms = [(m, config.get(server, m)) for m in modules.keys() if config.has_option(server, m)]
- for c in config.get(server, 'channels').split(' '):
- ch = [x[0] for x in ms if c in x[1]]
- channels.append('%s (%s)' % (c, ' '.join(ch)))
- print '%s: %s' % (server, ' '.join(channels))
- del channels, ms, c, ch, x
+ server_modules = [(m, config.get(server, m).split()) for m in modules.keys() if config.has_option(server, m)]
+ for channel in config.get(server, 'channels').split():
+ channel_modules = [x[0] for x in server_modules if channel in x[1]]
+ channels.append('%s (%s)' % (channel, ' '.join(channel_modules) if len(channel_modules) else 'No modules'))
+
+ print '%s: %s' % (server, ' '.join(channels) if len(channels) else 'No channels')
+
factory = BotFactory(server, config.get(server, 'nickname'))
reactor.connectTCP(config.get(server, 'host'), config.getint(server, 'port'), factory)
+print 'Starting per-network instances...'
+for server in (server for server in config.sections() if server.startswith('server/')):
+ start_server(server)
+
loginfactory = login.getManholeFactory(globals(), os.path.expanduser('~/.fot.users'))
reactor.listenTCP(3333, loginfactory)