From 509e9862219a53ddad1dc53fbe7e3aeb12a5aa3a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 23 Feb 2022 14:21:28 -0500 Subject: [PATCH] test --- sopel_SpiceBot_Core_Prerun/__init__.py | 6 --- sopel_SpiceBot_Core_Prerun/command_args.py | 15 ------ sopel_SpiceBot_Core_Prerun/dispatch_multi.py | 27 ----------- sopel_SpiceBot_Core_Prerun/rule_match.py | 49 -------------------- 4 files changed, 97 deletions(-) delete mode 100644 sopel_SpiceBot_Core_Prerun/command_args.py delete mode 100644 sopel_SpiceBot_Core_Prerun/dispatch_multi.py delete mode 100644 sopel_SpiceBot_Core_Prerun/rule_match.py diff --git a/sopel_SpiceBot_Core_Prerun/__init__.py b/sopel_SpiceBot_Core_Prerun/__init__.py index 4c511e9..22bebb7 100644 --- a/sopel_SpiceBot_Core_Prerun/__init__.py +++ b/sopel_SpiceBot_Core_Prerun/__init__.py @@ -3,12 +3,7 @@ import functools from sopel_SpiceBot_Core_1 import sb from .comrun import ComRun -# from .clean_trigger import clean_trigger -# from .validate_command import validate_command -# from .dispatch_multi import dispatch_multi from .pipe_split import rebuild_pipes -# from .command_args import command_args -# from .rule_match import rule_match def prerun(rulematch=False): @@ -46,7 +41,6 @@ def prerun(rulematch=False): trigger_command = sb.commands.get_command_from_trigger(trigger) if trigger_command != commands[0]["trigger_command"]: trigger_dict = rebuild_pipes(commands) - print(trigger_dict) sb.commands.dispatch(trigger_dict) return diff --git a/sopel_SpiceBot_Core_Prerun/command_args.py b/sopel_SpiceBot_Core_Prerun/command_args.py deleted file mode 100644 index cf1258a..0000000 --- a/sopel_SpiceBot_Core_Prerun/command_args.py +++ /dev/null @@ -1,15 +0,0 @@ -import functools - - -def command_args(): - """This Detects --arguments to commands.""" - - def actual_decorator(function): - - @functools.wraps(function) - def internal_command_args(bot, trigger, comrun, *args, **kwargs): - - function(bot, trigger, comrun, *args, **kwargs) - - return internal_command_args - return actual_decorator diff --git a/sopel_SpiceBot_Core_Prerun/dispatch_multi.py b/sopel_SpiceBot_Core_Prerun/dispatch_multi.py deleted file mode 100644 index 53a1e64..0000000 --- a/sopel_SpiceBot_Core_Prerun/dispatch_multi.py +++ /dev/null @@ -1,27 +0,0 @@ -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: - comrun.trigger_dict = commands[0] - function(bot, trigger, comrun, *args, **kwargs) - else: - for trigger_dict in commands: - sb.commands.dispatch(trigger_dict) - - return internal_dispatch_multi - return actual_decorator diff --git a/sopel_SpiceBot_Core_Prerun/rule_match.py b/sopel_SpiceBot_Core_Prerun/rule_match.py deleted file mode 100644 index f713372..0000000 --- a/sopel_SpiceBot_Core_Prerun/rule_match.py +++ /dev/null @@ -1,49 +0,0 @@ -import functools - -from sopel_SpiceBot_Core_1 import sb - - -def rule_match(): - """This Detects --arguments to commands.""" - - def actual_decorator(function): - - @functools.wraps(function) - def internal_rule_match(bot, trigger, comrun, *args, **kwargs): - - returnfunc = True - - # Applies to non-command rule matching - if comrun.rulematch: - - first_full_trigger_str = trigger.args[1] - - if comrun.trigger_dict["trigger_type"] == "command": - commands_list = sb.commands.valid_sopel_commands - first_trigger_noprefix = first_full_trigger_str[1:] - first_trigger_command = first_trigger_noprefix.split(" ")[0] - - elif comrun.trigger_dict["trigger_type"] == "nickname_command": - commands_list = sb.commands.valid_sopel_nickname_commands - first_trigger_noprefix = " ".join(first_full_trigger_str.split(" ")[1:]) - first_trigger_command = first_trigger_noprefix.split(" ")[0] - - elif comrun.trigger_dict["trigger_type"] == "action_command": - commands_list = sb.commands.valid_sopel_action_commands - first_trigger_noprefix = first_full_trigger_str - first_trigger_command = first_trigger_noprefix.split(" ")[0] - - # Ignore if the command was caught - # handle if the command was triggered with && or | too close to the command - if comrun.trigger_dict["trigger_command"] in commands_list: - if first_trigger_command != comrun.trigger_dict["trigger_command"]: - sb.commands.dispatch(comrun.trigger_dict) - returnfunc = False - else: - returnfunc = False - - if returnfunc: - function(bot, trigger, comrun, *args, **kwargs) - - return internal_rule_match - return actual_decorator