Merge pull request #52 from SpiceBot/development

Development
This commit is contained in:
Deathbybandaid 2019-06-08 09:23:45 -04:00 committed by GitHub
commit 9a0fefef1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 118 additions and 118 deletions

View File

@ -78,7 +78,7 @@ class SpiceBot_AI():
# current_bot_db = botdb.get_bot_value('botai') or None # current_bot_db = botdb.get_bot_value('botai') or None
# if current_bot_db: # if current_bot_db:
# for predicate in current_bot_db.keys(): # for predicate in list(current_bot_db.keys()):
# predval = current_bot_db[predicate] # predval = current_bot_db[predicate]
# self.aiml_kernel.setBotPredicate(predicate, predval) # self.aiml_kernel.setBotPredicate(predicate, predval)
@ -141,7 +141,7 @@ class SpiceBot_AI():
# punctuation # punctuation
puct_dict = {"!": "exclamationmark", ".": "period", "?": "questionmark", ",": "comma"} 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]) message = message.replace(puctuation, puct_dict[puctuation])
# bot items # bot items
@ -200,12 +200,12 @@ class SpiceBot_AI():
"self": "themselves", "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]) aiml_response = aiml_response.replace("BOTPRONOUN" + pronounitem, pronounsdict[botgendertype][pronounitem])
triggergendertype = self.getPredicate("gender", trigger.nick) triggergendertype = self.getPredicate("gender", trigger.nick)
if not triggergendertype or triggergendertype == "": if not triggergendertype or triggergendertype == "":
triggergendertype = "point" 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 = aiml_response.replace("TRIGGERPRONOUN" + pronounitem, pronounsdict[triggergendertype][pronounitem])
aiml_response = "\x0315" + aiml_response + "\x03" aiml_response = "\x0315" + aiml_response + "\x03"
@ -222,14 +222,14 @@ class SpiceBot_AI():
if not nick_id: if not nick_id:
nick = Identifier(nick) nick = Identifier(nick)
nick_id = botdb.get_nick_id(nick, create=True) 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 {} 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] predval = self.dict["sessioncache"][nick_id][predicate]
self.aiml_kernel.setPredicate(predicate, predval, nick_id) self.aiml_kernel.setPredicate(predicate, predval, nick_id)
# defaults # 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.dict["sessioncache"][nick_id]["nick"] = nick
self.aiml_kernel.setPredicate("nick", nick, nick_id) self.aiml_kernel.setPredicate("nick", nick, nick_id)

View File

@ -45,7 +45,7 @@ class BotChannels():
def channel_list_recieve_input(self, trigger): def channel_list_recieve_input(self, trigger):
self.lock.acquire() self.lock.acquire()
channel, _, topic = trigger.args[1:] 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()] = dict()
self.dict['list'][channel.lower()]['name'] = channel self.dict['list'][channel.lower()]['name'] = channel
self.dict['list'][channel.lower()]['topic'] = self.topic_compile(topic) self.dict['list'][channel.lower()]['topic'] = self.topic_compile(topic)
@ -69,8 +69,8 @@ class BotChannels():
ignorepartlist = [] ignorepartlist = []
if bot.config.core.logging_channel: if bot.config.core.logging_channel:
ignorepartlist.append(bot.config.core.logging_channel) ignorepartlist.append(bot.config.core.logging_channel)
for channel in bot.channels.keys(): for channel in list(bot.channels.keys()):
if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist and channel.startswith("#"): if len(list(bot.channels[channel].privileges.keys())) == 1 and channel not in ignorepartlist and channel.startswith("#"):
bot.part(channel, "Leaving Empty Channel") bot.part(channel, "Leaving Empty Channel")
if channel.lower() in self.dict['list']: if channel.lower() in self.dict['list']:
self.lock.acquire() self.lock.acquire()
@ -79,16 +79,16 @@ class BotChannels():
def join_all_channels(self, bot): def join_all_channels(self, bot):
if botconfig.SpiceBot_Channels.joinall: 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.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'])) 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'])) bot.write(('SAJOIN', bot.nick, self.dict['list'][channel]['name']))
def chanadmin_all_channels(self, bot): def chanadmin_all_channels(self, bot):
# Chan ADMIN +a # Chan ADMIN +a
for channel in bot.channels.keys(): for channel in list(bot.channels.keys()):
if channel.startswith("#"): if channel.startswith("#"):
if channel not in botconfig.SpiceBot_Channels.chanignore: if channel not in botconfig.SpiceBot_Channels.chanignore:
if botconfig.SpiceBot_Channels.operadmin: if botconfig.SpiceBot_Channels.operadmin:
@ -105,7 +105,7 @@ class BotChannels():
def add_to_channel(self, channel, nick, nick_id=None): def add_to_channel(self, channel, nick, nick_id=None):
if not nick_id: if not nick_id:
nick_id = self.whois_ident(nick) 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() self.dict['list'][channel.lower()] = dict()
if 'users' not in self.dict['list'][channel.lower()]: if 'users' not in self.dict['list'][channel.lower()]:
self.dict['list'][channel.lower()]['users'] = [] self.dict['list'][channel.lower()]['users'] = []
@ -115,7 +115,7 @@ class BotChannels():
def remove_from_channel(self, channel, nick, nick_id=None): def remove_from_channel(self, channel, nick, nick_id=None):
if not nick_id: if not nick_id:
nick_id = self.whois_ident(nick) 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() self.dict['list'][channel.lower()] = dict()
if 'users' not in self.dict['list'][channel.lower()]: if 'users' not in self.dict['list'][channel.lower()]:
self.dict['list'][channel.lower()]['users'] = [] self.dict['list'][channel.lower()]['users'] = []
@ -123,21 +123,21 @@ class BotChannels():
self.dict['list'][channel.lower()]['users'].remove(nick_id) self.dict['list'][channel.lower()]['users'].remove(nick_id)
def remove_all_from_channel(self, channel): 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() self.dict['list'][channel.lower()] = dict()
if 'users' not in self.dict['list'][channel.lower()]: if 'users' not in self.dict['list'][channel.lower()]:
self.dict['list'][channel.lower()]['users'] = [] self.dict['list'][channel.lower()]['users'] = []
self.dict['list'][channel.lower()]['users'] = [] self.dict['list'][channel.lower()]['users'] = []
def channel_scan(self, bot): def channel_scan(self, bot):
for channel in bot.channels.keys(): for channel in list(bot.channels.keys()):
for user in bot.channels[channel].privileges.keys(): for user in list(bot.channels[channel].privileges.keys()):
self.add_to_channel(channel, user) self.add_to_channel(channel, user)
def join(self, bot, trigger): def join(self, bot, trigger):
# bot block # bot block
if trigger.nick == bot.nick: 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) self.add_to_channel(trigger.sender, user)
return return
# Identify # Identify

View File

@ -42,7 +42,7 @@ class BotCommands():
self.module_files_parse() self.module_files_parse()
self.nickrules() self.nickrules()
for comtype in ['module', 'nickname', 'rule']: 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): def setup_commands(self):
botconfig.define_section("SpiceBot_Commands", SpiceBot_Commands_MainSection, validate=False) 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) botconfig.core.prefix_list.extend(botconfig.SpiceBot_Commands.query_prefix)
def nickrules(self): def nickrules(self):
for command in self.dict['commands']['rule'].keys(): for command in list(self.dict['commands']['rule'].keys()):
if command.startswith("$nickname"): if command.startswith("$nickname"):
command = command.split("$nickname")[-1] command = command.split("$nickname")[-1]
if command not in self.dict['nickrules']: if command not in self.dict['nickrules']:
self.dict['nickrules'].append(command) self.dict['nickrules'].append(command)
def find_command_type(self, 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']: 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(): if com.lower() == command.lower():
return commandstype return commandstype
return None return None
@ -70,7 +70,7 @@ class BotCommands():
return self.dict['disabled'] return self.dict['disabled']
def check_commands_disabled(self, command, channel): 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 return True
else: else:
return False return False
@ -78,10 +78,10 @@ class BotCommands():
def get_realcom(self, command, trigger_command_type): def get_realcom(self, command, trigger_command_type):
realcom = command 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 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 return realcom
if "aliasfor" in self.dict['commands'][trigger_command_type][command].keys(): if "aliasfor" in self.dict['commands'][trigger_command_type][command].keys():
@ -98,7 +98,7 @@ class BotCommands():
def unset_command_disabled(self, command, channel): def unset_command_disabled(self, command, channel):
if not len(list(self.dict['disabled'])): if not len(list(self.dict['disabled'])):
self.dict['disabled'] = botdb.get_channel_value(channel, 'commands_disabled') or {} 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] del self.dict['disabled'][command]
botdb.set_channel_value(channel, 'commands_disabled', self.dict['disabled']) botdb.set_channel_value(channel, 'commands_disabled', self.dict['disabled'])
@ -112,13 +112,13 @@ class BotCommands():
if not isinstance(validcoms, list): if not isinstance(validcoms, list):
validcoms = [validcoms] 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() self.dict['commands'][command_type] = dict()
dict_from_file = dict() dict_from_file = dict()
# default command to filename # 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 dict_from_file["validcoms"] = validcoms
maincom = dict_from_file["validcoms"][0] maincom = dict_from_file["validcoms"][0]
@ -129,7 +129,7 @@ class BotCommands():
self.dict['commands'][command_type][maincom] = dict_from_file self.dict['commands'][command_type][maincom] = dict_from_file
for comalias in comaliases: 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.dict['commands'][command_type][comalias] = {"aliasfor": maincom}
self.lock.release() self.lock.release()

View File

@ -28,10 +28,10 @@ class BotConfig():
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read(self.config.filename) config.read(self.config.filename)
for each_section in config.sections(): 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() self.dict[each_section.lower()] = dict()
for (each_key, each_val) in config.items(each_section): 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 self.dict[each_section.lower()][each_key.lower()] = each_val
def setup_config(self): def setup_config(self):
@ -46,7 +46,7 @@ class BotConfig():
"""We will try to find a core value, or return None""" """We will try to find a core value, or return None"""
if hasattr(self.config.core, name): if hasattr(self.config.core, name):
return eval("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()] return self.dict["core"][str(name).lower()]
elif hasattr(self.config, name): elif hasattr(self.config, name):
return eval("self.config." + name) return eval("self.config." + name)

View File

@ -95,7 +95,7 @@ class BotEvents(object):
if not isinstance(checklist, list): if not isinstance(checklist, list):
checklist = [str(checklist)] checklist = [str(checklist)]
for number in 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 False
return True return True
@ -110,14 +110,14 @@ class BotEvents(object):
def startup_check(self): def startup_check(self):
for number in self.dict["startup_required"]: 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 False
return True return True
def startup_debug(self): def startup_debug(self):
not_done = [] not_done = []
for number in self.dict["startup_required"]: 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)) not_done.append(int(number))
reference_not_done = [] reference_not_done = []
for item in not_done: for item in not_done:

View File

@ -50,7 +50,7 @@ class BotLogs():
if stdio: if stdio:
self.botstderr(logmessage) 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] = []
self.dict["list"][logtype].append(logentry) self.dict["list"][logtype].append(logentry)
@ -68,7 +68,7 @@ class BotLogs():
def stdio_logs_fetch(self): def stdio_logs_fetch(self):
stdio_ignore = [] stdio_ignore = []
for logtype in self.dict["list"].keys(): for logtype in list(self.dict["list"].keys()):
stdio_ignore.append("[" + logtype + "]") stdio_ignore.append("[" + logtype + "]")
try: try:

View File

@ -109,7 +109,7 @@ class BotPrerun():
if not trigger.is_privmsg: if not trigger.is_privmsg:
commandused = trigger.sb["realcom"] commandused = trigger.sb["realcom"]
disabled_list = botdb.get_channel_value(trigger.sender, 'commands_disabled') or {} 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"] reason = disabled_list[trigger.sb["realcom"]]["reason"]
timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"]
bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"] bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"]

View File

@ -242,7 +242,7 @@ def letters_in_string(text):
def channel_privs(bot, channel, privtype): def channel_privs(bot, channel, privtype):
privlist = [] privlist = []
for user in bot.channels[channel].privileges.keys(): for user in list(bot.channels[channel].privileges.keys()):
try: try:
privnum = bot.channels[channel].privileges[user] or 0 privnum = bot.channels[channel].privileges[user] or 0
except KeyError: except KeyError:

View File

@ -14,7 +14,7 @@ class BotUsers():
self.all = botdb.get_bot_value('users') or dict() self.all = botdb.get_bot_value('users') or dict()
self.online = [] self.online = []
self.offline = [] self.offline = []
for user_id in self.all.keys(): for user_id in list(self.all.keys()):
self.offline.append(int(user_id)) self.offline.append(int(user_id))
self.current = {} self.current = {}
@ -25,9 +25,9 @@ class BotUsers():
return self.current[nick_id]["nick"] return self.current[nick_id]["nick"]
def whois_id(self, nick_id): 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"] 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] return self.all[nick_id][0]
else: else:
return None return None
@ -50,7 +50,7 @@ class BotUsers():
if not nick_id: if not nick_id:
nick_id = self.whois_ident(nick) nick_id = self.whois_ident(nick)
# add to all if not there # 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] = [] self.all[nick_id] = []
# add nick alias # add nick alias
if nick not in self.all[nick_id]: if nick not in self.all[nick_id]:
@ -61,12 +61,12 @@ class BotUsers():
if not nick_id: if not nick_id:
nick_id = self.whois_ident(nick) nick_id = self.whois_ident(nick)
# add to current if not there # 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} self.current[nick_id] = {"channels": [], "nick": nick}
def channel_scan(self, bot): def channel_scan(self, bot):
for channel in bot.channels.keys(): for channel in list(bot.channels.keys()):
for user in bot.channels[channel].privileges.keys(): for user in list(bot.channels[channel].privileges.keys()):
# Identify # Identify
nick_id = self.whois_ident(user) nick_id = self.whois_ident(user)
# Verify nick is in the all list # Verify nick is in the all list
@ -86,7 +86,7 @@ class BotUsers():
def join(self, bot, trigger): def join(self, bot, trigger):
if trigger.nick == bot.nick: 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 # Identify
nick_id = self.whois_ident(user) nick_id = self.whois_ident(user)
# Verify nick is in the all list # Verify nick is in the all list
@ -142,7 +142,7 @@ class BotUsers():
def part(self, bot, trigger): def part(self, bot, trigger):
if trigger.nick == bot.nick: 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"]: if trigger.sender in self.current[nick_id]["channels"]:
self.current[nick_id]["channels"].remove(trigger.sender) self.current[nick_id]["channels"].remove(trigger.sender)
# mark offline # mark offline
@ -169,7 +169,7 @@ class BotUsers():
def kick(self, bot, trigger): def kick(self, bot, trigger):
targetnick = Identifier(str(trigger.args[1])) targetnick = Identifier(str(trigger.args[1]))
if targetnick == bot.nick: 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"]: if trigger.sender in self.current[nick_id]["channels"]:
self.current[nick_id]["channels"].remove(trigger.sender) self.current[nick_id]["channels"].remove(trigger.sender)
# mark offline # mark offline

View File

@ -46,7 +46,7 @@ class ToolsOSD:
* unicode string * unicode string
* a comma-seperated unicode string * a comma-seperated unicode string
* list * list
* dict_keys handy for bot.channels.keys() * dict_keys handy for list(bot.channels.keys())
""" """
if sys.version_info.major >= 3: if sys.version_info.major >= 3:

View File

@ -20,7 +20,7 @@ def bot_command_nick(bot, trigger):
if trigger.sb['com'][0] == "?": if trigger.sb['com'][0] == "?":
return 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 return
trigger.sb['args'].insert(0, trigger.sb['com']) trigger.sb['args'].insert(0, trigger.sb['com'])

View File

@ -32,9 +32,9 @@ def bot_command_rule(bot, trigger):
if trigger_command.startswith("."): if trigger_command.startswith("."):
return return
commands_list = [] 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']: 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: if com not in commands_list:
commands_list.append(com) commands_list.append(com)
if trigger_command not in commands_list: if trigger_command not in commands_list:
@ -55,7 +55,7 @@ def bot_command_rule(bot, trigger):
return return
if fulltrigger in SpiceBot.commands.dict['nickrules']: if fulltrigger in SpiceBot.commands.dict['nickrules']:
return return
if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys(): if trigger_command in list(SpiceBot.commands.dict['commands']["nickname"].keys()):
return return
else: else:
command_type = 'other' command_type = 'other'
@ -90,22 +90,22 @@ def bot_command_rule(bot, trigger):
realtarget = SpiceBot.inlist_match(target, bot.users) realtarget = SpiceBot.inlist_match(target, bot.users)
dispmsg = [trigger.nick + ", yes. I can see " + realtarget] dispmsg = [trigger.nick + ", yes. I can see " + realtarget]
targetchannels = [] targetchannels = []
for channel in bot.channels.keys(): for channel in list(bot.channels.keys()):
if SpiceBot.inlist(trigger.nick, bot.channels[channel].privileges.keys()): if SpiceBot.inlist(trigger.nick, list(bot.channels[channel].privileges.keys())):
targetchannels.append(channel) targetchannels.append(channel)
dispmsg.append(realtarget + " is in " + spicemanip.main(targetchannels, 'andlist')) dispmsg.append(realtarget + " is in " + spicemanip.main(targetchannels, 'andlist'))
bot.osd(dispmsg) bot.osd(dispmsg)
else: else:
bot.osd(trigger.nick + ", no. I cannot see " + target + " right now!") 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.") # bot.osd(trigger.nick + ", I can't see " + inlist_match(target, bot.users) + " at the moment.")
# else: # else:
# bot.osd("I have never seen " + str(target) + ".") # bot.osd("I have never seen " + str(target) + ".")
# user in bot.channels[channel].privileges.keys() # user in list(bot.channels[channel].privileges.keys())
# TODO # TODO
return 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): if len(closestmatches):
closestmatches = spicemanip.main(closestmatches, "andlist") closestmatches = spicemanip.main(closestmatches, "andlist")
bot.osd("I don't know what you are asking me to do! Did you mean: " + str(closestmatches) + "?") bot.osd("I don't know what you are asking me to do! Did you mean: " + str(closestmatches) + "?")

View File

@ -23,13 +23,13 @@ def nickname_comand_channels(bot, trigger):
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
if commandused == '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) bot.osd("You can find me in " + chanlist)
return return
elif commandused == 'total': elif commandused == 'total':
botcount = len(bot.channels.keys()) botcount = len(list(bot.channels.keys()))
servercount = len(SpiceBot.channels.dict['list'].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.") bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.")
return return
@ -54,7 +54,7 @@ def nickname_comand_channels(bot, trigger):
while SpiceBot.channels.channel_lock: while SpiceBot.channels.channel_lock:
pass pass
SpiceBot.channels.join_all_channels(bot) 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.") bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.")
SpiceBot.channels.bot_part_empty(bot) SpiceBot.channels.bot_part_empty(bot)
return return
@ -64,7 +64,7 @@ def nickname_comand_channels(bot, trigger):
bot.osd("Channel name input missing.") bot.osd("Channel name input missing.")
return return
channel = spicemanip.main(trigger.sb['args'], 1) 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)) bot.osd("Channel name {} not valid.".format(channel))
return return
topic = SpiceBot.channels.dict['list'][channel.lower()]['topic'] topic = SpiceBot.channels.dict['list'][channel.lower()]['topic']
@ -81,10 +81,10 @@ def nickname_comand_channels(bot, trigger):
channel = trigger.sender channel = trigger.sender
else: else:
channel = spicemanip.main(trigger.sb['args'], 1) 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)) bot.osd("Channel name {} not valid.".format(channel))
return 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)) bot.osd("I need to be in {} to see nick privileges.".format(channel))
return return
@ -101,17 +101,17 @@ def nickname_comand_channels(bot, trigger):
# Users List # Users List
if commandused == 'users': if commandused == 'users':
channel = spicemanip.main(trigger.sb['args'], 1) 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)) bot.osd("Channel name {} not valid.".format(channel))
return 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)) bot.osd("I need to be in {} to see user list.".format(channel))
return return
dispmsg = [] 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)) dispmsg.append("There are no Channel users for " + str(channel))
else: 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) dispmsg.append("Channel users for " + str(channel) + " are: " + userslist)
bot.osd(dispmsg, trigger.nick, 'notice') bot.osd(dispmsg, trigger.nick, 'notice')
return return

View File

@ -23,9 +23,9 @@ def nickname_comand_commands(bot, trigger):
commandused = spicemanip.main(trigger.sb['args'], 1).lower() commandused = spicemanip.main(trigger.sb['args'], 1).lower()
commands_list = [] commands_list = []
for commandstype in SpiceBot.commands.dict['commands'].keys(): for commandstype in list(SpiceBot.commands.dict['commands'].keys()):
if commandstype not in ['rule']: 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 com not in commands_list:
if commandstype in ['nickname']: if commandstype in ['nickname']:
commands_list.append(bot.nick + " " + com) commands_list.append(bot.nick + " " + com)

View File

@ -29,8 +29,8 @@ def query_detection_nick(bot, trigger):
return return
commands_list = dict() commands_list = dict()
for com in SpiceBot.commands.dict['commands']['nickname'].keys(): for com in list(SpiceBot.commands.dict['commands']['nickname'].keys()):
if com not in commands_list.keys(): if com not in list(commands_list.keys()):
commands_list[com] = SpiceBot.commands.dict['commands']['nickname'][com] commands_list[com] = SpiceBot.commands.dict['commands']['nickname'][com]
if trigger.sb['com'].endswith("+"): if trigger.sb['com'].endswith("+"):
@ -48,7 +48,7 @@ def query_detection_nick(bot, trigger):
return return
realcom = trigger.sb['com'] 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"] realcom = commands_list[trigger.sb['com']]["aliasfor"]
validcomlist = commands_list[realcom]["validcoms"] validcomlist = commands_list[realcom]["validcoms"]
bot.osd("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') 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 return
commands_list = dict() 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']: 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.keys(): if com not in list(commands_list.keys()):
commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com] commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com]
if trigger.sb['com'][:-1] == "+": if trigger.sb['com'][:-1] == "+":
@ -112,7 +112,7 @@ def query_detection(bot, trigger):
return return
realcom = trigger.sb['com'] 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"] realcom = commands_list[trigger.sb['com']]["aliasfor"]
validcomlist = commands_list[realcom]["validcoms"] validcomlist = commands_list[realcom]["validcoms"]
bot.osd("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') bot.osd("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice')

View File

@ -23,11 +23,11 @@ def bot_command_logs(bot, trigger):
logtype = spicemanip.main(trigger.sb['args'], 1) or None logtype = spicemanip.main(trigger.sb['args'], 1) or None
if not logtype: 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 return
if not SpiceBot.inlist(logtype, SpiceBot.logs.dict["list"].keys()): if not SpiceBot.inlist(logtype, list(SpiceBot.logs.dict["list"].keys())):
closestmatches = SpiceBot.similar_list(logtype, SpiceBot.logs.dict["list"].keys(), 10, 'reverse') closestmatches = SpiceBot.similar_list(logtype, list(SpiceBot.logs.dict["list"].keys()), 10, 'reverse')
if not len(closestmatches): if not len(closestmatches):
bot.osd("No valid logs match " + str(logtype) + ".", trigger.nick, 'notice') bot.osd("No valid logs match " + str(logtype) + ".", trigger.nick, 'notice')
else: else:
@ -35,7 +35,7 @@ def bot_command_logs(bot, trigger):
return 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) logindex = SpiceBot.logs.get_logs(logtype)

View File

@ -42,7 +42,7 @@ def bot_command_process(bot, trigger):
target = spicemanip.main(trigger.sb['args'], 1) target = spicemanip.main(trigger.sb['args'], 1)
if (target not in ['allchans', 'allnicks'] 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)): and not SpiceBot.inlist(target.lower(), bot.users)):
bot.osd("Channel/nick name {} not valid.".format(target)) bot.osd("Channel/nick name {} not valid.".format(target))
return return
@ -50,7 +50,7 @@ def bot_command_process(bot, trigger):
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
if target == 'allchans': if target == 'allchans':
targetsendlist = bot.channels.keys() targetsendlist = list(bot.channels.keys())
elif target == 'allnicks': elif target == 'allnicks':
targetsendlist = bot.users targetsendlist = bot.users
else: else:

View File

@ -30,7 +30,7 @@ def nickname_comand_update(bot, trigger):
quitmessage = "Received command from " + trigger.nick + " to update from Github and restart" quitmessage = "Received command from " + trigger.nick + " to update from Github and restart"
SpiceBot.logs.log('SpiceBot_Update', quitmessage) SpiceBot.logs.log('SpiceBot_Update', quitmessage)
bot.osd(quitmessage, bot.channels.keys()) bot.osd(quitmessage, list(bot.channels.keys()))
if commandused == 'nodeps': if commandused == 'nodeps':
SpiceBot.spicebot_update(False) 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!" quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!"
SpiceBot.logs.log('SpiceBot_Restart', quitmessage) 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') # service_manip(bot.nick, 'restart', 'SpiceBot_Restart')
SpiceBot.spicebot_reload(bot, 'SpiceBot_Restart', quitmessage) SpiceBot.spicebot_reload(bot, 'SpiceBot_Restart', quitmessage)

View File

@ -38,7 +38,7 @@ def request_channels_list_initial(bot, trigger):
else: else:
pass 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.logs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.")
SpiceBot.channels.join_all_channels(bot) SpiceBot.channels.join_all_channels(bot)
@ -86,13 +86,13 @@ def trigger_channel_list_recurring(bot, trigger):
if "*" in newlist: if "*" in newlist:
newlist.remove("*") newlist.remove("*")
if len(newlist) and SpiceBot.config.SpiceBot_Channels.announcenew: 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.join_all_channels(bot)
SpiceBot.channels.chanadmin_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']["*"] del SpiceBot.channels.dict['list']["*"]
SpiceBot.channels.bot_part_empty(bot) SpiceBot.channels.bot_part_empty(bot)

View File

@ -41,7 +41,7 @@ def bot_events_start(bot, trigger):
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_READY, "Ready To Process module setup procedures") 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""" """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 pass
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CONNECTED, "Bot Connected to IRC") SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CONNECTED, "Bot Connected to IRC")

View File

@ -14,10 +14,10 @@ def join_log_channel(bot, trigger):
if SpiceBot.config.logging_channel: if SpiceBot.config.logging_channel:
channel = bot.config.core.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)) bot.write(('JOIN', bot.nick, channel))
if channel not in bot.channels.keys() and bot.config.SpiceBot_Channels.operadmin: if channel not in list(bot.channels.keys()) and bot.config.SpiceBot_Channels.operadmin:
bot.write(('SAJOIN', bot.nick, channel)) bot.write(('SAJOIN', bot.nick, channel))
while True: while True:
if len(SpiceBot.logs.dict["queue"]): if len(SpiceBot.logs.dict["queue"]):

View File

@ -12,8 +12,8 @@ import sopel_modules.SpiceBot as SpiceBot
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_events_complete_modules(bot, trigger): 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']: 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") SpiceBot.events.trigger(bot, SpiceBot.events.BOT_COMMANDS, "SpiceBot_Commands")

View File

@ -15,15 +15,15 @@ import time
def bot_startup_monologue_start(bot, trigger): def bot_startup_monologue_start(bot, trigger):
# Startup # Startup
SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " is now starting. Please wait while I load my configuration") 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") SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue")
@sopel.module.event(SpiceBot.events.BOT_CHANNELS) @sopel.module.event(SpiceBot.events.BOT_CHANNELS)
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_startup_monologue_channels(bot, trigger): def bot_startup_monologue_channels(bot, trigger):
botcount = len(bot.channels.keys()) botcount = len(list(bot.channels.keys()))
servercount = len(SpiceBot.channels.dict['list'].keys()) servercount = len(list(SpiceBot.channels.dict['list'].keys()))
displayval = "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server." displayval = "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server."
SpiceBot.startupmonologue.dict["channels"] = displayval SpiceBot.startupmonologue.dict["channels"] = displayval
SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval) SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval)
@ -34,8 +34,8 @@ def bot_startup_monologue_channels(bot, trigger):
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_startup_monologue_commands(bot, trigger): def bot_startup_monologue_commands(bot, trigger):
availablecomsnum, availablecomsfiles = 0, 0 availablecomsnum, availablecomsfiles = 0, 0
for commandstype in SpiceBot.commands.dict['commands'].keys(): for commandstype in list(SpiceBot.commands.dict['commands'].keys()):
availablecomsnum += len(SpiceBot.commands.dict['commands'][commandstype].keys()) availablecomsnum += len(list(SpiceBot.commands.dict['commands'][commandstype].keys()))
availablecomsfiles += SpiceBot.commands.dict['counts'] availablecomsfiles += SpiceBot.commands.dict['counts']
displayval = "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files." displayval = "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files."
SpiceBot.startupmonologue.dict["commands"] = displayval SpiceBot.startupmonologue.dict["commands"] = displayval
@ -58,7 +58,7 @@ def bot_startup_monologue_ai(bot, trigger):
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_startup_monologue_display(bot, trigger): def bot_startup_monologue_display(bot, trigger):
dispmsg = [" startup complete"] dispmsg = [" startup complete"]
for messagekey in SpiceBot.startupmonologue.dict.keys(): for messagekey in list(SpiceBot.startupmonologue.dict.keys()):
dispmsg.append(SpiceBot.startupmonologue.dict[messagekey]) dispmsg.append(SpiceBot.startupmonologue.dict[messagekey])
if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1: if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1:
timesince = SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME) 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) dispmsg.append("Startup took " + timesince)
# Announce to chan, then handle some closing stuff # Announce to chan, then handle some closing stuff
SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete") 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.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue")
SpiceBot.logs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True) 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)) SpiceBot.logs.log('SpiceBot_Logs', str(foundphase))
searchphrasefound.insert(0, "Notice to Bot Admins: ") searchphrasefound.insert(0, "Notice to Bot Admins: ")
searchphrasefound.append("Run the debug command for more information.") searchphrasefound.append("Run the debug command for more information.")
bot.osd(searchphrasefound, bot.channels.keys()) bot.osd(searchphrasefound, list(bot.channels.keys()))
else: else:
SpiceBot.logs.log('SpiceBot_Logs', "No issues found at bot startup!", True) SpiceBot.logs.log('SpiceBot_Logs', "No issues found at bot startup!", True)

View File

@ -16,7 +16,7 @@ import sopel_modules.SpiceBot as SpiceBot
@sopel.module.commands('(.*)') @sopel.module.commands('(.*)')
def gifapi_triggers(bot, trigger): 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 return
if not len(trigger.sb['args']): if not len(trigger.sb['args']):

View File

@ -20,7 +20,7 @@ def gif_trigger(bot, trigger):
return bot.osd("Please present a query to search.") return bot.osd("Please present a query to search.")
query = spicemanip.main(trigger.sb['args'], 0) 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} searchdict = {"query": query, "gifsearch": searchapis}
gifdict = getGif(bot, searchdict) gifdict = getGif(bot, searchdict)

View File

@ -16,7 +16,7 @@ import sopel_modules.SpiceBot as SpiceBot
@sopel.module.commands('(.*)') @sopel.module.commands('(.*)')
def gifapi_triggers(bot, trigger): 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 return
if not len(trigger.sb['args']): if not len(trigger.sb['args']):

View File

@ -35,7 +35,7 @@ def configure(config):
config.SopelGifSearch.configure_setting('extra', 'SpiceBot_GifSearch API Extra directory') config.SopelGifSearch.configure_setting('extra', 'SpiceBot_GifSearch API Extra directory')
config.SopelGifSearch.configure_setting('nsfw', 'SpiceBot_GifSearch API nsfw content') 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) config.define_section(gif_api, GifAPISection, validate=False)
gif_api_config = eval("config." + gif_api) gif_api_config = eval("config." + gif_api)
gif_api_config.configure_setting('apikey', 'GIF API Client ID-' + 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) 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) bot.config.define_section(gif_api, GifAPISection, validate=False)
SpiceBot.config.define_section(gif_api, GifAPISection, validate=False) SpiceBot.config.define_section(gif_api, GifAPISection, validate=False)
apikey = eval("bot.config." + gif_api + ".apikey") apikey = eval("bot.config." + gif_api + ".apikey")
@ -71,7 +71,7 @@ def setup(bot):
valid_gif_api_dict[gif_api]["apikey"] = None valid_gif_api_dict[gif_api]["apikey"] = None
bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][gif_api] = valid_gif_api_dict[gif_api] 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 = { command_dict = {
"comtype": "prefix", "comtype": "prefix",
"validcoms": validgifapi "validcoms": validgifapi
@ -98,7 +98,7 @@ def getGif(bot, searchdict):
query_defaults = { query_defaults = {
"query": None, "query": None,
"searchnum": 'random', "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'], "gifsearchremove": ['gifme'],
"searchlimit": 'default', "searchlimit": 'default',
"nsfw": False, "nsfw": False,
@ -109,7 +109,7 @@ def getGif(bot, searchdict):
# set defaults if they don't exist # set defaults if they don't exist
for key in query_defaults: for key in query_defaults:
if key not in searchdict.keys(): if key not in list(searchdict.keys()):
searchdict[key] = query_defaults[key] searchdict[key] = query_defaults[key]
if key == "gifsearch": if key == "gifsearch":
for remx in query_defaults["gifsearchremove"]: for remx in query_defaults["gifsearchremove"]:
@ -123,13 +123,13 @@ def getGif(bot, searchdict):
# set api usage # set api usage
if not isinstance(searchdict['gifsearch'], list): 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']] searchdict['gifsearch'] = [searchdict['gifsearch']]
else: else:
searchdict['gifsearch'] = bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys() searchdict['gifsearch'] = bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys()
else: else:
for apis in searchdict['gifsearch']: 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) searchdict['gifsearch'].remove(apis)
# Verify search limit # Verify search limit
@ -164,10 +164,10 @@ def getGif(bot, searchdict):
# api key # 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']) 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() 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"])] = [] bot.memory["SpiceBot_GifSearch"]['cache'][currentapi][str(searchdict["searchquery"])] = []
if not len(bot.memory["SpiceBot_GifSearch"]['cache'][currentapi][str(searchdict["searchquery"])]): if not len(bot.memory["SpiceBot_GifSearch"]['cache'][currentapi][str(searchdict["searchquery"])]):