This commit is contained in:
= 2025-04-04 04:58:05 +00:00
parent c478220bc2
commit 7d45d39e35

14
bot.py

@ -97,8 +97,7 @@ class IRCBot():
try:
this_time = self.config["times"][channel]
except KeyError:
this_time = time()
self.config["times"][channel] = this_time
this_time = self.config["times"][channel] = time()
self.write_config()
return this_time
@ -113,6 +112,10 @@ class IRCBot():
value = self.config["counts"][channel] = 1
self.write_config()
return value
def reset_count(self, channel):
self.config["counts"][channel] = 0
self.write_config()
def command_loop(self):
while True:
@ -164,11 +167,10 @@ class IRCBot():
channel_time = self.check_time(channel)
now = time()
count = self.counter(channel)
if now - channel_time > timeout and count < messages_within_timeout:
self.config["counts"][channel] = 0
self.write_config()
delta = now - channel_time
if delta > timeout and count < messages_within_timeout:
self.reset_count(channel)
self.send("#bots", f"i hear activity in {channel}...")
# self.send("#tildetown", f"i hear activity in {channel}...")
self.set_time(channel, now)
if __name__ == "__main__":