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.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 = []

View File

@ -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)