From ca957c6dc76e96e46d8fc05fbb0c7dff1cb1437c Mon Sep 17 00:00:00 2001 From: kaliko Date: Thu, 1 Oct 2020 13:45:32 +0200 Subject: [PATCH] Handles disconnections --- sid/sid.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- 2.39.5