Implement initial WHO loop delay

This commit is contained in:
Mark Veidemanis 2022-08-14 20:58:41 +01:00
parent 4fa5c25e94
commit 6cdadd23a0
2 changed files with 17 additions and 6 deletions

View File

@ -57,6 +57,7 @@
"Prefix": "*" "Prefix": "*"
}, },
"Delays": { "Delays": {
"WhoDelay": 3600,
"WhoLoop": 600, "WhoLoop": 600,
"WhoRange": 1800, "WhoRange": 1800,
"Timeout": 30, "Timeout": 30,

View File

@ -690,11 +690,8 @@ class IRCBot(IRCClient):
if not self.authenticated: if not self.authenticated:
reactor.callLater(10, self.regPing) reactor.callLater(10, self.regPing)
def joined(self, channel): def setup_who_loop(self, channel):
if channel not in self.channels: # if main.config["Toggles"]["Who"]:
self.channels.append(channel)
self.names(channel).addCallback(self.got_names)
if main.config["Toggles"]["Who"]:
lc = LoopingCall(self.who, channel) lc = LoopingCall(self.who, channel)
self._getWho[channel] = lc self._getWho[channel] = lc
intrange = main.config["Tweaks"]["Delays"]["WhoRange"] intrange = main.config["Tweaks"]["Delays"]["WhoRange"]
@ -702,6 +699,19 @@ class IRCBot(IRCClient):
interval = randint(minint, minint + intrange) interval = randint(minint, minint + intrange)
lc.start(interval) 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"]:
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): def botLeft(self, channel):
if channel in self.channels: if channel in self.channels:
self.channels.remove(channel) self.channels.remove(channel)