diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 315d148..220c681 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -78,7 +78,7 @@ class SpiceBot_AI(): # current_bot_db = botdb.get_bot_value('botai') or None # if current_bot_db: - # for predicate in current_bot_db.keys(): + # for predicate in list(current_bot_db.keys()): # predval = current_bot_db[predicate] # self.aiml_kernel.setBotPredicate(predicate, predval) @@ -141,7 +141,7 @@ class SpiceBot_AI(): # punctuation puct_dict = {"!": "exclamationmark", ".": "period", "?": "questionmark", ",": "comma"} - for puctuation in puct_dict.keys(): + for puctuation in list(puct_dict.keys()): message = message.replace(puctuation, puct_dict[puctuation]) # bot items @@ -200,12 +200,12 @@ class SpiceBot_AI(): "self": "themselves", }, } - for pronounitem in pronounsdict[botgendertype].keys(): + for pronounitem in list(pronounsdict[botgendertype].keys()): aiml_response = aiml_response.replace("BOTPRONOUN" + pronounitem, pronounsdict[botgendertype][pronounitem]) triggergendertype = self.getPredicate("gender", trigger.nick) if not triggergendertype or triggergendertype == "": triggergendertype = "point" - for pronounitem in pronounsdict[triggergendertype].keys(): + for pronounitem in list(pronounsdict[triggergendertype].keys()): aiml_response = aiml_response.replace("TRIGGERPRONOUN" + pronounitem, pronounsdict[triggergendertype][pronounitem]) aiml_response = "\x0315" + aiml_response + "\x03" @@ -222,14 +222,14 @@ class SpiceBot_AI(): if not nick_id: nick = Identifier(nick) nick_id = botdb.get_nick_id(nick, create=True) - if nick_id not in self.dict["sessioncache"].keys(): + if nick_id not in list(self.dict["sessioncache"].keys()): self.dict["sessioncache"][nick_id] = botdb.get_nick_value(nick, 'botai') or {} - for predicate in self.dict["sessioncache"][nick_id].keys(): + for predicate in list(self.dict["sessioncache"][nick_id].keys()): predval = self.dict["sessioncache"][nick_id][predicate] self.aiml_kernel.setPredicate(predicate, predval, nick_id) # defaults - if "nick" not in self.dict["sessioncache"][nick_id].keys(): + if "nick" not in list(self.dict["sessioncache"][nick_id].keys()): self.dict["sessioncache"][nick_id]["nick"] = nick self.aiml_kernel.setPredicate("nick", nick, nick_id) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index 74366aa..7692181 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -45,7 +45,7 @@ class BotChannels(): def channel_list_recieve_input(self, trigger): self.lock.acquire() channel, _, topic = trigger.args[1:] - if channel.lower() not in self.dict['list'].keys(): + if channel.lower() not in list(self.dict['list'].keys()): self.dict['list'][channel.lower()] = dict() self.dict['list'][channel.lower()]['name'] = channel self.dict['list'][channel.lower()]['topic'] = self.topic_compile(topic) @@ -69,8 +69,8 @@ class BotChannels(): ignorepartlist = [] if bot.config.core.logging_channel: ignorepartlist.append(bot.config.core.logging_channel) - for channel in bot.channels.keys(): - if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist and channel.startswith("#"): + for channel in list(bot.channels.keys()): + if len(list(bot.channels[channel].privileges.keys())) == 1 and channel not in ignorepartlist and channel.startswith("#"): bot.part(channel, "Leaving Empty Channel") if channel.lower() in self.dict['list']: self.lock.acquire() @@ -79,16 +79,16 @@ class BotChannels(): def join_all_channels(self, bot): if botconfig.SpiceBot_Channels.joinall: - for channel in self.dict['list'].keys(): + for channel in list(self.dict['list'].keys()): if channel.startswith("#"): - if channel not in bot.channels.keys() and channel not in botconfig.SpiceBot_Channels.chanignore: + if channel not in list(bot.channels.keys()) and channel not in botconfig.SpiceBot_Channels.chanignore: bot.write(('JOIN', bot.nick, self.dict['list'][channel]['name'])) - if channel not in bot.channels.keys() and botconfig.SpiceBot_Channels.operadmin: + if channel not in list(bot.channels.keys()) and botconfig.SpiceBot_Channels.operadmin: bot.write(('SAJOIN', bot.nick, self.dict['list'][channel]['name'])) def chanadmin_all_channels(self, bot): # Chan ADMIN +a - for channel in bot.channels.keys(): + for channel in list(bot.channels.keys()): if channel.startswith("#"): if channel not in botconfig.SpiceBot_Channels.chanignore: if botconfig.SpiceBot_Channels.operadmin: @@ -105,7 +105,7 @@ class BotChannels(): def add_to_channel(self, channel, nick, nick_id=None): if not nick_id: nick_id = self.whois_ident(nick) - if channel.lower() not in self.dict['list'].keys(): + if channel.lower() not in list(self.dict['list'].keys()): self.dict['list'][channel.lower()] = dict() if 'users' not in self.dict['list'][channel.lower()]: self.dict['list'][channel.lower()]['users'] = [] @@ -115,7 +115,7 @@ class BotChannels(): def remove_from_channel(self, channel, nick, nick_id=None): if not nick_id: nick_id = self.whois_ident(nick) - if channel.lower() not in self.dict['list'].keys(): + if channel.lower() not in list(self.dict['list'].keys()): self.dict['list'][channel.lower()] = dict() if 'users' not in self.dict['list'][channel.lower()]: self.dict['list'][channel.lower()]['users'] = [] @@ -123,21 +123,21 @@ class BotChannels(): self.dict['list'][channel.lower()]['users'].remove(nick_id) def remove_all_from_channel(self, channel): - if channel.lower() not in self.dict['list'].keys(): + if channel.lower() not in list(self.dict['list'].keys()): self.dict['list'][channel.lower()] = dict() if 'users' not in self.dict['list'][channel.lower()]: self.dict['list'][channel.lower()]['users'] = [] self.dict['list'][channel.lower()]['users'] = [] def channel_scan(self, bot): - for channel in bot.channels.keys(): - for user in bot.channels[channel].privileges.keys(): + for channel in list(bot.channels.keys()): + for user in list(bot.channels[channel].privileges.keys()): self.add_to_channel(channel, user) def join(self, bot, trigger): # bot block if trigger.nick == bot.nick: - for user in bot.channels[trigger.sender].privileges.keys(): + for user in list(bot.channels[trigger.sender].privileges.keys()): self.add_to_channel(trigger.sender, user) return # Identify diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index e495b21..b351d11 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -42,7 +42,7 @@ class BotCommands(): self.module_files_parse() self.nickrules() for comtype in ['module', 'nickname', 'rule']: - logs.log('SpiceBot_Commands', "Found " + str(len(self.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) + logs.log('SpiceBot_Commands', "Found " + str(len(list(self.dict['commands'][comtype].keys()))) + " " + comtype + " commands.", True) def setup_commands(self): botconfig.define_section("SpiceBot_Commands", SpiceBot_Commands_MainSection, validate=False) @@ -50,16 +50,16 @@ class BotCommands(): botconfig.core.prefix_list.extend(botconfig.SpiceBot_Commands.query_prefix) def nickrules(self): - for command in self.dict['commands']['rule'].keys(): + for command in list(self.dict['commands']['rule'].keys()): if command.startswith("$nickname"): command = command.split("$nickname")[-1] if command not in self.dict['nickrules']: self.dict['nickrules'].append(command) def find_command_type(self, command): - for commandstype in self.dict['commands'].keys(): + for commandstype in list(self.dict['commands'].keys()): if commandstype not in ['rule']: - for com in self.dict['commands'][commandstype].keys(): + for com in list(self.dict['commands'][commandstype].keys()): if com.lower() == command.lower(): return commandstype return None @@ -70,7 +70,7 @@ class BotCommands(): return self.dict['disabled'] def check_commands_disabled(self, command, channel): - if command in self.get_commands_disabled(channel).keys(): + if command in list(self.get_commands_disabled(channel).keys()): return True else: return False @@ -78,10 +78,10 @@ class BotCommands(): def get_realcom(self, command, trigger_command_type): realcom = command - if trigger_command_type not in self.dict['commands'].keys(): + if trigger_command_type not in list(self.dict['commands'].keys()): return realcom - if command not in self.dict['commands'][trigger_command_type].keys(): + if command not in list(self.dict['commands'][trigger_command_type].keys()): return realcom if "aliasfor" in self.dict['commands'][trigger_command_type][command].keys(): @@ -98,7 +98,7 @@ class BotCommands(): def unset_command_disabled(self, command, channel): if not len(list(self.dict['disabled'])): self.dict['disabled'] = botdb.get_channel_value(channel, 'commands_disabled') or {} - if command in self.dict['disabled'].keys(): + if command in list(self.dict['disabled'].keys()): del self.dict['disabled'][command] botdb.set_channel_value(channel, 'commands_disabled', self.dict['disabled']) @@ -112,13 +112,13 @@ class BotCommands(): if not isinstance(validcoms, list): validcoms = [validcoms] - if command_type not in self.dict['commands'].keys(): + if command_type not in list(self.dict['commands'].keys()): self.dict['commands'][command_type] = dict() dict_from_file = dict() # default command to filename - if "validcoms" not in dict_from_file.keys(): + if "validcoms" not in list(dict_from_file.keys()): dict_from_file["validcoms"] = validcoms maincom = dict_from_file["validcoms"][0] @@ -129,7 +129,7 @@ class BotCommands(): self.dict['commands'][command_type][maincom] = dict_from_file for comalias in comaliases: - if comalias not in self.dict['commands'][command_type].keys(): + if comalias not in list(self.dict['commands'][command_type].keys()): self.dict['commands'][command_type][comalias] = {"aliasfor": maincom} self.lock.release() diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index b7f9bb5..8e8fd97 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -28,10 +28,10 @@ class BotConfig(): config = configparser.ConfigParser() config.read(self.config.filename) for each_section in config.sections(): - if each_section.lower() not in self.dict.keys(): + if each_section.lower() not in list(self.dict.keys()): self.dict[each_section.lower()] = dict() for (each_key, each_val) in config.items(each_section): - if each_key.lower() not in self.dict[each_section.lower()].keys(): + if each_key.lower() not in list(self.dict[each_section.lower()].keys()): self.dict[each_section.lower()][each_key.lower()] = each_val def setup_config(self): @@ -46,7 +46,7 @@ class BotConfig(): """We will try to find a core value, or return None""" if hasattr(self.config.core, name): return eval("self.config.core." + name) - elif name.lower() in self.dict["core"].keys(): + elif name.lower() in list(self.dict["core"].keys()): return self.dict["core"][str(name).lower()] elif hasattr(self.config, name): return eval("self.config." + name) diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index a716277..cc72902 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -95,7 +95,7 @@ class BotEvents(object): if not isinstance(checklist, list): checklist = [str(checklist)] for number in checklist: - if str(number) not in self.dict["triggers_recieved"].keys(): + if str(number) not in list(self.dict["triggers_recieved"].keys()): return False return True @@ -110,14 +110,14 @@ class BotEvents(object): def startup_check(self): for number in self.dict["startup_required"]: - if str(number) not in self.dict["triggers_recieved"].keys(): + if str(number) not in list(self.dict["triggers_recieved"].keys()): return False return True def startup_debug(self): not_done = [] for number in self.dict["startup_required"]: - if str(number) not in self.dict["triggers_recieved"].keys(): + if str(number) not in list(self.dict["triggers_recieved"].keys()): not_done.append(int(number)) reference_not_done = [] for item in not_done: diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index 1226d98..45225b7 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -50,7 +50,7 @@ class BotLogs(): if stdio: self.botstderr(logmessage) - if logtype not in self.dict["list"].keys(): + if logtype not in list(self.dict["list"].keys()): self.dict["list"][logtype] = [] self.dict["list"][logtype].append(logentry) @@ -68,7 +68,7 @@ class BotLogs(): def stdio_logs_fetch(self): stdio_ignore = [] - for logtype in self.dict["list"].keys(): + for logtype in list(self.dict["list"].keys()): stdio_ignore.append("[" + logtype + "]") try: diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 9093560..72b9a44 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -109,7 +109,7 @@ class BotPrerun(): if not trigger.is_privmsg: commandused = trigger.sb["realcom"] disabled_list = botdb.get_channel_value(trigger.sender, 'commands_disabled') or {} - if commandused in disabled_list.keys(): + if commandused in list(disabled_list.keys()): reason = disabled_list[trigger.sb["realcom"]]["reason"] timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"] diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 1412801..7942a60 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -242,7 +242,7 @@ def letters_in_string(text): def channel_privs(bot, channel, privtype): privlist = [] - for user in bot.channels[channel].privileges.keys(): + for user in list(bot.channels[channel].privileges.keys()): try: privnum = bot.channels[channel].privileges[user] or 0 except KeyError: diff --git a/sopel_modules/SpiceBot/Users.py b/sopel_modules/SpiceBot/Users.py index 18e8a54..95c2f03 100644 --- a/sopel_modules/SpiceBot/Users.py +++ b/sopel_modules/SpiceBot/Users.py @@ -14,7 +14,7 @@ class BotUsers(): self.all = botdb.get_bot_value('users') or dict() self.online = [] self.offline = [] - for user_id in self.all.keys(): + for user_id in list(self.all.keys()): self.offline.append(int(user_id)) self.current = {} @@ -25,9 +25,9 @@ class BotUsers(): return self.current[nick_id]["nick"] def whois_id(self, nick_id): - if nick_id in self.current.keys(): + if nick_id in list(self.current.keys()): return self.current[nick_id]["nick"] - elif nick_id in self.all.keys() and len(self.all[nick_id]): + elif nick_id in list(self.all.keys()) and len(self.all[nick_id]): return self.all[nick_id][0] else: return None @@ -50,7 +50,7 @@ class BotUsers(): if not nick_id: nick_id = self.whois_ident(nick) # add to all if not there - if nick_id not in self.all.keys(): + if nick_id not in list(self.all.keys()): self.all[nick_id] = [] # add nick alias if nick not in self.all[nick_id]: @@ -61,12 +61,12 @@ class BotUsers(): if not nick_id: nick_id = self.whois_ident(nick) # add to current if not there - if nick_id not in self.current.keys(): + if nick_id not in list(self.current.keys()): self.current[nick_id] = {"channels": [], "nick": nick} def channel_scan(self, bot): - for channel in bot.channels.keys(): - for user in bot.channels[channel].privileges.keys(): + for channel in list(bot.channels.keys()): + for user in list(bot.channels[channel].privileges.keys()): # Identify nick_id = self.whois_ident(user) # Verify nick is in the all list @@ -86,7 +86,7 @@ class BotUsers(): def join(self, bot, trigger): if trigger.nick == bot.nick: - for user in bot.channels[trigger.sender].privileges.keys(): + for user in list(bot.channels[trigger.sender].privileges.keys()): # Identify nick_id = self.whois_ident(user) # Verify nick is in the all list @@ -142,7 +142,7 @@ class BotUsers(): def part(self, bot, trigger): if trigger.nick == bot.nick: - for nick_id in self.current.keys(): + for nick_id in list(self.current.keys()): if trigger.sender in self.current[nick_id]["channels"]: self.current[nick_id]["channels"].remove(trigger.sender) # mark offline @@ -169,7 +169,7 @@ class BotUsers(): def kick(self, bot, trigger): targetnick = Identifier(str(trigger.args[1])) if targetnick == bot.nick: - for nick_id in self.current.keys(): + for nick_id in list(self.current.keys()): if trigger.sender in self.current[nick_id]["channels"]: self.current[nick_id]["channels"].remove(trigger.sender) # mark offline diff --git a/sopel_modules/SpiceBot/osd.py b/sopel_modules/SpiceBot/osd.py index 99eb137..a0ce15a 100644 --- a/sopel_modules/SpiceBot/osd.py +++ b/sopel_modules/SpiceBot/osd.py @@ -46,7 +46,7 @@ class ToolsOSD: * unicode string * a comma-seperated unicode string * list - * dict_keys handy for bot.channels.keys() + * dict_keys handy for list(bot.channels.keys()) """ if sys.version_info.major >= 3: diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index cd66c8c..7423465 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -20,7 +20,7 @@ def bot_command_nick(bot, trigger): if trigger.sb['com'][0] == "?": return - if trigger.sb['com'] in SpiceBot.commands.dict['commands']["nickname"].keys(): + if trigger.sb['com'] in list(SpiceBot.commands.dict['commands']["nickname"].keys()): return trigger.sb['args'].insert(0, trigger.sb['com']) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 94cfc35..9f99446 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -32,9 +32,9 @@ def bot_command_rule(bot, trigger): if trigger_command.startswith("."): return commands_list = [] - for commandstype in SpiceBot.commands.dict['commands'].keys(): + for commandstype in list(SpiceBot.commands.dict['commands'].keys()): if commandstype not in ['rule', 'nickname']: - for com in SpiceBot.commands.dict['commands'][commandstype].keys(): + for com in list(SpiceBot.commands.dict['commands'][commandstype].keys()): if com not in commands_list: commands_list.append(com) if trigger_command not in commands_list: @@ -55,7 +55,7 @@ def bot_command_rule(bot, trigger): return if fulltrigger in SpiceBot.commands.dict['nickrules']: return - if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys(): + if trigger_command in list(SpiceBot.commands.dict['commands']["nickname"].keys()): return else: command_type = 'other' @@ -90,22 +90,22 @@ def bot_command_rule(bot, trigger): realtarget = SpiceBot.inlist_match(target, bot.users) dispmsg = [trigger.nick + ", yes. I can see " + realtarget] targetchannels = [] - for channel in bot.channels.keys(): - if SpiceBot.inlist(trigger.nick, bot.channels[channel].privileges.keys()): + for channel in list(bot.channels.keys()): + if SpiceBot.inlist(trigger.nick, list(bot.channels[channel].privileges.keys())): targetchannels.append(channel) dispmsg.append(realtarget + " is in " + spicemanip.main(targetchannels, 'andlist')) bot.osd(dispmsg) else: bot.osd(trigger.nick + ", no. I cannot see " + target + " right now!") - # if bot_check_inlist(target, bot.memory["botdict"]["users"].keys()): + # if bot_check_inlist(target, list(bot.memory["botdict"]["users"].keys())): # bot.osd(trigger.nick + ", I can't see " + inlist_match(target, bot.users) + " at the moment.") # else: # bot.osd("I have never seen " + str(target) + ".") - # user in bot.channels[channel].privileges.keys() + # user in list(bot.channels[channel].privileges.keys()) # TODO return - closestmatches = SpiceBot.similar_list(trigger_command, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse') + closestmatches = SpiceBot.similar_list(trigger_command, list(SpiceBot.commands.dict['commands']["nickname"].keys()), 3, 'reverse') if len(closestmatches): closestmatches = spicemanip.main(closestmatches, "andlist") bot.osd("I don't know what you are asking me to do! Did you mean: " + str(closestmatches) + "?") diff --git a/sopel_modules/SpiceBot_Core_Commands/Channels.py b/sopel_modules/SpiceBot_Core_Commands/Channels.py index d8c863b..dea730f 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Channels.py +++ b/sopel_modules/SpiceBot_Core_Commands/Channels.py @@ -23,13 +23,13 @@ def nickname_comand_channels(bot, trigger): trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') if commandused == 'list': - chanlist = spicemanip.main(bot.channels.keys(), 'andlist') + chanlist = spicemanip.main(list(bot.channels.keys()), 'andlist') bot.osd("You can find me in " + chanlist) return elif commandused == 'total': - botcount = len(bot.channels.keys()) - servercount = len(SpiceBot.channels.dict['list'].keys()) + botcount = len(list(bot.channels.keys())) + servercount = len(list(SpiceBot.channels.dict['list'].keys())) bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") return @@ -54,7 +54,7 @@ def nickname_comand_channels(bot, trigger): while SpiceBot.channels.channel_lock: pass SpiceBot.channels.join_all_channels(bot) - foundchannelcount = len(SpiceBot.channels.dict['list'].keys()) + foundchannelcount = len(list(SpiceBot.channels.dict['list'].keys())) bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.") SpiceBot.channels.bot_part_empty(bot) return @@ -64,7 +64,7 @@ def nickname_comand_channels(bot, trigger): bot.osd("Channel name input missing.") return channel = spicemanip.main(trigger.sb['args'], 1) - if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()): + if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())): bot.osd("Channel name {} not valid.".format(channel)) return topic = SpiceBot.channels.dict['list'][channel.lower()]['topic'] @@ -81,10 +81,10 @@ def nickname_comand_channels(bot, trigger): channel = trigger.sender else: channel = spicemanip.main(trigger.sb['args'], 1) - if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()): + if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())): bot.osd("Channel name {} not valid.".format(channel)) return - if not SpiceBot.inlist(channel.lower(), bot.channels.keys()): + if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())): bot.osd("I need to be in {} to see nick privileges.".format(channel)) return @@ -101,17 +101,17 @@ def nickname_comand_channels(bot, trigger): # Users List if commandused == 'users': channel = spicemanip.main(trigger.sb['args'], 1) - if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()): + if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())): bot.osd("Channel name {} not valid.".format(channel)) return - if not SpiceBot.inlist(channel.lower(), bot.channels.keys()): + if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())): bot.osd("I need to be in {} to see user list.".format(channel)) return dispmsg = [] - if not len(bot.channels[channel].privileges.keys()): + if not len(list(bot.channels[channel].privileges.keys())): dispmsg.append("There are no Channel users for " + str(channel)) else: - userslist = spicemanip.main(bot.channels[channel].privileges.keys(), 'andlist') + userslist = spicemanip.main(list(bot.channels[channel].privileges.keys()), 'andlist') dispmsg.append("Channel users for " + str(channel) + " are: " + userslist) bot.osd(dispmsg, trigger.nick, 'notice') return diff --git a/sopel_modules/SpiceBot_Core_Commands/Commands.py b/sopel_modules/SpiceBot_Core_Commands/Commands.py index 994888e..3353ea1 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Commands.py +++ b/sopel_modules/SpiceBot_Core_Commands/Commands.py @@ -23,9 +23,9 @@ def nickname_comand_commands(bot, trigger): commandused = spicemanip.main(trigger.sb['args'], 1).lower() commands_list = [] - for commandstype in SpiceBot.commands.dict['commands'].keys(): + for commandstype in list(SpiceBot.commands.dict['commands'].keys()): if commandstype not in ['rule']: - for com in SpiceBot.commands.dict['commands'][commandstype].keys(): + for com in list(SpiceBot.commands.dict['commands'][commandstype].keys()): if com not in commands_list: if commandstype in ['nickname']: commands_list.append(bot.nick + " " + com) diff --git a/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py b/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py index 461c62a..f06ce70 100644 --- a/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py +++ b/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py @@ -29,8 +29,8 @@ def query_detection_nick(bot, trigger): return commands_list = dict() - for com in SpiceBot.commands.dict['commands']['nickname'].keys(): - if com not in commands_list.keys(): + for com in list(SpiceBot.commands.dict['commands']['nickname'].keys()): + if com not in list(commands_list.keys()): commands_list[com] = SpiceBot.commands.dict['commands']['nickname'][com] if trigger.sb['com'].endswith("+"): @@ -48,7 +48,7 @@ def query_detection_nick(bot, trigger): return realcom = trigger.sb['com'] - if "aliasfor" in commands_list[trigger.sb['com']].keys(): + if "aliasfor" in list(commands_list[trigger.sb['com']].keys()): realcom = commands_list[trigger.sb['com']]["aliasfor"] validcomlist = commands_list[realcom]["validcoms"] bot.osd("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') @@ -91,10 +91,10 @@ def query_detection(bot, trigger): return commands_list = dict() - for commandstype in SpiceBot.commands.dict['commands'].keys(): + for commandstype in list(SpiceBot.commands.dict['commands'].keys()): if commandstype not in ['rule', 'nickname']: - for com in SpiceBot.commands.dict['commands'][commandstype].keys(): - if com not in commands_list.keys(): + for com in list(SpiceBot.commands.dict['commands'][commandstype].keys()): + if com not in list(commands_list.keys()): commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com] if trigger.sb['com'][:-1] == "+": @@ -112,7 +112,7 @@ def query_detection(bot, trigger): return realcom = trigger.sb['com'] - if "aliasfor" in commands_list[trigger.sb['com']].keys(): + if "aliasfor" in list(commands_list[trigger.sb['com']].keys()): realcom = commands_list[trigger.sb['com']]["aliasfor"] validcomlist = commands_list[realcom]["validcoms"] bot.osd("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') diff --git a/sopel_modules/SpiceBot_Core_Commands/Logs.py b/sopel_modules/SpiceBot_Core_Commands/Logs.py index 7eccb01..59b454f 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Logs.py +++ b/sopel_modules/SpiceBot_Core_Commands/Logs.py @@ -23,11 +23,11 @@ def bot_command_logs(bot, trigger): logtype = spicemanip.main(trigger.sb['args'], 1) or None if not logtype: - bot.osd("Current valid log(s) include: " + spicemanip.main(SpiceBot.logs.dict["list"].keys(), 'andlist'), trigger.sender, 'action') + bot.osd("Current valid log(s) include: " + spicemanip.main(list(SpiceBot.logs.dict["list"].keys()), 'andlist'), trigger.sender, 'action') return - if not SpiceBot.inlist(logtype, SpiceBot.logs.dict["list"].keys()): - closestmatches = SpiceBot.similar_list(logtype, SpiceBot.logs.dict["list"].keys(), 10, 'reverse') + if not SpiceBot.inlist(logtype, list(SpiceBot.logs.dict["list"].keys())): + closestmatches = SpiceBot.similar_list(logtype, list(SpiceBot.logs.dict["list"].keys()), 10, 'reverse') if not len(closestmatches): bot.osd("No valid logs match " + str(logtype) + ".", trigger.nick, 'notice') else: @@ -35,7 +35,7 @@ def bot_command_logs(bot, trigger): return - logtype = SpiceBot.inlist_match(logtype, SpiceBot.logs.dict["list"].keys()) + logtype = SpiceBot.inlist_match(logtype, list(SpiceBot.logs.dict["list"].keys())) logindex = SpiceBot.logs.get_logs(logtype) diff --git a/sopel_modules/SpiceBot_Core_Commands/Messaging.py b/sopel_modules/SpiceBot_Core_Commands/Messaging.py index de9f5eb..3d8a45e 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Messaging.py +++ b/sopel_modules/SpiceBot_Core_Commands/Messaging.py @@ -42,7 +42,7 @@ def bot_command_process(bot, trigger): target = spicemanip.main(trigger.sb['args'], 1) if (target not in ['allchans', 'allnicks'] - and not SpiceBot.inlist(target.lower(), SpiceBot.channels.dict['list'].keys()) + and not SpiceBot.inlist(target.lower(), list(SpiceBot.channels.dict['list'].keys())) and not SpiceBot.inlist(target.lower(), bot.users)): bot.osd("Channel/nick name {} not valid.".format(target)) return @@ -50,7 +50,7 @@ def bot_command_process(bot, trigger): trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') if target == 'allchans': - targetsendlist = bot.channels.keys() + targetsendlist = list(bot.channels.keys()) elif target == 'allnicks': targetsendlist = bot.users else: diff --git a/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py index ec4d8e0..54dce6c 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py +++ b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py @@ -30,7 +30,7 @@ def nickname_comand_update(bot, trigger): quitmessage = "Received command from " + trigger.nick + " to update from Github and restart" SpiceBot.logs.log('SpiceBot_Update', quitmessage) - bot.osd(quitmessage, bot.channels.keys()) + bot.osd(quitmessage, list(bot.channels.keys())) if commandused == 'nodeps': SpiceBot.spicebot_update(False) @@ -49,7 +49,7 @@ def nickname_comand_restart(bot, trigger): quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!" SpiceBot.logs.log('SpiceBot_Restart', quitmessage) - bot.osd(quitmessage, bot.channels.keys()) + bot.osd(quitmessage, list(bot.channels.keys())) # service_manip(bot.nick, 'restart', 'SpiceBot_Restart') SpiceBot.spicebot_reload(bot, 'SpiceBot_Restart', quitmessage) diff --git a/sopel_modules/SpiceBot_Core_Processing/Channels.py b/sopel_modules/SpiceBot_Core_Processing/Channels.py index b4ca4d4..6cdb2d9 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Channels.py +++ b/sopel_modules/SpiceBot_Core_Processing/Channels.py @@ -38,7 +38,7 @@ def request_channels_list_initial(bot, trigger): else: pass - foundchannelcount = len(SpiceBot.channels.dict['list'].keys()) + foundchannelcount = len(list(SpiceBot.channels.dict['list'].keys())) SpiceBot.logs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.") SpiceBot.channels.join_all_channels(bot) @@ -86,13 +86,13 @@ def trigger_channel_list_recurring(bot, trigger): if "*" in newlist: newlist.remove("*") if len(newlist) and SpiceBot.config.SpiceBot_Channels.announcenew: - bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], bot.channels.keys()) + bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], list(bot.channels.keys())) SpiceBot.channels.join_all_channels(bot) SpiceBot.channels.chanadmin_all_channels(bot) - if "*" in SpiceBot.channels.dict['list'].keys(): + if "*" in list(SpiceBot.channels.dict['list'].keys()): del SpiceBot.channels.dict['list']["*"] SpiceBot.channels.bot_part_empty(bot) diff --git a/sopel_modules/SpiceBot_Core_Processing/Events.py b/sopel_modules/SpiceBot_Core_Processing/Events.py index c7aea0e..2b07c3d 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Events.py +++ b/sopel_modules/SpiceBot_Core_Processing/Events.py @@ -41,7 +41,7 @@ def bot_events_start(bot, trigger): SpiceBot.events.trigger(bot, SpiceBot.events.BOT_READY, "Ready To Process module setup procedures") """Here, we wait until we are in at least one channel""" - while not len(bot.channels.keys()) > 0: + while not len(list(bot.channels.keys())) > 0: pass SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CONNECTED, "Bot Connected to IRC") diff --git a/sopel_modules/SpiceBot_Core_Processing/Logs.py b/sopel_modules/SpiceBot_Core_Processing/Logs.py index d1bf3ac..5ad773f 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Logs.py +++ b/sopel_modules/SpiceBot_Core_Processing/Logs.py @@ -14,10 +14,10 @@ def join_log_channel(bot, trigger): if SpiceBot.config.logging_channel: channel = bot.config.core.logging_channel - if channel not in bot.channels.keys(): + if channel not in list(bot.channels.keys()): bot.write(('JOIN', bot.nick, channel)) - if channel not in bot.channels.keys() and bot.config.SpiceBot_Channels.operadmin: - bot.write(('SAJOIN', bot.nick, channel)) + if channel not in list(bot.channels.keys()) and bot.config.SpiceBot_Channels.operadmin: + bot.write(('SAJOIN', bot.nick, channel)) while True: if len(SpiceBot.logs.dict["queue"]): diff --git a/sopel_modules/SpiceBot_Core_Processing/Modules.py b/sopel_modules/SpiceBot_Core_Processing/Modules.py index fa0303d..cb8e512 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Modules.py +++ b/sopel_modules/SpiceBot_Core_Processing/Modules.py @@ -12,8 +12,8 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.rule('.*') def bot_events_complete_modules(bot, trigger): - for comtype in SpiceBot.commands.dict['commands'].keys(): + for comtype in list(SpiceBot.commands.dict['commands'].keys()): if comtype not in ['module', 'nickname', 'rule']: - SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) + SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(len(list(SpiceBot.commands.dict['commands'][comtype].keys()))) + " " + comtype + " commands.", True) SpiceBot.events.trigger(bot, SpiceBot.events.BOT_COMMANDS, "SpiceBot_Commands") diff --git a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py index 10aedb8..f8aafab 100644 --- a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py +++ b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py @@ -15,15 +15,15 @@ import time def bot_startup_monologue_start(bot, trigger): # Startup SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " is now starting. Please wait while I load my configuration") - bot.osd(" is now starting. Please wait while I load my configuration.", bot.channels.keys(), 'ACTION') + bot.osd(" is now starting. Please wait while I load my configuration.", list(bot.channels.keys()), 'ACTION') SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue") @sopel.module.event(SpiceBot.events.BOT_CHANNELS) @sopel.module.rule('.*') def bot_startup_monologue_channels(bot, trigger): - botcount = len(bot.channels.keys()) - servercount = len(SpiceBot.channels.dict['list'].keys()) + botcount = len(list(bot.channels.keys())) + servercount = len(list(SpiceBot.channels.dict['list'].keys())) displayval = "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server." SpiceBot.startupmonologue.dict["channels"] = displayval SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval) @@ -34,8 +34,8 @@ def bot_startup_monologue_channels(bot, trigger): @sopel.module.rule('.*') def bot_startup_monologue_commands(bot, trigger): availablecomsnum, availablecomsfiles = 0, 0 - for commandstype in SpiceBot.commands.dict['commands'].keys(): - availablecomsnum += len(SpiceBot.commands.dict['commands'][commandstype].keys()) + for commandstype in list(SpiceBot.commands.dict['commands'].keys()): + availablecomsnum += len(list(SpiceBot.commands.dict['commands'][commandstype].keys())) availablecomsfiles += SpiceBot.commands.dict['counts'] displayval = "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files." SpiceBot.startupmonologue.dict["commands"] = displayval @@ -58,7 +58,7 @@ def bot_startup_monologue_ai(bot, trigger): @sopel.module.rule('.*') def bot_startup_monologue_display(bot, trigger): dispmsg = [" startup complete"] - for messagekey in SpiceBot.startupmonologue.dict.keys(): + for messagekey in list(SpiceBot.startupmonologue.dict.keys()): dispmsg.append(SpiceBot.startupmonologue.dict[messagekey]) if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1: timesince = SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME) @@ -67,7 +67,7 @@ def bot_startup_monologue_display(bot, trigger): dispmsg.append("Startup took " + timesince) # Announce to chan, then handle some closing stuff SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete") - bot.osd(dispmsg, bot.channels.keys(), 'ACTION') + bot.osd(dispmsg, list(bot.channels.keys()), 'ACTION') SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue") SpiceBot.logs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True) @@ -88,6 +88,6 @@ def bot_startup_monologue_errors(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs', str(foundphase)) searchphrasefound.insert(0, "Notice to Bot Admins: ") searchphrasefound.append("Run the debug command for more information.") - bot.osd(searchphrasefound, bot.channels.keys()) + bot.osd(searchphrasefound, list(bot.channels.keys())) else: SpiceBot.logs.log('SpiceBot_Logs', "No issues found at bot startup!", True) diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py b/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py index 929b1b9..6a76425 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py +++ b/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py @@ -16,7 +16,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): - if trigger.sb['com'] not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): + if trigger.sb['com'] not in list(bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys()): return if not len(trigger.sb['args']): diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_Command.py b/sopel_modules/SpiceBot_GifSearch/Gif_Command.py index 841f958..631a8d1 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_Command.py +++ b/sopel_modules/SpiceBot_GifSearch/Gif_Command.py @@ -20,7 +20,7 @@ def gif_trigger(bot, trigger): return bot.osd("Please present a query to search.") query = spicemanip.main(trigger.sb['args'], 0) - searchapis = bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys() + searchapis = list(bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys()) searchdict = {"query": query, "gifsearch": searchapis} gifdict = getGif(bot, searchdict) diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands index 929b1b9..6a76425 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands +++ b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands @@ -16,7 +16,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): - if trigger.sb['com'] not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): + if trigger.sb['com'] not in list(bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys()): return if not len(trigger.sb['args']): diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index 8681674..d7122ab 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -35,7 +35,7 @@ def configure(config): config.SopelGifSearch.configure_setting('extra', 'SpiceBot_GifSearch API Extra directory') config.SopelGifSearch.configure_setting('nsfw', 'SpiceBot_GifSearch API nsfw content') - for gif_api in valid_gif_api_dict.keys(): + for gif_api in list(valid_gif_api_dict.keys()): config.define_section(gif_api, GifAPISection, validate=False) gif_api_config = eval("config." + gif_api) gif_api_config.configure_setting('apikey', 'GIF API Client ID-' + gif_api) @@ -61,7 +61,7 @@ def setup(bot): valid_gif_api_dict = SpiceBot.read_directory_json_to_dict(dir_to_scan, "Gif API", "SpiceBot_GifSearch", logging=True) - for gif_api in valid_gif_api_dict.keys(): + for gif_api in list(valid_gif_api_dict.keys()): bot.config.define_section(gif_api, GifAPISection, validate=False) SpiceBot.config.define_section(gif_api, GifAPISection, validate=False) apikey = eval("bot.config." + gif_api + ".apikey") @@ -71,7 +71,7 @@ def setup(bot): valid_gif_api_dict[gif_api]["apikey"] = None bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][gif_api] = valid_gif_api_dict[gif_api] - for validgifapi in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): + for validgifapi in list(bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys()): command_dict = { "comtype": "prefix", "validcoms": validgifapi @@ -98,7 +98,7 @@ def getGif(bot, searchdict): query_defaults = { "query": None, "searchnum": 'random', - "gifsearch": bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(), + "gifsearch": list(bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys()), "gifsearchremove": ['gifme'], "searchlimit": 'default', "nsfw": False, @@ -109,7 +109,7 @@ def getGif(bot, searchdict): # set defaults if they don't exist for key in query_defaults: - if key not in searchdict.keys(): + if key not in list(searchdict.keys()): searchdict[key] = query_defaults[key] if key == "gifsearch": for remx in query_defaults["gifsearchremove"]: @@ -123,13 +123,13 @@ def getGif(bot, searchdict): # set api usage if not isinstance(searchdict['gifsearch'], list): - if str(searchdict['gifsearch']) in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): + if str(searchdict['gifsearch']) in list(bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys()): searchdict['gifsearch'] = [searchdict['gifsearch']] else: searchdict['gifsearch'] = bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys() else: for apis in searchdict['gifsearch']: - if apis not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): + if apis not in list(bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys()): searchdict['gifsearch'].remove(apis) # Verify search limit @@ -164,10 +164,10 @@ def getGif(bot, searchdict): # api key url += str(bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][currentapi]['key']) + str(bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][currentapi]['apikey']) - if currentapi not in bot.memory["SpiceBot_GifSearch"]['cache'].keys(): + if currentapi not in list(bot.memory["SpiceBot_GifSearch"]['cache'].keys()): bot.memory["SpiceBot_GifSearch"]['cache'][currentapi] = dict() - if str(searchdict["searchquery"]) not in bot.memory["SpiceBot_GifSearch"]['cache'][currentapi].keys(): + if str(searchdict["searchquery"]) not in list(bot.memory["SpiceBot_GifSearch"]['cache'][currentapi].keys()): bot.memory["SpiceBot_GifSearch"]['cache'][currentapi][str(searchdict["searchquery"])] = [] if not len(bot.memory["SpiceBot_GifSearch"]['cache'][currentapi][str(searchdict["searchquery"])]):