From 2023e4e1bb36fde7a5b7078db64599bdf66bb22d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 23 Feb 2022 14:59:21 -0500 Subject: [PATCH] test --- .../SBCore/commands/__init__.py | 17 +++++++++++++++++ sopel_SpiceBot_Core_Prerun/__init__.py | 3 +++ 2 files changed, 20 insertions(+) diff --git a/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py b/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py index a9c872a..0ac3533 100644 --- a/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py +++ b/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py @@ -104,7 +104,9 @@ class Commands(): return pretrigger def get_command_from_trigger(self, trigger): + commstring = trigger.args[1] + if commstring.startswith(tuple(self.config.prefix_list)): command = commstring[1:].split(" ")[0] elif commstring.startswith(self.bot.nick): @@ -113,8 +115,23 @@ class Commands(): command = commstring.split(" ")[0] else: command = "" + return command + def is_real_command(self, trigger_dict): + + if trigger_dict["trigger_type"] == "command": + commands_list = self.valid_sopel_commands + elif trigger_dict["trigger_type"] == "nickname_command": + commands_list = self.valid_sopel_nickname_commands + elif trigger_dict["trigger_type"] == "action_command": + commands_list = self.valid_sopel_action_commands + + if trigger_dict["trigger_command"] in commands_list: + return True + else: + return False + def get_commands_split(self, trigger, splitkey): commands = [] diff --git a/sopel_SpiceBot_Core_Prerun/__init__.py b/sopel_SpiceBot_Core_Prerun/__init__.py index 22bebb7..4762907 100644 --- a/sopel_SpiceBot_Core_Prerun/__init__.py +++ b/sopel_SpiceBot_Core_Prerun/__init__.py @@ -44,6 +44,9 @@ def prerun(rulematch=False): sb.commands.dispatch(trigger_dict) return + if rulematch and sb.commands.is_real_command(commands[0]["trigger_command"]): + return + # This is where we rebuild trigger # we validate a few things here # trigger = clean_trigger(bot, trigger, commands[0])