From 8ad0e98e9eb0773646ece3f051c9ee4bd8a03594 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 15:44:00 -0400 Subject: [PATCH] invalid command detection --- sopel_modules/SpiceBot_AI/AI_aiml.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index c3bf735..417f261 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -25,6 +25,18 @@ def bot_command_rule(bot, trigger): # ignore text coming from a valid prefix if str(message).startswith(tuple(bot.config.core.prefix_list)): + trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'module') + commands_list = [] + for commandstype in SpiceBot.commands.dict['commands'].keys(): + if commandstype not in ['rule', 'nickname']: + for com in SpiceBot.commands.dict['commands'][commandstype].keys(): + if com not in commands_list: + commands_list.append(com) + if trigger_command not in commands_list: + invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"] + invalid_display.append("If you have a suggestion for this command, you can run .feature ." + str(trigger_command)) + invalid_display.append("ADD DESCRIPTION HERE!") + bot.osd(invalid_display, trigger.nick, 'notice') return if str(message).lower().startswith(str(bot.nick).lower()):