29 lines
825 B
Python
29 lines
825 B
Python
import functools
|
|
|
|
from sopel_SpiceBot_Core_1 import sb
|
|
|
|
|
|
def dispatch_multi():
|
|
"""
|
|
This splits the given command by `&&` and re-dispatches it internally to the bot.
|
|
"""
|
|
|
|
def actual_decorator(function):
|
|
|
|
@functools.wraps(function)
|
|
def internal_dispatch_multi(bot, trigger, comrun, *args, **kwargs):
|
|
|
|
# Get list of trigger command(s)
|
|
commands = sb.commands.get_commands_split(trigger, "&&")
|
|
|
|
if len(commands) == 1:
|
|
function(bot, trigger, comrun, *args, **kwargs)
|
|
comrun.trigger_dict = commands[0]
|
|
else:
|
|
for trigger_dict in commands:
|
|
sb.commands.dispatch(trigger_dict)
|
|
comrun.continuerun = False
|
|
|
|
return internal_dispatch_multi
|
|
return actual_decorator
|