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