summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-05-25 19:44:13 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-05-25 19:44:13 +0200
commit62664c9248a89a185527cd2ec26e55b52dabeb80 (patch)
tree4c118b1729ac2ea4550f2373bd7acfc509b90868
parent070ede1ae77a89728341f7d084e882e04ffd2d2a (diff)
Cleaned up initial connect code.
-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)