From 85af5aa89df3fdc0b49758fecaac2c2a1944d1f1 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Mon, 13 May 2019 10:31:51 -0400 Subject: [PATCH] debug coding --- .../SpiceBot_CommandsQuery/CommandsQuery.py | 21 +++++++++++++++++-- .../SpiceBot_CommandsQuery/QueryCommand.py | 16 +++++++------- sopel_modules/SpiceBot_SBTools/__init__.py | 3 +++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py b/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py index 548d746..51b4d10 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py +++ b/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py @@ -18,7 +18,7 @@ def setup(bot): bot_events_startup_register(bot, ['2002']) if 'SpiceBot_CommandsQuery' not in bot.memory: - bot.memory['SpiceBot_CommandsQuery'] = {"counts": 0, "commands": {}, "nickrules": []} + bot.memory['SpiceBot_CommandsQuery'] = {"counts": 0, 'commands_all': {}, "commands": {}, "nickrules": []} for comtype in ['module', 'nickname', 'rule']: if comtype not in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): @@ -152,6 +152,15 @@ def setup(bot): if command not in bot.memory['SpiceBot_CommandsQuery']['nickrules']: bot.memory['SpiceBot_CommandsQuery']['nickrules'].append(command) + for commandstype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): + if commandstype != 'rule': + for com in bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype].keys(): + if com not in bot.memory['SpiceBot_CommandsQuery']['commands_all'].keys(): + if commandstype == 'nickname': + bot.memory['SpiceBot_CommandsQuery']['commands_all'][str(bot.nick) + " " + com] = bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype][com] + else: + bot.memory['SpiceBot_CommandsQuery']['commands_all'][com] = bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype][com] + bot_events_trigger(bot, 2002, "SpiceBot_CommandsQuery") @@ -173,7 +182,7 @@ def bot_events_complete(bot, trigger): def commandsquery_register(bot, command_type, validcoms, aliasfor=None): if 'SpiceBot_CommandsQuery' not in bot.memory: - bot.memory['SpiceBot_CommandsQuery'] = {"counts": 0, "commands": {}, "nickrules": []} + bot.memory['SpiceBot_CommandsQuery'] = {"counts": 0, 'commands_all': {}, "commands": {}, "nickrules": []} if not isinstance(validcoms, list): validcoms = [validcoms] @@ -203,6 +212,14 @@ def commandsquery_register(bot, command_type, validcoms, aliasfor=None): if comalias not in bot.memory['SpiceBot_CommandsQuery']['commands'][command_type].keys(): bot.memory['SpiceBot_CommandsQuery']['commands'][command_type][comalias] = {"aliasfor": aliasfor} + for comalias in comaliases: + if command_type != 'rule': + if comalias not in bot.memory['SpiceBot_CommandsQuery']['commands_all'].keys(): + if command_type == 'nickname': + bot.memory['SpiceBot_CommandsQuery']['commands_all'][str(bot.nick) + " " + comalias] = bot.memory['SpiceBot_CommandsQuery']['commands'][command_type][comalias] + else: + bot.memory['SpiceBot_CommandsQuery']['commands_all'][comalias] = bot.memory['SpiceBot_CommandsQuery']['commands'][command_type][comalias] + @sopel.module.event('2002') @sopel.module.rule('.*') diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index 727783e..ed3cefd 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -9,6 +9,8 @@ from difflib import SequenceMatcher from operator import itemgetter from sopel_modules.SpiceBot_Events.System import bot_events_check +from sopel_modules.SpiceBot_SBTools import sopel_triggerargs + import spicemanip @@ -19,15 +21,11 @@ def query_detection(bot, trigger): while not bot_events_check(bot, '2002'): pass - commands_list = dict() - for commandstype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): - if commandstype != 'rule': - for com in bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype].keys(): - if com not in commands_list.keys(): - if commandstype == 'nickname': - commands_list[str(bot.nick) + " " + com] = bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype][com] - else: - commands_list[com] = bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype][com] + commands_list = bot.memory['SpiceBot_CommandsQuery']['commands_all'] + + triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'query_command') + bot.say(str(triggerargs)) + bot.say(str(triggercommand)) triggerargsarray = spicemanip.main(trigger, 'create') diff --git a/sopel_modules/SpiceBot_SBTools/__init__.py b/sopel_modules/SpiceBot_SBTools/__init__.py index fb4054b..22d5ea6 100644 --- a/sopel_modules/SpiceBot_SBTools/__init__.py +++ b/sopel_modules/SpiceBot_SBTools/__init__.py @@ -47,6 +47,9 @@ def sopel_triggerargs(bot, trigger, command_type='module_command'): if command_type in ['nickname_command']: command = spicemanip.main(triggerargs, 2).lower() triggerargs = spicemanip.main(triggerargs, '3+', 'list') + elif command_type in ['query_command']: + command = spicemanip.main(triggerargs, 1).lower()[1:] + triggerargs = spicemanip.main(triggerargs, '2+', 'list') else: command = spicemanip.main(triggerargs, 1).lower()[1:] triggerargs = spicemanip.main(triggerargs, '2+', 'list')