add configurable kick-rejoin delay (default 5s)

This commit is contained in:
jesopo 2019-07-11 21:34:16 +01:00
parent fa429a4c28
commit baa13d9e7f

View file

@ -2,10 +2,20 @@
from src import ModuleManager, utils
DELAY = 5
@utils.export("serverset", utils.BoolSetting("kick-rejoin",
"Whether or not I should rejoin channels I get kicked from"))
@utils.export("serverset", utils.IntSetting("kick-rejoin-delay",
"Amount of seconds to wait before rejoining a channel"))
class Module(ModuleManager.BaseModule):
@utils.hook("self.kick")
def on_kick(self, event):
if event["server"].get_setting("kick-rejoin", False):
event["server"].send_join(event["channel"].name)
delay = event["server"].get_setting("kick-rejoin-delay", DELAY)
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"])