diff -r a849c00b63f8 -r 8574aeff9b36 fixbot/module.py --- a/fixbot/module.py Sat Feb 20 22:32:18 2010 +0200 +++ b/fixbot/module.py Sat Feb 20 23:06:43 2010 +0200 @@ -13,7 +13,7 @@ name = None def __str__ (self) : - return "Module %s:" % (self.name) + return "%s" % (self.name) def __repr__ (self) : return "" % (self.name, ) @@ -70,6 +70,7 @@ # XXX: legacy: self.secret = config['api-secret'] + def _onRegistered (self, connection) : """ Connected to nexus and registered @@ -78,16 +79,20 @@ log.msg("Connected and registered") self.connection = connection - + + # XXX: abort on errors? self.handleConnect() + + # XXX: unused, bad interface def disconnect (self) : """ Disconnect from Nexus """ self.connection.transport.loseConnection() - + + def sendEvent (self, type, msg) : """ Send event to nexus @@ -95,6 +100,7 @@ self.connection.sendEvent(Event(self, type, msg)) + def handleConnect (self) : """ Do something once we are connected to nexus and registered @@ -102,6 +108,13 @@ pass + def abort (self, err) : + """ + Abort this module, disconnecting with the given error + """ + + self.connection.abort(str(err)) + def makeService (module_class, config, protocol) : s = service.MultiService()