SpiceBot/sopel_SpiceBot_Core_Prerun/pipe_split.py
deathbybandaid 3d5e5af76b test
2022-02-22 11:03:30 -05:00

38 lines
880 B
Python

import functools
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):
bot.say("pipe_split")
# Get list of trigger command(s)
pipes = get_pipes(bot, trigger)
bot.say(str(pipes))
function(bot, trigger, comrun, *args, **kwargs)
print(comrun.test)
return internal_pipe_split
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