diff --git a/sopel_SpiceBot_Core_Prerun/__init__.py b/sopel_SpiceBot_Core_Prerun/__init__.py index af3f4be..053a94a 100644 --- a/sopel_SpiceBot_Core_Prerun/__init__.py +++ b/sopel_SpiceBot_Core_Prerun/__init__.py @@ -4,17 +4,19 @@ from .comrun import comrun_create from .dispatch_multi import dispatch_multi from .pipe_split import pipe_split from .command_args import command_args +from .rule_match import rule_match -def prerun(): +def prerun(rulematch=False): """This decorator is the hub of handling for all SpiceBot Commands""" def actual_decorator(function): - @comrun_create() + @comrun_create(rulematch) @dispatch_multi() @pipe_split() @command_args() + @rule_match() @functools.wraps(function) def internal_prerun(bot, trigger, comrun, *args, **kwargs): diff --git a/sopel_SpiceBot_Core_Prerun/comrun.py b/sopel_SpiceBot_Core_Prerun/comrun.py index 2bbec81..8f0973e 100644 --- a/sopel_SpiceBot_Core_Prerun/comrun.py +++ b/sopel_SpiceBot_Core_Prerun/comrun.py @@ -3,8 +3,9 @@ import functools class ComRun(): - def __init__(self): + def __init__(self, rulematch): self.piped = False + self.rulematch = rulematch self.say = "" self.trigger_dict = { "trigger_type": None, @@ -16,7 +17,7 @@ class ComRun(): } -def comrun_create(): +def comrun_create(rulematch): """This Detects --arguments to commands.""" def actual_decorator(function): @@ -25,6 +26,7 @@ def comrun_create(): def internal_comrun_create(bot, trigger, *args, **kwargs): comrun = ComRun() + comrun.rulematch = rulematch function(bot, trigger, comrun, *args, **kwargs) diff --git a/sopel_SpiceBot_Core_Prerun/rule_match.py b/sopel_SpiceBot_Core_Prerun/rule_match.py new file mode 100644 index 0000000..eaa1d67 --- /dev/null +++ b/sopel_SpiceBot_Core_Prerun/rule_match.py @@ -0,0 +1,16 @@ +import functools + + +def rule_match(): + """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) + bot.say(str(comrun.rulematch)) + + return internal_command_args + return actual_decorator diff --git a/sopel_SpiceBot_Runtime_Unmatched_Commands/__init__.py b/sopel_SpiceBot_Runtime_Unmatched_Commands/__init__.py index 31b2bc8..9d8f6f6 100644 --- a/sopel_SpiceBot_Runtime_Unmatched_Commands/__init__.py +++ b/sopel_SpiceBot_Runtime_Unmatched_Commands/__init__.py @@ -4,7 +4,7 @@ from sopel import plugin from sopel_SpiceBot_Core_Prerun import prerun -@prerun() +@prerun(rulematch=True) @plugin.command('(.*)') def rule_command(bot, trigger, comrun): bot.say("%s" % trigger.raw)