Created
April 16, 2011 04:27
-
-
Save EntityReborn/922864 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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