diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-05-25 20:07:55 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-05-25 20:07:55 +0200 |
commit | 2066a309d2672f6b071da87c2fb156a2af15c5d3 (patch) | |
tree | 8b353d5d6bdae666ddb0ed5407c6030bcef9c4d7 | |
parent | b97e85feef6b4dad4add23d17e37fd5ee976e1e3 (diff) | |
parent | f9e9af49233ba05a87f6c00c387134394443bfb3 (diff) |
Merge branch 'master' into ipv6
Conflicts:
fot.py
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | fot.py | 36 |
2 files changed, 22 insertions, 15 deletions
@@ -1 +1,2 @@ *.pyc +*.swp @@ -57,9 +57,6 @@ class Bot(irc.IRCClient): bots.append(self) self.modules = {} - def __del__(self): - bots.remove(self) - def __repr__(self): return '<Bot %s@%s>' % (self.nickname, self.factory.server) @@ -97,6 +94,9 @@ class Bot(irc.IRCClient): self.modules = {} irc.IRCClient.connectionLost(self, reason) + def reconnect(self): + self.quit('reconnecting') + class BotFactory(protocol.ReconnectingClientFactory): protocol = Bot @@ -113,24 +113,26 @@ class BotFactory(protocol.ReconnectingClientFactory): print 'Connecting to', connector.host def clientConnectionFailed(self, connector, reason): - print 'Connection failed:', reason + print 'Connection failed:', reason.getErrorMessage() protocol.ReconnectingClientFactory.clientConnectionFailed(self, connector, reason) def clientConnectionLost(self, connector, reason): - print 'Connection lost:', reason + print 'Connection lost:', reason.getErrorMessage() 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')) if config.has_option(server, 'host6'): bind6 = (config.get(server, 'bind6'), 0) if config.has_option(server, 'bind6') else None @@ -138,6 +140,10 @@ for server in (server for server in config.sections() if server.startswith('serv else: 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) |