From b2a7c5e3caafa7f56666808ab1f0029d04d6c3ff Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Mon, 13 May 2019 14:37:29 -0400 Subject: [PATCH] don't load asterisk regex --- .../SpiceBot_CommandsQuery/CommandsQuery.py | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py b/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py index 548d746..31ac4ed 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py +++ b/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py @@ -97,9 +97,9 @@ def setup(bot): detected_lines.append(line) if len(detected_lines): - bot.memory['SpiceBot_CommandsQuery']['counts'] += 1 filelinelist = [] + currentsuccesslines = 0 for detected_line in detected_lines: # Commands @@ -117,31 +117,40 @@ def setup(bot): validcoms = list(validcoms) else: validcoms = [validcoms] + if "(.*)" in validcoms: + while "(.*)" in validcoms: + validcoms.remove("(.*)") - validcomdict = {"comtype": comtype, "validcoms": validcoms} - filelinelist.append(validcomdict) + if len(validcoms): + validcomdict = {"comtype": comtype, "validcoms": validcoms} + filelinelist.append(validcomdict) + currentsuccesslines += 1 - for atlinefound in filelinelist: + if currentsuccesslines: + bot.memory['SpiceBot_CommandsQuery']['counts'] += 1 - dict_from_file = dict() + if len(filelinelist): + for atlinefound in filelinelist: - comtype = atlinefound["comtype"] - validcoms = atlinefound["validcoms"] + dict_from_file = dict() - # default command to filename - if "validcoms" not in dict_from_file.keys(): - dict_from_file["validcoms"] = validcoms + comtype = atlinefound["comtype"] + validcoms = atlinefound["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 = [] + # default command to filename + if "validcoms" not in dict_from_file.keys(): + dict_from_file["validcoms"] = validcoms - bot.memory['SpiceBot_CommandsQuery']['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} + maincom = dict_from_file["validcoms"][0] + if len(dict_from_file["validcoms"]) > 1: + comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') + else: + comaliases = [] + + bot.memory['SpiceBot_CommandsQuery']['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} for comtype in ['module', 'nickname', 'rule']: bot_logging(bot, 'SpiceBot_CommandsQuery', "Found " + str(len(bot.memory['SpiceBot_CommandsQuery']['commands'][comtype].keys())) + " " + comtype + " commands.", True)