Compare commits

..

2 Commits

Author SHA1 Message Date
deathbybandaid
f7473abd5e test 2022-02-23 14:15:40 -05:00
deathbybandaid
73da4fbe2a test 2022-02-23 14:13:04 -05:00
3 changed files with 15 additions and 39 deletions

View File

@ -6,7 +6,7 @@ from .comrun import ComRun
# from .clean_trigger import clean_trigger
# from .validate_command import validate_command
# from .dispatch_multi import dispatch_multi
# from .pipe_split import pipe_split
from .pipe_split import rebuild_pipes
# from .command_args import command_args
# from .rule_match import rule_match
@ -39,13 +39,21 @@ def prerun(rulematch=False):
sb.commands.dispatch(commands[0])
return
# Get list of trigger command(s) by | split
commands = sb.commands.get_commands_split(trigger, "|")
# Validate | split
trigger_command = sb.commands.get_command_from_trigger(trigger)
if trigger_command != commands[0]["trigger_command"]:
trigger_dict = rebuild_pipes(commands)
print(trigger_dict)
sb.commands.dispatch(trigger_dict)
return
# This is where we rebuild trigger
# we validate a few things here
# trigger = clean_trigger(bot, trigger, commands[0])
# Get list of trigger command(s) by | split
commands = sb.commands.get_commands_split(trigger, "|")
# Now we have a single valid command
# we are going to validate the command
# as a && or | attached to a command

View File

@ -5,3 +5,4 @@ class ComRun():
def __init__(self, rulematch, trigger):
self.rulematch = rulematch
self.original_trigger = trigger
self.trigger_dict = {}

View File

@ -1,39 +1,6 @@
import functools
from sopel_SpiceBot_Core_1 import sb
def pipe_split():
"""
This splits the given command by `|` and re-dispatches it internally to the bot.
This allows the output of a command to be sent
"""
def actual_decorator(function):
@functools.wraps(function)
def internal_pipe_split(bot, trigger, comrun, *args, **kwargs):
# Get list of trigger command(s)
pipes = sb.commands.get_commands_split(trigger, "|")
comrun.trigger_dict = pipes[0]
del pipes[0]
if len(pipes):
comrun.piped = True
function(bot, trigger, comrun, *args, **kwargs)
if len(pipes):
repipe_trigger_dict = reassemble_pipes(pipes, comrun.say)
sb.commands.dispatch(repipe_trigger_dict)
return internal_pipe_split
return actual_decorator
def reassemble_pipes(pipes, comrunsay):
def rebuild_pipes(pipes):
first_pipe = pipes[0]
del pipes[0]
@ -46,7 +13,7 @@ def reassemble_pipes(pipes, comrunsay):
"trigger_sender": first_pipe["trigger_sender"]
}
repipe_trigger_dict["trigger_str"] += " %s" % comrunsay
repipe_trigger_dict["trigger_str"] += " | "
for trigger_dict in pipes:
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"])