This commit is contained in:
deathbybandaid 2022-02-24 10:55:57 -05:00
parent 0d34f8ad85
commit 075ee19039
2 changed files with 33 additions and 20 deletions

View File

@ -9,6 +9,16 @@ class Commands():
self.bot = None self.bot = None
self.config = config self.config = config
@property
def multi_split_key(self):
# TODO config
return "&&"
@property
def pipe_split_key(self):
# TODO config
return "|"
@property @property
def valid_sopel_commands(self): def valid_sopel_commands(self):
found = [] found = []

View File

@ -22,7 +22,7 @@ def prerun():
sb.commands.dispatch(trigger_dict) sb.commands.dispatch(trigger_dict)
return 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 # so we will now redispatch to help get the correct function passed
if comrun.has_command_been_sanitized: if comrun.has_command_been_sanitized:
if comrun.is_pipe_command: if comrun.is_pipe_command:
@ -52,17 +52,20 @@ def rebuild_pipes(commands):
for trigger_dict in commands[1:]: for trigger_dict in commands[1:]:
if trigger_dict["trigger_type"] == "command": if trigger_dict["trigger_type"] == "command":
repipe_trigger_dict["trigger_str"] += " | %s%s %s" % (trigger_dict["trigger_prefix"], 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_command"],
trigger_dict["trigger_str"]) trigger_dict["trigger_str"])
elif trigger_dict["trigger_type"] == "nickname_command": elif trigger_dict["trigger_type"] == "nickname_command":
repipe_trigger_dict["trigger_str"] += " | %s %s %s" % (trigger_dict["trigger_prefix"], 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_command"],
trigger_dict["trigger_str"]) trigger_dict["trigger_str"])
elif trigger_dict["trigger_type"] == "action_command": elif trigger_dict["trigger_type"] == "action_command":
repipe_trigger_dict["trigger_str"] += " | %s %s %s" % ("/me", repipe_trigger_dict["trigger_str"] += " %s %s %s %s" % (sb.commands.pipe_split_key,
"/me",
trigger_dict["trigger_command"], trigger_dict["trigger_command"],
trigger_dict["trigger_str"]) trigger_dict["trigger_str"])
@ -89,34 +92,34 @@ class ComRun():
@property @property
def is_multi_command(self): 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 True
return False return False
@property @property
def is_pipe_command(self): 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 True
return False return False
@property @property
def multi_split_count(self): def multi_split_count(self):
if "&&" in self.trigger.args[1]: if self.is_multi_command:
return len([x.strip() for x in self.trigger.args[1].split("&&")]) return len([x.strip() for x in self.trigger.args[1].split(sb.commands.multi_split_key)])
return "N/A" return "N/A"
@property @property
def pipe_split_count(self): def pipe_split_count(self):
if "|" in self.trigger.args[1]: if self.is_pipe_command:
return len([x.strip() for x in self.trigger.args[1].split("|")]) return len([x.strip() for x in self.trigger.args[1].split(sb.commands.pipe_split_key)])
return "N/A" return "N/A"
@property @property
def commands(self): def commands(self):
if "&&" in self.trigger.args[1]: if self.is_multi_command:
return sb.commands.get_commands_split(self.trigger, "&&") return sb.commands.get_commands_split(self.trigger, sb.commands.multi_split_key)
elif "|" in self.trigger.args[1]: elif self.is_pipe_command:
return sb.commands.get_commands_split(self.trigger, "|") return sb.commands.get_commands_split(self.trigger, sb.commands.pipe_split_key)
else: else:
return sb.commands.get_commands_nosplit(self.trigger) return sb.commands.get_commands_nosplit(self.trigger)