This commit is contained in:
deathbybandaid 2022-02-22 10:32:40 -05:00
parent 6170d930fc
commit c5e9d8f23c

View File

@ -8,7 +8,7 @@ class ComRun():
pass
def dispatch():
def dispatch_multi():
"""
This splits the given command by `&&` and re-dispatches it internally to the bot.
"""
@ -16,7 +16,7 @@ def dispatch():
def actual_decorator(function):
@functools.wraps(function)
def internal_dispatch(bot, trigger, *args, **kwargs):
def internal_dispatch_multi(bot, trigger, *args, **kwargs):
bot.say("dispatch")
@ -31,7 +31,30 @@ def dispatch():
function(bot, trigger, *args, **kwargs)
return internal_dispatch
return internal_dispatch_multi
return actual_decorator
def dispatch_pipes():
"""
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_dispatch_pipe(bot, trigger, *args, **kwargs):
bot.say("dispatch")
# Get list of trigger command(s)
pipes = get_pipes(bot, trigger)
bot.say(str(pipes))
function(bot, trigger, *args, **kwargs)
return internal_dispatch_pipe
return actual_decorator
@ -56,8 +79,9 @@ def prerun():
def actual_decorator(function):
@dispatch()
@command_args()
@dispatch_pipes()
@dispatch_multi()
# @command_args()
@functools.wraps(function)
def internal_prerun(bot, trigger, *args, **kwargs):
@ -72,6 +96,17 @@ def prerun():
return actual_decorator
def get_pipes(bot, trigger):
# Get && split for multiple commands
if "|" in trigger.args[1]:
pipes = [x.strip() for x in trigger.args[1].split("|")]
else:
pipes = [trigger.args[1]]
return pipes
def get_commands(bot, trigger):
commands = []