From 075ee190394cf8fc7d214651843a63e892ae28ec Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 24 Feb 2022 10:55:57 -0500 Subject: [PATCH] test --- .../SBCore/commands/__init__.py | 10 +++++ sopel_SpiceBot_Core_Prerun/__init__.py | 43 ++++++++++--------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py b/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py index fa0b232..50cbacc 100644 --- a/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py +++ b/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py @@ -9,6 +9,16 @@ class Commands(): self.bot = None self.config = config + @property + def multi_split_key(self): + # TODO config + return "&&" + + @property + def pipe_split_key(self): + # TODO config + return "|" + @property def valid_sopel_commands(self): found = [] diff --git a/sopel_SpiceBot_Core_Prerun/__init__.py b/sopel_SpiceBot_Core_Prerun/__init__.py index 37c11fd..e1dc94a 100644 --- a/sopel_SpiceBot_Core_Prerun/__init__.py +++ b/sopel_SpiceBot_Core_Prerun/__init__.py @@ -22,7 +22,7 @@ def prerun(): sb.commands.dispatch(trigger_dict) return - # If the original trigger is not the same after && or | split + # If the original trigger is not the same after splits # so we will now redispatch to help get the correct function passed if comrun.has_command_been_sanitized: if comrun.is_pipe_command: @@ -52,19 +52,22 @@ def rebuild_pipes(commands): for trigger_dict in commands[1:]: if trigger_dict["trigger_type"] == "command": - repipe_trigger_dict["trigger_str"] += " | %s%s %s" % (trigger_dict["trigger_prefix"], - trigger_dict["trigger_command"], - trigger_dict["trigger_str"]) + repipe_trigger_dict["trigger_str"] += " %s %s%s %s" % (sb.commands.pipe_split_key, + trigger_dict["trigger_prefix"], + trigger_dict["trigger_command"], + trigger_dict["trigger_str"]) elif trigger_dict["trigger_type"] == "nickname_command": - repipe_trigger_dict["trigger_str"] += " | %s %s %s" % (trigger_dict["trigger_prefix"], - trigger_dict["trigger_command"], - trigger_dict["trigger_str"]) + repipe_trigger_dict["trigger_str"] += " %s %s %s %s" % (sb.commands.pipe_split_key, + trigger_dict["trigger_prefix"], + trigger_dict["trigger_command"], + trigger_dict["trigger_str"]) elif trigger_dict["trigger_type"] == "action_command": - repipe_trigger_dict["trigger_str"] += " | %s %s %s" % ("/me", - trigger_dict["trigger_command"], - trigger_dict["trigger_str"]) + repipe_trigger_dict["trigger_str"] += " %s %s %s %s" % (sb.commands.pipe_split_key, + "/me", + trigger_dict["trigger_command"], + trigger_dict["trigger_str"]) return repipe_trigger_dict @@ -89,34 +92,34 @@ class ComRun(): @property def is_multi_command(self): - if "&&" in self.trigger.args[1]: + if sb.commands.multi_split_key in self.trigger.args[1]: return True return False @property def is_pipe_command(self): - if "|" in self.trigger.args[1]: + if sb.commands.pipe_split_key in self.trigger.args[1]: return True return False @property def multi_split_count(self): - if "&&" in self.trigger.args[1]: - return len([x.strip() for x in self.trigger.args[1].split("&&")]) + if self.is_multi_command: + return len([x.strip() for x in self.trigger.args[1].split(sb.commands.multi_split_key)]) return "N/A" @property def pipe_split_count(self): - if "|" in self.trigger.args[1]: - return len([x.strip() for x in self.trigger.args[1].split("|")]) + if self.is_pipe_command: + return len([x.strip() for x in self.trigger.args[1].split(sb.commands.pipe_split_key)]) return "N/A" @property def commands(self): - if "&&" in self.trigger.args[1]: - return sb.commands.get_commands_split(self.trigger, "&&") - elif "|" in self.trigger.args[1]: - return sb.commands.get_commands_split(self.trigger, "|") + if self.is_multi_command: + return sb.commands.get_commands_split(self.trigger, sb.commands.multi_split_key) + elif self.is_pipe_command: + return sb.commands.get_commands_split(self.trigger, sb.commands.pipe_split_key) else: return sb.commands.get_commands_nosplit(self.trigger)