This commit is contained in:
deathbybandaid 2022-07-06 11:47:12 -04:00
parent 8792ff352d
commit 72b93df3f4

View File

@ -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,22 +65,25 @@ 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))
# Don't be annoying when /me is conversation and not a command
# if comrun.command_type == "action_command":
return
# Run function
if runfunc:
# At this point, we update the re.match for trigger
trigger = rebuild_trigger(comrun, function)
# Run function
function(bot, trigger, comrun, *args, **kwargs)
# If not piping the replies into pipe, let'sprint to IRC now
@ -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)