From e4abb21e8f409ab12aef13ecf186432fb47b7232 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 5 May 2022 13:00:02 -0400 Subject: [PATCH] test --- sopel_SpiceBot_Core_Prerun/__init__.py | 49 +++++++++++++++------ sopel_SpiceBot_Runtime_Commands/__init__.py | 1 + 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/sopel_SpiceBot_Core_Prerun/__init__.py b/sopel_SpiceBot_Core_Prerun/__init__.py index e01e787..c02fae8 100644 --- a/sopel_SpiceBot_Core_Prerun/__init__.py +++ b/sopel_SpiceBot_Core_Prerun/__init__.py @@ -61,6 +61,11 @@ def prerun(): if not comrun.is_pipe_command: for say_message in comrun._say: bot.say(say_message) + # Pipe text back to bot for next piped command + else: + for say_message in comrun._say: + trigger_dict = rebuild_pipes(comrun.commands, say_message) + sb.commands.dispatch(trigger_dict) return internal_prerun return actual_decorator @@ -73,29 +78,45 @@ def rebuild_trigger(comrun, function): return trigger -def rebuild_pipes(commands): +def rebuild_pipes(commands, trigger_str_add=None): - repipe_trigger_dict = commands[0] + if not trigger_str_add: + repipe_trigger_dict = commands[0] + else: + repipe_trigger_dict = "" + trigger_number = 1 for trigger_dict in commands[1:]: + if trigger_str_add and trigger_number == 1: + trigger_str = trigger_dict["trigger_str"] + " %s" % trigger_str_add + else: + trigger_str = trigger_dict["trigger_str"] + + if trigger_str_add: + splitkey_str = "" + else: + splitkey_str = " %s " % sb.commands.pipe_split_key + if trigger_dict["trigger_type"] == "command": - repipe_trigger_dict["trigger_str"] += " %s %s%s %s" % (sb.commands.pipe_split_key, - trigger_dict["trigger_prefix"], - trigger_dict["trigger_command"], - trigger_dict["trigger_str"]) + repipe_trigger_dict["trigger_str"] += "%s%s%s %s" % (splitkey_str, + trigger_dict["trigger_prefix"], + trigger_dict["trigger_command"], + trigger_str) elif trigger_dict["trigger_type"] == "nickname_command": - repipe_trigger_dict["trigger_str"] += " %s %s %s %s" % (sb.commands.pipe_split_key, - trigger_dict["trigger_prefix"], - trigger_dict["trigger_command"], - trigger_dict["trigger_str"]) + repipe_trigger_dict["trigger_str"] += "%s%s %s %s" % (splitkey_str, + trigger_dict["trigger_prefix"], + trigger_dict["trigger_command"], + trigger_str) elif trigger_dict["trigger_type"] == "action_command": - repipe_trigger_dict["trigger_str"] += " %s %s %s %s" % (sb.commands.pipe_split_key, - "/me", - trigger_dict["trigger_command"], - trigger_dict["trigger_str"]) + repipe_trigger_dict["trigger_str"] += "%s%s %s %s" % (splitkey_str, + "/me", + trigger_dict["trigger_command"], + trigger_str) + + trigger_number += 1 return repipe_trigger_dict diff --git a/sopel_SpiceBot_Runtime_Commands/__init__.py b/sopel_SpiceBot_Runtime_Commands/__init__.py index 0a1a93b..64e43f0 100644 --- a/sopel_SpiceBot_Runtime_Commands/__init__.py +++ b/sopel_SpiceBot_Runtime_Commands/__init__.py @@ -15,6 +15,7 @@ def commands_output_a(bot, trigger, comrun): @plugin.command('testob') def commands_output_b(bot, trigger, comrun): comrun.say("this is test b") + comrun.say(str(comrun.trigger).upper()) @prerun()