From: kaliko Date: Thu, 1 Oct 2020 11:45:32 +0000 (+0200) Subject: Handles disconnections X-Git-Tag: 0.2.0~7 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=ca957c6dc76e96e46d8fc05fbb0c7dff1cb1437c;p=sid.git Handles disconnections --- diff --git a/sid/sid.py b/sid/sid.py index a62c7e4..a3ca555 100644 --- a/sid/sid.py +++ b/sid/sid.py @@ -90,6 +90,9 @@ class MUCBot(slixmpp.ClientXMPP): self.add_event_handler('message', self.message) self.add_event_handler('got_online', self._view) + # Handles disconnection + self.add_event_handler('disconnected', self.disconn) + # Discover bot internal command (ie. help) for name, value in inspect.getmembers(self): if inspect.ismethod(value) and \ @@ -110,6 +113,12 @@ class MUCBot(slixmpp.ClientXMPP): self.log.setLevel(log_level) self.log.debug('set logger, log level : %s', log_level) + def disconn(self, event): + """disconnected handler""" + msg = ": %s" % event if event else "‽" + self.log.info('Disconnected from server%s', msg) + self.connect() + def message(self, msg): """Messages handler