From 4e8cef2a77ca558c725a2a29537d0047450a547f Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Mon, 1 Jun 2015 12:56:42 +0200 Subject: reset self-ping timer on every MUC message --- src/tabs/muctab.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py index 486c9078..bb731d20 100644 --- a/src/tabs/muctab.py +++ b/src/tabs/muctab.py @@ -1554,9 +1554,7 @@ class MucTab(ChatTab): if self is not self.core.current_tab(): self.state = 'disconnected' self.joined = False - if self.self_ping_event is not None: - self.core.remove_timed_event(self.self_ping_event) - self.self_ping_event = None + self.disable_self_ping_event() def get_single_line_topic(self): """ @@ -1618,6 +1616,10 @@ class MucTab(ChatTab): in the room anymore Return True if the message highlighted us. False otherwise. """ + + # reset self-ping interval + self.enable_self_ping_event() + self.log_message(txt, nickname, time=time, typ=kwargs.get('typ', 1)) args = dict() for key, value in kwargs.items(): @@ -1674,9 +1676,15 @@ class MucTab(ChatTab): delay = config.get_by_tabname("self_ping_delay", self.general_jid, default=0) if delay <= 0: # use 0 or some negative value to disable it return + self.disable_self_ping_event() self.self_ping_event = timed_events.DelayedEvent(delay, self.send_self_ping) self.core.add_timed_event(self.self_ping_event) + def disable_self_ping_event(self): + if self.self_ping_event is not None: + self.core.remove_timed_event(self.self_ping_event) + self.self_ping_event = None + def send_self_ping(self): to = self.name + "/" + self.own_nick self.core.xmpp.plugin['xep_0199'].send_ping(jid=to, -- cgit v1.2.3