support "0" kickrejoin delay without creating a timer

This commit is contained in:
jesopo 2019-09-15 22:22:41 +01:00
parent f9d13dc373
commit 21fa2120df

View file

@ -25,9 +25,15 @@ class Module(ModuleManager.BaseModule):
def on_kick(self, event):
if self._should_rejoin(event["server"], event["channel"]):
delay = self._get_delay(event["server"], event["channel"])
self.timers.add("kick-rejoin", delay, server=event["server"],
channel_name=event["channel"].name)
if delay == 0:
self._rejoin(event["server"], event["channel"].name)
else:
self.timers.add("kick-rejoin", delay, server=event["server"],
channel_name=event["channel"].name)
@utils.hook("timer.kick-rejoin")
def timer(self, event):
event["server"].send_join(event["channel_name"])
self._rejoin(event["server"], event["channel_name"])
def _rejoin(self, server, channel_name):
server.send_join(channel_name)