Compare commits
No commits in common. "f7473abd5eade23cf696656bd64f5d7067a40811" and "e1faf1341c79ab7acc0cd9ae7b3a6a61be4ab137" have entirely different histories.
f7473abd5e
...
e1faf1341c
@ -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 rebuild_pipes
|
||||
# from .pipe_split import pipe_split
|
||||
# from .command_args import command_args
|
||||
# from .rule_match import rule_match
|
||||
|
||||
@ -39,21 +39,13 @@ 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
|
||||
|
||||
@ -5,4 +5,3 @@ class ComRun():
|
||||
def __init__(self, rulematch, trigger):
|
||||
self.rulematch = rulematch
|
||||
self.original_trigger = trigger
|
||||
self.trigger_dict = {}
|
||||
|
||||
@ -1,6 +1,39 @@
|
||||
import functools
|
||||
|
||||
from sopel_SpiceBot_Core_1 import sb
|
||||
|
||||
|
||||
def rebuild_pipes(pipes):
|
||||
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):
|
||||
first_pipe = pipes[0]
|
||||
del pipes[0]
|
||||
|
||||
@ -13,7 +46,7 @@ def rebuild_pipes(pipes):
|
||||
"trigger_sender": first_pipe["trigger_sender"]
|
||||
}
|
||||
|
||||
repipe_trigger_dict["trigger_str"] += " | "
|
||||
repipe_trigger_dict["trigger_str"] += " %s" % comrunsay
|
||||
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"])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user