This commit is contained in:
deathbybandaid 2022-02-24 15:00:31 -05:00
parent c02dfb656d
commit c25d6a32da

View File

@ -114,9 +114,7 @@ class Commands():
return pretrigger
def get_command_from_trigger(self, trigger):
commstring = trigger.args[1]
if commstring.startswith(tuple(self.config.prefix_list)):
command = commstring[1:].split(" ")[0]
elif commstring.startswith(self.bot.nick):
@ -125,7 +123,6 @@ class Commands():
command = commstring.split(" ")[0]
else:
command = ""
return command
def what_command_type(self, trigger):
@ -148,10 +145,7 @@ class Commands():
elif trigger_dict["trigger_type"] == "action_command":
commands_list = self.valid_sopel_action_commands
if trigger_dict["trigger_command"] in commands_list:
return True
else:
return False
return (trigger_dict["trigger_command"] in commands_list)
def is_catchall(self, function, command_type):
"""Determine if function could be called with a rule match"""
@ -174,20 +168,19 @@ class Commands():
commands = []
first_full_trigger_str = trigger.args[1]
if first_full_trigger_str.startswith(tuple(self.config.prefix_list)):
first_trigger_type = "command"
first_trigger_type = self.what_command_type(trigger)
if first_trigger_type == "command":
first_trigger_prefix = first_full_trigger_str[0]
first_trigger_noprefix = first_full_trigger_str[1:]
first_trigger_command = first_trigger_noprefix.split(" ")[0]
first_trigger_str = " ".join([x.strip() for x in first_trigger_noprefix.split(" ")[1:]])
elif first_full_trigger_str.startswith(self.bot.nick):
first_trigger_type = "nickname_command"
elif first_trigger_type == "nickname_command":
first_trigger_prefix = str(first_full_trigger_str.split(" ")[0])
first_trigger_noprefix = " ".join(first_full_trigger_str.split(" ")[1:])
first_trigger_command = first_trigger_noprefix.split(" ")[0]
first_trigger_str = " ".join([x.strip() for x in first_trigger_noprefix.split(" ")[1:]])
elif "intent" in trigger.tags and trigger.tags["intent"] == "ACTION":
first_trigger_type = "action_command"
elif first_trigger_type == "action_command":
first_trigger_prefix = "ACTION"
first_trigger_noprefix = first_full_trigger_str
first_trigger_command = first_trigger_noprefix.split(" ")[0]
@ -222,20 +215,19 @@ class Commands():
first_full_trigger_str = triggers[0]
if first_full_trigger_str.startswith(tuple(self.config.prefix_list)):
first_trigger_type = "command"
first_trigger_type = self.what_command_type(trigger)
if first_trigger_type == "command":
first_trigger_prefix = first_full_trigger_str[0]
first_trigger_noprefix = first_full_trigger_str[1:]
first_trigger_command = first_trigger_noprefix.split(" ")[0]
first_trigger_str = " ".join([x.strip() for x in first_trigger_noprefix.split(" ")[1:]])
elif first_full_trigger_str.startswith(self.bot.nick):
first_trigger_type = "nickname_command"
elif first_trigger_type == "nickname_command":
first_trigger_prefix = str(first_full_trigger_str.split(" ")[0])
first_trigger_noprefix = " ".join(first_full_trigger_str.split(" ")[1:])
first_trigger_command = first_trigger_noprefix.split(" ")[0]
first_trigger_str = " ".join([x.strip() for x in first_trigger_noprefix.split(" ")[1:]])
elif "intent" in trigger.tags and trigger.tags["intent"] == "ACTION":
first_trigger_type = "action_command"
elif first_trigger_type == "action_command":
first_trigger_prefix = "ACTION"
first_trigger_noprefix = first_full_trigger_str
first_trigger_command = first_trigger_noprefix.split(" ")[0]
@ -250,8 +242,8 @@ class Commands():
commands.append({
"trigger_type": first_trigger_type,
"trigger_prefix": first_trigger_prefix,
"trigger_str": first_trigger_str.replace(splitkey, ""),
"trigger_command": first_trigger_command.replace(splitkey, ""),
"trigger_str": first_trigger_str,
"trigger_command": first_trigger_command,
"trigger_hostmask": trigger.hostmask,
"trigger_sender": trigger.sender,
"trigger_time": str(trigger.time)