Skip to content

Instantly share code, notes, and snippets.

@EntityReborn
Created April 16, 2011 04:27
Show Gist options
  • Save EntityReborn/922864 to your computer and use it in GitHub Desktop.
Save EntityReborn/922864 to your computer and use it in GitHub Desktop.
class BotFactory(protocol.ReconnectingClientFactory):
protocol = Bot
def __init__(self, config, name, state):
self.config = config
self.name = name
self.sharedstate = state
self.quitted = False
def clientConnectionLost(self, connector, unused_reason):
if not self.quitted:
protocol.ReconnectingClientFactory.clientConnectionLost(self, connector, unused_reason)
if not self.sharedstate["bots"]:
reactor.stop()
def removeBot(self, bot):
self.sharedstate["bots"][self.name].remove(bot)
if not self.sharedstate["bots"][self.name]:
del self.sharedstate["bots"][self.name]
def addBot(self, bot):
self.sharedstate["bots"][self.name].append(bot)
def shutdown(self):
self.quitted = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment