From e11dec69b7d2ff3085f709b36cb70ab75d34abe8 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 21 May 2019 12:32:26 -0400 Subject: [PATCH] move commands listing to class --- sopel_modules/SpiceBot/Commands.py | 56 ++++++ sopel_modules/SpiceBot/__init__.py | 1 + sopel_modules/SpiceBot_AI/AI.py | 7 +- .../SpiceBot_CommandsQuery/CommandsQuery.py | 43 ++--- .../NickQueryCommand.py | 5 +- .../SpiceBot_CommandsQuery/QueryCommand.py | 7 +- .../SpiceBot_CommandsQuery/__init__.py | 1 - sopel_modules/SpiceBot_GifSearch/gifsearch.py | 4 +- .../SpiceBot_InvalidCommand/InvalidCommand.py | 5 +- .../SpiceBot_Module_Parsing/ModuleParsing.py | 168 ++++++++++++++++++ .../SpiceBot_Module_Parsing/__init__.py | 10 ++ .../StartupMonologue_Display_Commands.py | 7 +- 12 files changed, 272 insertions(+), 42 deletions(-) create mode 100644 sopel_modules/SpiceBot/Commands.py create mode 100644 sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py create mode 100644 sopel_modules/SpiceBot_Module_Parsing/__init__.py diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py new file mode 100644 index 0000000..7168047 --- /dev/null +++ b/sopel_modules/SpiceBot/Commands.py @@ -0,0 +1,56 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Logs system. + +This Class stores logs in an easy to access manner +""" + +import spicemanip + + +class BotCommandss(): + """This Logs all channels known to the server""" + def __init__(self): + self.SpiceBot_Commands = { + "counts": 0, + "commands": { + 'module': {}, + 'nickname': {}, + 'rule': {} + }, + "nickrules": [] + } + + def commandsquery_register(self, bot, command_type, validcoms, aliasfor=None): + + if not isinstance(validcoms, list): + validcoms = [validcoms] + + if command_type not in self.SpiceBot_Commands['commands'].keys(): + self.SpiceBot_Commands['commands'][command_type] = dict() + self.SpiceBot_Commands['counts'] += 1 + + dict_from_file = dict() + + # default command to filename + if "validcoms" not in dict_from_file.keys(): + dict_from_file["validcoms"] = validcoms + + if not aliasfor: + + maincom = dict_from_file["validcoms"][0] + if len(dict_from_file["validcoms"]) > 1: + comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') + else: + comaliases = [] + self.SpiceBot_Commands['commands'][command_type][maincom] = dict_from_file + else: + comaliases = validcoms + + for comalias in comaliases: + if comalias not in self.SpiceBot_Commands['commands'][command_type].keys(): + self.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor} + + +botcommands = BotCommandss() diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index f0567d6..43549f3 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -8,6 +8,7 @@ This module contains references only for other modules to utilize. from .Tools import * from .Logs import * +from .Commands import * from .Events import * from .Channels import * diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 4e8e340..8b7f2f7 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -8,6 +8,7 @@ import spicemanip from sopel_modules.SpiceBot.Tools import sopel_triggerargs, googlesearch, bot_privs, inlist, inlist_match, similar_list from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands @botevents.check_ready([botevents.BOT_LOADED, botevents.BOT_COMMANDSQUERY]) @@ -22,13 +23,13 @@ def bot_command_nick(bot, trigger): if triggercommand[0] == "?": return - if triggercommand in bot.memory['SpiceBot_CommandsQuery']['commands']["nickname"].keys(): + if triggercommand in botcommands.SpiceBot_Commands['commands']["nickname"].keys(): return triggerargs.insert(0, triggercommand) fulltrigger = spicemanip.main(triggerargs, 0).lower() - if fulltrigger in bot.memory['SpiceBot_CommandsQuery']['nickrules']: + if fulltrigger in botcommands.SpiceBot_Commands['nickrules']: return if fulltrigger.lower().startswith("what is"): @@ -155,7 +156,7 @@ def bot_command_nick(bot, trigger): else: - closestmatches = similar_list(bot, triggercommand, bot.memory['SpiceBot_CommandsQuery']['commands']["nickname"].keys(), 3, 'reverse') + closestmatches = similar_list(bot, triggercommand, botcommands.SpiceBot_Commands['commands']["nickname"].keys(), 3, 'reverse') if len(closestmatches): closestmatches = spicemanip.main(closestmatches, "andlist") diff --git a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py b/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py index 9677108..7d80719 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py +++ b/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py @@ -9,6 +9,7 @@ import os from sopel_modules.SpiceBot.Logs import botlogs from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands import spicemanip @@ -17,13 +18,6 @@ def setup(bot): botlogs.log('SpiceBot_CommandsQuery', "Starting setup procedure") botevents.startup_add([botevents.BOT_COMMANDSQUERY]) - if 'SpiceBot_CommandsQuery' not in bot.memory: - bot.memory['SpiceBot_CommandsQuery'] = {"counts": 0, "commands": {}, "nickrules": []} - - for comtype in ['module', 'nickname', 'rule']: - if comtype not in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): - bot.memory['SpiceBot_CommandsQuery']['commands'][comtype] = dict() - filepathlisting = [] # main Modules directory @@ -128,7 +122,7 @@ def setup(bot): currentsuccesslines += 1 if currentsuccesslines: - bot.memory['SpiceBot_CommandsQuery']['counts'] += 1 + botcommands.SpiceBot_Commands['counts'] += 1 if len(filelinelist): for atlinefound in filelinelist: @@ -148,19 +142,19 @@ def setup(bot): else: comaliases = [] - bot.memory['SpiceBot_CommandsQuery']['commands'][comtype][maincom] = dict_from_file + botcommands.SpiceBot_Commands['commands'][comtype][maincom] = dict_from_file for comalias in comaliases: - if comalias not in bot.memory['SpiceBot_CommandsQuery']['commands'][comtype].keys(): - bot.memory['SpiceBot_CommandsQuery']['commands'][comtype][comalias] = {"aliasfor": maincom} + if comalias not in botcommands.SpiceBot_Commands['commands'][comtype].keys(): + botcommands.SpiceBot_Commands['commands'][comtype][comalias] = {"aliasfor": maincom} for comtype in ['module', 'nickname', 'rule']: - botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(bot.memory['SpiceBot_CommandsQuery']['commands'][comtype].keys())) + " " + comtype + " commands.", True) + botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) - for command in bot.memory['SpiceBot_CommandsQuery']['commands']['rule'].keys(): + for command in botcommands.SpiceBot_Commands['commands']['rule'].keys(): if command.startswith("$nickname"): command = command.split("$nickname")[-1] - if command not in bot.memory['SpiceBot_CommandsQuery']['nickrules']: - bot.memory['SpiceBot_CommandsQuery']['nickrules'].append(command) + if command not in botcommands.SpiceBot_Commands['nickrules']: + botcommands.SpiceBot_Commands['nickrules'].append(command) botevents.trigger(bot, botevents.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery") @@ -174,22 +168,19 @@ def shutdown(bot): @sopel.module.rule('.*') def bot_events_complete(bot, trigger): - for comtype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): + for comtype in botcommands.SpiceBot_Commands['commands'].keys(): if comtype not in ['module', 'nickname', 'rule']: - botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(bot.memory['SpiceBot_CommandsQuery']['commands'][comtype].keys())) + " " + comtype + " commands.", True) + botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) def commandsquery_register(bot, command_type, validcoms, aliasfor=None): - if 'SpiceBot_CommandsQuery' not in bot.memory: - bot.memory['SpiceBot_CommandsQuery'] = {"counts": 0, "commands": {}, "nickrules": []} - if not isinstance(validcoms, list): validcoms = [validcoms] - if command_type not in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): - bot.memory['SpiceBot_CommandsQuery']['commands'][command_type] = dict() - bot.memory['SpiceBot_CommandsQuery']['counts'] += 1 + if command_type not in botcommands.SpiceBot_Commands['commands'].keys(): + botcommands.SpiceBot_Commands['commands'][command_type] = dict() + botcommands.SpiceBot_Commands['counts'] += 1 dict_from_file = dict() @@ -204,10 +195,10 @@ def commandsquery_register(bot, command_type, validcoms, aliasfor=None): comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') else: comaliases = [] - bot.memory['SpiceBot_CommandsQuery']['commands'][command_type][maincom] = dict_from_file + botcommands.SpiceBot_Commands['commands'][command_type][maincom] = dict_from_file else: comaliases = validcoms for comalias in comaliases: - if comalias not in bot.memory['SpiceBot_CommandsQuery']['commands'][command_type].keys(): - bot.memory['SpiceBot_CommandsQuery']['commands'][command_type][comalias] = {"aliasfor": aliasfor} + if comalias not in botcommands.SpiceBot_Commands['commands'][command_type].keys(): + botcommands.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor} diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index 9932600..3de378d 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -6,6 +6,7 @@ import sopel import sopel.module from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands from sopel_modules.SpiceBot.Tools import sopel_triggerargs, similar_list, letters_in_string @@ -30,9 +31,9 @@ def query_detection_nick(bot, trigger): return commands_list = dict() - for com in bot.memory['SpiceBot_CommandsQuery']['commands']['nickname'].keys(): + for com in botcommands.SpiceBot_Commands['commands']['nickname'].keys(): if com not in commands_list.keys(): - commands_list[com] = bot.memory['SpiceBot_CommandsQuery']['commands']['nickname'][com] + commands_list[com] = botcommands.SpiceBot_Commands['commands']['nickname'][com] if triggercommand.endswith("+"): diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index 794b006..01b7ca7 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -6,6 +6,7 @@ import sopel import sopel.module from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands from sopel_modules.SpiceBot.Tools import sopel_triggerargs, similar_list, letters_in_string @@ -26,11 +27,11 @@ def query_detection(bot, trigger): return commands_list = dict() - for commandstype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): + for commandstype in botcommands.SpiceBot_Commands['commands'].keys(): if commandstype not in ['rule', 'nickname']: - for com in bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype].keys(): + for com in botcommands.SpiceBot_Commands['commands'][commandstype].keys(): if com not in commands_list.keys(): - commands_list[com] = bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype][com] + commands_list[com] = botcommands.SpiceBot_Commands['commands'][commandstype][com] if triggercommand[:-1] == "+": diff --git a/sopel_modules/SpiceBot_CommandsQuery/__init__.py b/sopel_modules/SpiceBot_CommandsQuery/__init__.py index fcad5b8..3dffefa 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/__init__.py +++ b/sopel_modules/SpiceBot_CommandsQuery/__init__.py @@ -5,7 +5,6 @@ Sopel Commands Query responds to ? to display commands matching patterns """ from __future__ import unicode_literals, absolute_import, division, print_function -from .CommandsQuery import * from .QueryCommand import * from .NickQueryCommand import * diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index 2b3a25e..210c1e3 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -7,7 +7,7 @@ from sopel.config.types import StaticSection, ValidatedAttribute from sopel_modules.SpiceBot.Logs import botlogs from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot_CommandsQuery.CommandsQuery import commandsquery_register +from sopel_modules.SpiceBot.Commands import botcommands from sopel_modules.SpiceBot.Tools import read_directory_json_to_dict import spicemanip @@ -73,7 +73,7 @@ def setup(bot): 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(): - commandsquery_register(bot, "prefix", validgifapi) + botcommands.commandsquery_register(bot, "prefix", validgifapi) if validgifapi not in bot.memory["SpiceBot_GifSearch"]['cache'].keys(): bot.memory["SpiceBot_GifSearch"]['cache'][validgifapi] = dict() diff --git a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py index 732a976..895f466 100644 --- a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py +++ b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py @@ -6,6 +6,7 @@ import sopel.module from sopel_modules.SpiceBot.Tools import sopel_triggerargs from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands def setup(bot): @@ -21,8 +22,8 @@ def shutdown(bot): @sopel.module.event(botevents.BOT_LOADED) @sopel.module.rule('.*') def bot_events_complete(bot, trigger): - for comtype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): - bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(bot.memory['SpiceBot_CommandsQuery']['commands'][comtype].keys()) + for comtype in botcommands.SpiceBot_Commands['commands'].keys(): + bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(botcommands.SpiceBot_Commands['commands'][comtype].keys()) @botevents.check_ready([botevents.BOT_LOADED, botevents.BOT_COMMANDSQUERY]) diff --git a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py new file mode 100644 index 0000000..c7a59e9 --- /dev/null +++ b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py @@ -0,0 +1,168 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel +import sopel.module + +import os + +from sopel_modules.SpiceBot.Logs import botlogs +from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands + +import spicemanip + + +def setup(bot): + botlogs.log('SpiceBot_CommandsQuery', "Starting setup procedure") + botevents.startup_add([botevents.BOT_COMMANDSQUERY]) + + filepathlisting = [] + + # main Modules directory + main_dir = os.path.dirname(os.path.abspath(sopel.__file__)) + modules_dir = os.path.join(main_dir, 'modules') + filepathlisting.append(modules_dir) + + # Home Directory + home_modules_dir = os.path.join(bot.config.homedir, 'modules') + if os.path.isdir(home_modules_dir): + filepathlisting.append(home_modules_dir) + + # pypi installed + try: + import sopel_modules + for plugin_dir in set(sopel_modules.__path__): + for pathname in os.listdir(plugin_dir): + pypi_modules_dir = os.path.join(plugin_dir, pathname) + filepathlisting.append(pypi_modules_dir) + except Exception as e: + botlogs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) + + # Extra directories + filepathlist = [] + for directory in bot.config.core.extra: + filepathlisting.append(directory) + + for directory in filepathlisting: + for pathname in os.listdir(directory): + path = os.path.join(directory, pathname) + if (os.path.isfile(path) and path.endswith('.py') and not path.startswith('_')): + if pathname not in ["SpiceBot_dummycommand.py"]: + filepathlist.append(str(path)) + + # CoreTasks + ct_path = os.path.join(main_dir, 'coretasks.py') + filepathlist.append(ct_path) + + for modulefile in filepathlist: + + module_file_lines = [] + module_file = open(modulefile, 'r') + lines = module_file.readlines() + for line in lines: + module_file_lines.append(line) + module_file.close() + + dict_from_file = dict() + + detected_lines = [] + for line in module_file_lines: + + if str(line).startswith("@"): + line = str(line)[1:] + + if str(line).startswith(tuple(["commands", "module.commands", "sopel.module.commands"])): + line = str(line).split("commands")[-1] + line = "commands" + line + detected_lines.append(line) + elif str(line).startswith(tuple(["nickname_commands", "module.nickname_commands", "sopel.module.nickname_commands"])): + line = str(line).split("nickname_commands")[-1] + line = "nickname_commands" + line + detected_lines.append(line) + elif str(line).startswith(tuple(["rule", "module.rule", "sopel.module.rule"])): + line = str(line).split("rule")[-1] + line = "rule" + line + else: + line = None + + if line: + detected_lines.append(line) + + if len(detected_lines): + + filelinelist = [] + currentsuccesslines = 0 + for detected_line in detected_lines: + + # Commands + if str(detected_line).startswith("commands"): + comtype = "module" + validcoms = eval(str(detected_line).split("commands")[-1]) + elif str(detected_line).startswith("nickname_commands"): + comtype = "nickname" + validcoms = eval(str(detected_line).split("nickname_commands")[-1]) + elif str(detected_line).startswith("rule"): + comtype = "rule" + validcoms = eval(str(detected_line).split("rule")[-1]) + + if isinstance(validcoms, tuple): + validcoms = list(validcoms) + else: + validcoms = [validcoms] + for regexcom in ["(.*)", '^\?(.*)']: + if regexcom in validcoms: + while regexcom in validcoms: + validcoms.remove(regexcom) + + if len(validcoms): + validcomdict = {"comtype": comtype, "validcoms": validcoms} + filelinelist.append(validcomdict) + currentsuccesslines += 1 + + if currentsuccesslines: + botcommands.SpiceBot_Commands['counts'] += 1 + + if len(filelinelist): + for atlinefound in filelinelist: + + dict_from_file = dict() + + comtype = atlinefound["comtype"] + validcoms = atlinefound["validcoms"] + + # default command to filename + if "validcoms" not in dict_from_file.keys(): + dict_from_file["validcoms"] = validcoms + + maincom = dict_from_file["validcoms"][0] + if len(dict_from_file["validcoms"]) > 1: + comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') + else: + comaliases = [] + + botcommands.SpiceBot_Commands['commands'][comtype][maincom] = dict_from_file + for comalias in comaliases: + if comalias not in botcommands.SpiceBot_Commands['commands'][comtype].keys(): + botcommands.SpiceBot_Commands['commands'][comtype][comalias] = {"aliasfor": maincom} + + for comtype in ['module', 'nickname', 'rule']: + botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) + + for command in botcommands.SpiceBot_Commands['commands']['rule'].keys(): + if command.startswith("$nickname"): + command = command.split("$nickname")[-1] + if command not in botcommands.SpiceBot_Commands['nickrules']: + botcommands.SpiceBot_Commands['nickrules'].append(command) + + botevents.trigger(bot, botevents.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery") + + +@sopel.module.event(botevents.BOT_LOADED) +@sopel.module.rule('.*') +def bot_events_complete(bot, trigger): + + for comtype in botcommands.SpiceBot_Commands['commands'].keys(): + if comtype not in ['module', 'nickname', 'rule']: + botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) diff --git a/sopel_modules/SpiceBot_Module_Parsing/__init__.py b/sopel_modules/SpiceBot_Module_Parsing/__init__.py new file mode 100644 index 0000000..09f2208 --- /dev/null +++ b/sopel_modules/SpiceBot_Module_Parsing/__init__.py @@ -0,0 +1,10 @@ +# coding=utf8 +"""Parse module file information +""" +from __future__ import unicode_literals, absolute_import, division, print_function + +from .ModuleParsing import * + +__author__ = 'Sam Zick' +__email__ = 'sam@deathbybandaid.net' +__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py index 3cae22e..f613f50 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py @@ -6,6 +6,7 @@ import sopel.module from sopel_modules.SpiceBot.Logs import botlogs from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands @sopel.module.event(botevents.BOT_COMMANDSQUERY) @@ -13,9 +14,9 @@ from sopel_modules.SpiceBot.Events import botevents def bot_startup_monologue_commands(bot, trigger): availablecomsnum, availablecomsfiles = 0, 0 - for commandstype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): - availablecomsnum += len(bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype].keys()) - availablecomsfiles += bot.memory['SpiceBot_CommandsQuery']['counts'] + for commandstype in botcommands.SpiceBot_Commands['commands'].keys(): + availablecomsnum += len(botcommands.SpiceBot_Commands['commands'][commandstype].keys()) + availablecomsfiles += botcommands.SpiceBot_Commands['counts'] bot.memory['SpiceBot_StartupMonologue'].append("There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") botlogs.log('SpiceBot_StartupMonologue', "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.")