debug coding

This commit is contained in:
deathbybandaid 2019-05-13 10:31:51 -04:00
parent ff7ed67bba
commit 85af5aa89d
3 changed files with 29 additions and 11 deletions

View File

@ -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('.*')

View File

@ -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')

View File

@ -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')