diff --git a/sopel_modules/SpiceBot/Users.py b/sopel_modules/SpiceBot/Users.py index b51e900..560596f 100644 --- a/sopel_modules/SpiceBot/Users.py +++ b/sopel_modules/SpiceBot/Users.py @@ -20,18 +20,17 @@ class BotUsers(): def __init__(self): self.lock = threading.Lock() + # TODO AWAY self.dict = { "all": botdb.get_bot_value('users') or {}, "online": [], "offline": [], - "away": [], # TODO + "away": [], "current": {}, } """during setup, all users from database are offline until marked online""" for user_id in list(self.dict["all"].keys()): - self.lock.acquire() - self.dict["offline"].append(int(user_id)) - self.lock.release() + self.mark_user_offline(user_id) def __getattr__(self, name): ''' will only get called for undefined attributes ''' @@ -42,20 +41,20 @@ class BotUsers(): raise Exception('User dict does not contain a function or key ' + str(name.lower())) def ID(self, nickinput): - self.lock.acquire() if is_number(nickinput): nick_id = nickinput - if nick_id in list(self.dict["current"].keys()): - nick = self.dict["current"][nick_id]["nick"] - elif nick_id in list(self.dict["all"].keys()) and len(self.dict["all"][int(nick_id)]): + self.lock.acquire() + if int(nick_id) in list(self.dict["current"].keys()): + nick = self.dict["current"][int(nick_id)]["nick"] + self.lock.release() + elif int(nick_id) in list(self.dict["all"].keys()) and len(self.dict["all"][int(nick_id)]): nick = self.dict["all"][int(nick_id)][0] + self.lock.release() else: raise Exception('ID ' + str(nickinput) + ' does not appear to be associated with a nick') - self.lock.release() return nick else: nick_id = self.whois_ident(nickinput) - self.lock.release() return int(nick_id) def whois_ident(self, nick, usercreate=True): @@ -65,7 +64,7 @@ class BotUsers(): except Exception as e: nick_id = e nick_id = None - if usercreate: + if usercreate and nick_id: self.add_to_all(nick, nick_id) return int(nick_id) diff --git a/sopel_modules/SpiceBot_Core_Processing/Channels.py b/sopel_modules/SpiceBot_Core_Processing/Channels.py index a5358aa..92b4a66 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Channels.py +++ b/sopel_modules/SpiceBot_Core_Processing/Channels.py @@ -140,7 +140,6 @@ def bot_channelscan(bot, trigger): SpiceBot.channels.channel_scan(bot) -""" @sopel.module.event(SpiceBot.events.RPL_NAMREPLY) @sopel.module.rule('(.*)') def handle_names(bot, trigger): @@ -153,4 +152,3 @@ def handle_names(bot, trigger): @sopel.module.unblockable def recv_who(bot, trigger): SpiceBot.channels.rpl_who(bot, trigger) -""" diff --git a/sopel_modules/SpiceBot_Core_Processing/Users.py b/sopel_modules/SpiceBot_Core_Processing/Users.py index d7243ad..d97fa11 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Users.py +++ b/sopel_modules/SpiceBot_Core_Processing/Users.py @@ -51,7 +51,6 @@ def bot_channelscan_users(bot, trigger): SpiceBot.users.channel_scan(bot) -""" @sopel.module.rule('.*') def bot_users_chat(bot, trigger): SpiceBot.users.chat(bot, trigger) @@ -81,4 +80,3 @@ def account_notify(bot, trigger): @sopel.module.rule('.*') def track_notify(bot, trigger): SpiceBot.users.track_notify(bot, trigger) -"""