From 6ab8169d76f9c1e8b4724bd20e0ff6a4c9bd0725 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 17 Sep 2019 20:06:12 -0400 Subject: [PATCH] 4 minute whois timeout --- sopel_modules/SpiceBot/Users.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sopel_modules/SpiceBot/Users.py b/sopel_modules/SpiceBot/Users.py index 545c807..0fc51ea 100644 --- a/sopel_modules/SpiceBot/Users.py +++ b/sopel_modules/SpiceBot/Users.py @@ -12,6 +12,7 @@ from sopel_modules.spicemanip import spicemanip import threading import re +import time # TODO timestamp for new .seen @@ -29,6 +30,7 @@ class BotUsers(): "away": [], "current": {}, "registered": botdb.get_bot_value('regged_users') or [], + "notregistered": {}, } """during setup, all users from database are offline until marked online""" for user_id in list(self.dict["all"].keys()): @@ -354,11 +356,17 @@ class BotUsers(): self.lock.acquire() if str(nick).lower() not in [x.lower() for x in self.dict["registered"]]: self.dict["registered"].append(str(nick)) + else: + self.dict["notregistered"][str(nick).lower()] = time.time() self.lock.release() def whois_send(self, bot, nick): if not bot.config.SpiceBot_regnick.regnick: return + if str(nick).lower() in [x.lower() for x in list(self.dict["notregistered"].keys())]: + timestamp = self.dict["notregistered"][str(nick).lower()] + if time.time() - timestamp < 240: + return if str(nick).lower() not in [x.lower() for x in self.dict["registered"]]: bot.write(['WHOIS', str(nick)])