From 6cdadd23a02fc5132094065e4108fb9de7316024 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 14 Aug 2022 20:58:41 +0100 Subject: [PATCH] Implement initial WHO loop delay --- conf/templates/config.json | 1 + core/bot.py | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/conf/templates/config.json b/conf/templates/config.json index 9ea4fa5..1a47ad9 100644 --- a/conf/templates/config.json +++ b/conf/templates/config.json @@ -57,6 +57,7 @@ "Prefix": "*" }, "Delays": { + "WhoDelay": 3600, "WhoLoop": 600, "WhoRange": 1800, "Timeout": 30, diff --git a/core/bot.py b/core/bot.py index 5bff113..91b02fd 100644 --- a/core/bot.py +++ b/core/bot.py @@ -690,17 +690,27 @@ class IRCBot(IRCClient): if not self.authenticated: reactor.callLater(10, self.regPing) + def setup_who_loop(self, channel): + # if main.config["Toggles"]["Who"]: + lc = LoopingCall(self.who, channel) + self._getWho[channel] = lc + intrange = main.config["Tweaks"]["Delays"]["WhoRange"] + minint = main.config["Tweaks"]["Delays"]["WhoLoop"] + interval = randint(minint, minint + intrange) + lc.start(interval) + def joined(self, channel): if channel not in self.channels: self.channels.append(channel) self.names(channel).addCallback(self.got_names) if main.config["Toggles"]["Who"]: - lc = LoopingCall(self.who, channel) - self._getWho[channel] = lc - intrange = main.config["Tweaks"]["Delays"]["WhoRange"] - minint = main.config["Tweaks"]["Delays"]["WhoLoop"] - interval = randint(minint, minint + intrange) - lc.start(interval) + reactor.callLater(main.config["Tweaks"]["Delays"]["WhoDelay"], self.setup_who_loop, channel) + # lc = LoopingCall(self.who, channel) + # self._getWho[channel] = lc + # intrange = main.config["Tweaks"]["Delays"]["WhoRange"] + # minint = main.config["Tweaks"]["Delays"]["WhoLoop"] + # interval = randint(minint, minint + intrange) + # lc.start(interval) def botLeft(self, channel): if channel in self.channels: