From a2569cab86177cc90ac0a0a7ad6ad3109011c74f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 22 Feb 2022 12:31:14 -0500 Subject: [PATCH] test --- sopel_SpiceBot_Core_Prerun/__init__.py | 4 ++-- sopel_SpiceBot_Core_Prerun/command_args.py | 2 -- sopel_SpiceBot_Core_Prerun/comrun.py | 1 - sopel_SpiceBot_Core_Prerun/dispatch_multi.py | 10 ++++------ sopel_SpiceBot_Core_Prerun/pipe_split.py | 18 ++++++------------ sopel_SpiceBot_Runtime_Commands/__init__.py | 4 ++-- 6 files changed, 14 insertions(+), 25 deletions(-) diff --git a/sopel_SpiceBot_Core_Prerun/__init__.py b/sopel_SpiceBot_Core_Prerun/__init__.py index 8385b1b..7806b9d 100644 --- a/sopel_SpiceBot_Core_Prerun/__init__.py +++ b/sopel_SpiceBot_Core_Prerun/__init__.py @@ -18,9 +18,9 @@ def prerun(): @functools.wraps(function) def internal_prerun(bot, trigger, comrun, *args, **kwargs): - bot.say("prerun") - function(bot, trigger, comrun, *args, **kwargs) + bot.say(comrun.say) + return internal_prerun return actual_decorator diff --git a/sopel_SpiceBot_Core_Prerun/command_args.py b/sopel_SpiceBot_Core_Prerun/command_args.py index 9995db3..cf1258a 100644 --- a/sopel_SpiceBot_Core_Prerun/command_args.py +++ b/sopel_SpiceBot_Core_Prerun/command_args.py @@ -9,8 +9,6 @@ def command_args(): @functools.wraps(function) def internal_command_args(bot, trigger, comrun, *args, **kwargs): - bot.say("command_args") - function(bot, trigger, comrun, *args, **kwargs) return internal_command_args diff --git a/sopel_SpiceBot_Core_Prerun/comrun.py b/sopel_SpiceBot_Core_Prerun/comrun.py index c945532..7755e8e 100644 --- a/sopel_SpiceBot_Core_Prerun/comrun.py +++ b/sopel_SpiceBot_Core_Prerun/comrun.py @@ -14,7 +14,6 @@ def comrun_create(): @functools.wraps(function) def internal_comrun_create(bot, trigger, *args, **kwargs): - bot.say("comrun_create") comrun = ComRun() function(bot, trigger, comrun, *args, **kwargs) diff --git a/sopel_SpiceBot_Core_Prerun/dispatch_multi.py b/sopel_SpiceBot_Core_Prerun/dispatch_multi.py index 3a54157..8f96c76 100644 --- a/sopel_SpiceBot_Core_Prerun/dispatch_multi.py +++ b/sopel_SpiceBot_Core_Prerun/dispatch_multi.py @@ -13,18 +13,16 @@ def dispatch_multi(): @functools.wraps(function) def internal_dispatch_multi(bot, trigger, comrun, *args, **kwargs): - bot.say("dispatch_multi") - # Get list of trigger command(s) commands = sb.commands.get_commands_split(trigger, "&&") - # If more than 1 trigger command, dispatch - if len(commands) > 1: + if len(commands) == 1: + function(bot, trigger, comrun, *args, **kwargs) + comrun.trigger_dict = commands[0] + else: for trigger_dict in commands: sb.commands.dispatch(bot, trigger_dict) return - function(bot, trigger, comrun, *args, **kwargs) - return internal_dispatch_multi return actual_decorator diff --git a/sopel_SpiceBot_Core_Prerun/pipe_split.py b/sopel_SpiceBot_Core_Prerun/pipe_split.py index aa90ecf..38f94ea 100644 --- a/sopel_SpiceBot_Core_Prerun/pipe_split.py +++ b/sopel_SpiceBot_Core_Prerun/pipe_split.py @@ -14,27 +14,21 @@ def pipe_split(): @functools.wraps(function) def internal_pipe_split(bot, trigger, comrun, *args, **kwargs): - bot.say("pipe_split") - # Get list of trigger command(s) pipes = sb.commands.get_commands_split(trigger, "|") + comrun.trigger_dict = pipes[0] + if len(pipes) == 1: function(bot, trigger, comrun, *args, **kwargs) else: - # for trigger_dict in commands: - # sb.commands.dispatch(bot, trigger, trigger_dict) - # return - - # first_pipe = pipes[0] del pipes[0] function(bot, trigger, comrun, *args, **kwargs) repipe_trigger_dict = reassemble_pipes(pipes, comrun.say) sb.commands.dispatch(bot, repipe_trigger_dict) - - bot.say(comrun.say) + return return internal_pipe_split return actual_decorator @@ -56,10 +50,10 @@ def reassemble_pipes(pipes, comrunsay): 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" % (trigger_dict["trigger_prefix"], trigger_dict["trigger_str"]) + repipe_trigger_dict["trigger_str"] += " | %s%s %s" % (trigger_dict["trigger_prefix"], trigger_dict["trigger_command"], trigger_dict["trigger_str"]) elif trigger_dict["trigger_type"] == "nickname_command": - repipe_trigger_dict["trigger_str"] += " | %s %s" % (trigger_dict["trigger_prefix"], trigger_dict["trigger_str"]) + repipe_trigger_dict["trigger_str"] += " | %s %s %s" % (trigger_dict["trigger_prefix"], trigger_dict["trigger_command"], trigger_dict["trigger_str"]) elif trigger_dict["trigger_type"] == "action_command": - repipe_trigger_dict["trigger_str"] += " | %s %s" % ("/me", trigger_dict["trigger_str"]) + repipe_trigger_dict["trigger_str"] += " | %s %s %s" % ("/me", trigger_dict["trigger_command"], trigger_dict["trigger_str"]) return repipe_trigger_dict diff --git a/sopel_SpiceBot_Runtime_Commands/__init__.py b/sopel_SpiceBot_Runtime_Commands/__init__.py index 757ea96..cb7bb24 100644 --- a/sopel_SpiceBot_Runtime_Commands/__init__.py +++ b/sopel_SpiceBot_Runtime_Commands/__init__.py @@ -8,13 +8,13 @@ from sopel_SpiceBot_Core_Prerun import prerun @prerun() @plugin.command('pipea') def pipea(bot, trigger, comrun): - comrun.say = "this is a test" + comrun.say = str(comrun.trigger_dict["trigger_str"]) @prerun() @plugin.command('pipeb') def pipeb(bot, trigger, comrun): - comrun.say = str(trigger.args[1]).upper() + comrun.say = str(comrun.trigger_dict["trigger_str"]).upper() @prerun()