diff --git a/modules/kick-rejoin.py b/modules/kick-rejoin.py index 7544ba9f..4e9d48af 100644 --- a/modules/kick-rejoin.py +++ b/modules/kick-rejoin.py @@ -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"])