diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index cbe46ab..28d9033 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -97,20 +97,20 @@ class BotChannels(): else: bot.part(channel) - def whois(self, nick): + def whois_id(self, nick): nick = Identifier(nick) nick_id = botdb.db.get_nick_id(nick, create=True) return nick_id def add_to_channel(self, channel, nick, nick_id=None): if not nick_id: - nick_id = self.whois(nick) + nick_id = self.whois_id(nick) if nick_id not in self.dict['list'][channel.lower()]['users']: self.dict['list'][channel.lower()]['users'].append(nick_id) def remove_from_channel(self, channel, nick, nick_id=None): if not nick_id: - nick_id = self.whois(nick) + nick_id = self.whois_id(nick) if nick_id in self.dict['list'][channel.lower()]['users']: self.dict['list'][channel.lower()]['users'].remove(nick_id) @@ -124,7 +124,7 @@ class BotChannels(): self.add_to_channel(self, trigger.sender, user) return # Identify - nick_id = self.whois(trigger.nick) + nick_id = self.whois_id(trigger.nick) # Verify nick is in the channel list self.add_to_channel(self, trigger.sender, trigger.nick, nick_id) @@ -134,7 +134,7 @@ class BotChannels(): self.remove_all_from_channel(trigger.sender) return # Identify - nick_id = self.whois(trigger.nick) + nick_id = self.whois_id(trigger.nick) # Verify nick is not in the channel list self.remove_from_channel(self, trigger.sender, trigger.nick, nick_id) @@ -144,7 +144,7 @@ class BotChannels(): self.remove_all_from_channel(trigger.sender) return # Identify - nick_id = self.whois(trigger.nick) + nick_id = self.whois_id(trigger.nick) # Verify nick is not in the channel list self.remove_from_channel(self, trigger.sender, trigger.nick, nick_id) @@ -155,7 +155,7 @@ class BotChannels(): self.remove_all_from_channel(trigger.sender) return # Identify - nick_id = self.whois(targetnick) + nick_id = self.whois_id(targetnick) # Verify nick is not in the channel list self.remove_from_channel(self, trigger.sender, targetnick, nick_id) @@ -168,7 +168,7 @@ class BotChannels(): if not botdb.check_nick_id(newnick): botdb.alias_nick(trigger.nick, newnick) # Identify - nick_id = self.whois(newnick) + nick_id = self.whois_id(newnick) # Verify nick is in the channel list self.add_to_channel(self, trigger.sender, trigger.nick, nick_id) diff --git a/sopel_modules/SpiceBot/Users.py b/sopel_modules/SpiceBot/Users.py index c85bb15..f44ea23 100644 --- a/sopel_modules/SpiceBot/Users.py +++ b/sopel_modules/SpiceBot/Users.py @@ -19,6 +19,12 @@ class BotUsers(): self.current = {} def whois(self, nick): + nick_id = self.whois_id(nick) + self.add_to_all(nick, nick_id) + self.add_to_current(nick, nick_id) + return self.current[nick_id]["nick"] + + def whois_id(self, nick): nick = Identifier(nick) nick_id = botdb.db.get_nick_id(nick, create=True) return nick_id @@ -28,7 +34,7 @@ class BotUsers(): def add_to_all(self, nick, nick_id=None): if not nick_id: - nick_id = self.whois(nick) + nick_id = self.whois_id(nick) # add to all if not there if nick_id not in self.all.keys(): self.all[nick_id] = [] @@ -39,7 +45,7 @@ class BotUsers(): def add_to_current(self, nick, nick_id=None): if not nick_id: - nick_id = self.whois(nick) + nick_id = self.whois_id(nick) # add to current if not there if nick_id not in self.current.keys(): self.current[nick_id] = {"channels": [], "nick": nick} @@ -49,7 +55,7 @@ class BotUsers(): if trigger.nick == bot.nick: for user in bot.channels[trigger.sender].privileges.keys(): # Identify - nick_id = self.whois(user) + nick_id = self.whois_id(user) # Verify nick is in the all list self.add_to_all(user, nick_id) # Verify nick is in the all list @@ -66,7 +72,7 @@ class BotUsers(): self.offline.remove(nick_id) return # Identify - nick_id = self.whois(trigger.nick) + nick_id = self.whois_id(trigger.nick) # Verify nick is in the all list self.add_to_all(trigger.nick, nick_id) # Verify nick is in the all list @@ -87,7 +93,7 @@ class BotUsers(): if trigger.nick == bot.nick: return # Identify - nick_id = self.whois(trigger.nick) + nick_id = self.whois_id(trigger.nick) # Verify nick is in the all list self.add_to_all(trigger.nick, nick_id) # Verify nick is in the all list @@ -115,7 +121,7 @@ class BotUsers(): self.offline.append(nick_id) return # Identify - nick_id = self.whois(trigger.nick) + nick_id = self.whois_id(trigger.nick) # Verify nick is in the all list self.add_to_all(trigger.nick, nick_id) # Verify nick is in the all list @@ -143,7 +149,7 @@ class BotUsers(): self.offline.append(nick_id) return # Identify - nick_id = self.whois(targetnick) + nick_id = self.whois_id(targetnick) # Verify nick is in the all list self.add_to_all(targetnick, nick_id) # Verify nick is in the all list @@ -166,7 +172,7 @@ class BotUsers(): if not botdb.check_nick_id(newnick): botdb.alias_nick(trigger.nick, newnick) # Identify - nick_id = self.whois(newnick) + nick_id = self.whois_id(newnick) # Verify nick is in the all list self.add_to_all(newnick, nick_id) # Verify nick is in the all list