From 72b93df3f4e70e9d6ca511a73eaa93aa1826867c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 6 Jul 2022 11:47:12 -0400 Subject: [PATCH] test --- sopel_SpiceBot_Core_Prerun/__init__.py | 28 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/sopel_SpiceBot_Core_Prerun/__init__.py b/sopel_SpiceBot_Core_Prerun/__init__.py index 39c6d67..38d0948 100644 --- a/sopel_SpiceBot_Core_Prerun/__init__.py +++ b/sopel_SpiceBot_Core_Prerun/__init__.py @@ -14,6 +14,8 @@ def prerun(metadata={}): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): + runfunc = True + comrun = ComRun(bot, trigger, function, metadata) # Check that nick has the correct bot or channel privileges @@ -56,10 +58,6 @@ def prerun(metadata={}): if comrun.is_catchall and not comrun.is_real_command: valid_command_results = sb.commands.search_similar_commands(comrun.command["trigger_command"]) - # Don't be annoying when /me is conversation and not a command - if comrun.command_type == "action_command": - return - # Handling for invalid nickname commands if comrun.command_type == "nickname_command": if not len(valid_command_results): @@ -67,23 +65,26 @@ def prerun(metadata={}): (comrun.command["trigger_command"], " %s" % comrun.command["trigger_str"] if comrun.command["trigger_str"] != "" else "")) else: comrun.osd("%s does not appear to be a valid command. Possible Matches: %s" % (comrun.command["trigger_command"], valid_command_results)) - return # normal prefixed command handling - if comrun.command_type == "command": + elif comrun.command_type == "command": # warn that a command is not valid if not len(valid_command_results): comrun.osd("%s does not appear to be a valid command." % comrun.command["trigger_command"]) else: comrun.osd("%s does not appear to be a valid command. Possible Matches: %s" % (comrun.command["trigger_command"], valid_command_results)) - return - # At this point, we update the re.match for trigger - trigger = rebuild_trigger(comrun, function) + # Don't be annoying when /me is conversation and not a command + # if comrun.command_type == "action_command": + return # Run function - function(bot, trigger, comrun, *args, **kwargs) + if runfunc: + # At this point, we update the re.match for trigger + trigger = rebuild_trigger(comrun, function) + + function(bot, trigger, comrun, *args, **kwargs) # If not piping the replies into pipe, let'sprint to IRC now if not comrun.is_pipe_command: @@ -217,6 +218,13 @@ class ComRun(): return True return False + @property + def author(self): + author = "deathbybandaid" + if "author" in list(self.metadata.keys()): + author = self.metadata["author"] + return author + @property def is_real_command(self): return sb.commands.is_real_command(self.command)