more descriptive errors

This commit is contained in:
deathbybandaid 2019-05-13 12:59:59 -04:00
parent 59ee2f41f5
commit 2a92b4679f

View File

@ -30,29 +30,34 @@ def query_detection(bot, trigger):
return return
if triggercommand.endswith("+"): if triggercommand.endswith("+"):
triggercommand = triggercommand[:-1] triggercommand = triggercommand[:-1]
if not triggercommand or not len(triggercommand): if not triggercommand or not len(triggercommand):
return return
if triggercommand not in commands_list.keys():
triggercommand += "?" if triggercommand not in commands_list.keys():
else: closestmatches = similar_list(bot, triggercommand, commands_list.keys(), 10, 'reverse')
realcom = triggercommand dispmsg = ["Cannot find any alias commands: No valid commands match " + str(triggercommand) + ".",
if "aliasfor" in commands_list[triggercommand].keys(): "The following commands match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + "."]
realcom = commands_list[triggercommand]["aliasfor"] bot.notice(dispmsg, trigger.nick)
validcomlist = commands_list[realcom]["validcoms"] return
if not len(validcomlist):
bot.notice("No commands match " + str(triggercommand) + ".", trigger.nick) realcom = triggercommand
else: if "aliasfor" in commands_list[triggercommand].keys():
bot.notice("The following commands match " + str(triggercommand) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick) realcom = commands_list[triggercommand]["aliasfor"]
return validcomlist = commands_list[realcom]["validcoms"]
bot.notice("The following commands match " + str(triggercommand) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick)
return
if triggercommand.endswith("?"): if triggercommand.endswith("?"):
triggercommand = triggercommand[:-1] triggercommand = triggercommand[:-1]
if not triggercommand or not len(triggercommand): if not triggercommand or not len(triggercommand):
return return
closestmatches = similar_list(bot, triggercommand, commands_list.keys(), 10, 'reverse') closestmatches = similar_list(bot, triggercommand, commands_list.keys(), 10, 'reverse')
if not len(closestmatches): if not len(closestmatches):
bot.notice("No commands match " + str(triggercommand) + ".", trigger.nick) bot.notice("Cannot find any similar commands for " + str(triggercommand) + ".", trigger.nick)
else: else:
bot.notice("The following commands may match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick) bot.notice("The following commands may match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick)
return return
@ -63,6 +68,6 @@ def query_detection(bot, trigger):
commandlist.append(command) commandlist.append(command)
if not len(commandlist): if not len(commandlist):
bot.notice("No commands match " + str(triggercommand) + ".", trigger.nick) bot.notice("No commands start with " + str(triggercommand) + ".", trigger.nick)
else: else:
bot.notice("The following commands match " + str(triggercommand) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick) bot.notice("The following commands start with " + str(triggercommand) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick)