From 4dd78b6755a4276206ed2a2a667c0dbc1244607a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 22 Feb 2022 12:45:29 -0500 Subject: [PATCH] test --- .../SBCore/commands/__init__.py | 26 +++++++++---------- sopel_SpiceBot_Core_Prerun/__init__.py | 3 +++ sopel_SpiceBot_Core_Prerun/command_args.py | 3 +++ sopel_SpiceBot_Core_Prerun/comrun.py | 3 ++- sopel_SpiceBot_Core_Prerun/dispatch_multi.py | 4 +-- sopel_SpiceBot_Core_Prerun/pipe_split.py | 14 +++++----- 6 files changed, 30 insertions(+), 23 deletions(-) diff --git a/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py b/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py index 15a9c17..bb95d30 100644 --- a/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py +++ b/sopel_SpiceBot_Core_1/SBCore/commands/__init__.py @@ -69,37 +69,37 @@ class Commands(): }) return commands_list - def dispatch(self, bot, trigger_dict): + def dispatch(self, trigger_dict): if trigger_dict["trigger_type"] == "command": - return self.dispatch_command(bot, trigger_dict) + return self.dispatch_command(trigger_dict) elif trigger_dict["trigger_type"] == "nickname_command": - return self.dispatch_nickname_command(bot, trigger_dict) + return self.dispatch_nickname_command(trigger_dict) elif trigger_dict["trigger_type"] == "action_command": - return self.dispatch_action_command(bot, trigger_dict) + return self.dispatch_action_command(trigger_dict) - def dispatch_command(self, bot, trigger_dict): + def dispatch_command(self, trigger_dict): pretrigger = PreTrigger( - bot.nick, + self.bot.nick, ":%s %s %s :%s%s" % (trigger_dict["trigger_hostmask"], "PRIVMSG", trigger_dict["trigger_sender"], trigger_dict["trigger_prefix"], trigger_dict["trigger_str"]) ) - bot.dispatch(pretrigger) + self.bot.dispatch(pretrigger) - def dispatch_nickname_command(self, bot, trigger_dict): + def dispatch_nickname_command(self, trigger_dict): pretrigger = PreTrigger( - bot.nick, + self.bot.nick, ":%s %s %s :%s %s" % (trigger_dict["trigger_hostmask"], "PRIVMSG", trigger_dict["trigger_sender"], trigger_dict["trigger_prefix"], trigger_dict["trigger_str"]) ) - bot.dispatch(pretrigger) + self.bot.dispatch(pretrigger) - def dispatch_action_command(self, bot, trigger_dict): + def dispatch_action_command(self, trigger_dict): pretrigger = PreTrigger( - bot.nick, + self.bot.nick, ":%s %s %s :%s%s %s%s" % (trigger_dict["trigger_hostmask"], "PRIVMSG", trigger_dict["trigger_sender"], "\x01", "ACTION", trigger_dict["trigger_str"], "\x01") ) - bot.dispatch(pretrigger) + self.bot.dispatch(pretrigger) def get_commands_split(self, trigger, splitkey): commands = [] diff --git a/sopel_SpiceBot_Core_Prerun/__init__.py b/sopel_SpiceBot_Core_Prerun/__init__.py index 7806b9d..6efd535 100644 --- a/sopel_SpiceBot_Core_Prerun/__init__.py +++ b/sopel_SpiceBot_Core_Prerun/__init__.py @@ -18,6 +18,9 @@ def prerun(): @functools.wraps(function) def internal_prerun(bot, trigger, comrun, *args, **kwargs): + if not comrun.continuerun: + return + function(bot, trigger, comrun, *args, **kwargs) bot.say(comrun.say) diff --git a/sopel_SpiceBot_Core_Prerun/command_args.py b/sopel_SpiceBot_Core_Prerun/command_args.py index cf1258a..1c13401 100644 --- a/sopel_SpiceBot_Core_Prerun/command_args.py +++ b/sopel_SpiceBot_Core_Prerun/command_args.py @@ -9,6 +9,9 @@ def command_args(): @functools.wraps(function) def internal_command_args(bot, trigger, comrun, *args, **kwargs): + if not comrun.continuerun: + return + 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 7755e8e..bac2c8c 100644 --- a/sopel_SpiceBot_Core_Prerun/comrun.py +++ b/sopel_SpiceBot_Core_Prerun/comrun.py @@ -2,8 +2,9 @@ import functools class ComRun(): + def __init__(self): - pass + self.continuerun = True def comrun_create(): diff --git a/sopel_SpiceBot_Core_Prerun/dispatch_multi.py b/sopel_SpiceBot_Core_Prerun/dispatch_multi.py index 8f96c76..ed50ed2 100644 --- a/sopel_SpiceBot_Core_Prerun/dispatch_multi.py +++ b/sopel_SpiceBot_Core_Prerun/dispatch_multi.py @@ -21,8 +21,8 @@ def dispatch_multi(): comrun.trigger_dict = commands[0] else: for trigger_dict in commands: - sb.commands.dispatch(bot, trigger_dict) - return + sb.commands.dispatch(trigger_dict) + comrun.continuerun = False 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 38f94ea..42e3476 100644 --- a/sopel_SpiceBot_Core_Prerun/pipe_split.py +++ b/sopel_SpiceBot_Core_Prerun/pipe_split.py @@ -14,20 +14,20 @@ def pipe_split(): @functools.wraps(function) def internal_pipe_split(bot, trigger, comrun, *args, **kwargs): + if not comrun.continuerun: + return + # Get list of trigger command(s) pipes = sb.commands.get_commands_split(trigger, "|") comrun.trigger_dict = pipes[0] + del pipes[0] - if len(pipes) == 1: - function(bot, trigger, comrun, *args, **kwargs) - else: - del pipes[0] - - function(bot, trigger, comrun, *args, **kwargs) + function(bot, trigger, comrun, *args, **kwargs) + if len(pipes) > 1: repipe_trigger_dict = reassemble_pipes(pipes, comrun.say) - sb.commands.dispatch(bot, repipe_trigger_dict) + sb.commands.dispatch(repipe_trigger_dict) return return internal_pipe_split