test
This commit is contained in:
parent
a103b2231b
commit
4826c6fe7f
@ -149,69 +149,71 @@ class Commands():
|
|||||||
|
|
||||||
for full_trigger_str in triggers:
|
for full_trigger_str in triggers:
|
||||||
|
|
||||||
if full_trigger_str.startswith(tuple(self.config.prefix_list)):
|
if not full_trigger_str.isspace():
|
||||||
trigger_type = "command"
|
|
||||||
trigger_prefix = full_trigger_str[0]
|
|
||||||
trigger_noprefix = full_trigger_str[1:]
|
|
||||||
trigger_command = trigger_noprefix.split(" ")[0]
|
|
||||||
trigger_str = " ".join(trigger_noprefix.split(" ")[1:])
|
|
||||||
elif full_trigger_str.startswith(self.bot.nick):
|
|
||||||
trigger_type = "nickname_command"
|
|
||||||
trigger_prefix = str(full_trigger_str.split(" ")[0])
|
|
||||||
trigger_noprefix = " ".join(full_trigger_str.split(" ")[1:])
|
|
||||||
trigger_command = trigger_noprefix.split(" ")[0]
|
|
||||||
trigger_str = " ".join(trigger_noprefix.split(" ")[1:])
|
|
||||||
elif full_trigger_str.startswith(tuple(["ACTION", "/me"])):
|
|
||||||
trigger_type = "action_command"
|
|
||||||
trigger_prefix = "ACTION"
|
|
||||||
trigger_noprefix = full_trigger_str
|
|
||||||
trigger_command = trigger_noprefix.split(" ")[0]
|
|
||||||
trigger_str = " ".join(trigger_noprefix.split(" ")[1:])
|
|
||||||
else:
|
|
||||||
trigger_command = full_trigger_str.split(" ")[0]
|
|
||||||
trigger_str = " ".join(full_trigger_str.split(" ")[1:])
|
|
||||||
|
|
||||||
command_types = ["command", "nickname_command", "action_command"]
|
if full_trigger_str.startswith(tuple(self.config.prefix_list)):
|
||||||
# Assume same command type until proven otherwise
|
trigger_type = "command"
|
||||||
assumed_trigger_type = first_trigger_type
|
trigger_prefix = full_trigger_str[0]
|
||||||
assumed_trigger_prefix = first_trigger_prefix
|
trigger_noprefix = full_trigger_str[1:]
|
||||||
|
trigger_command = trigger_noprefix.split(" ")[0]
|
||||||
# Still under the assumption that the command is most likely the same type as first command
|
trigger_str = " ".join(trigger_noprefix.split(" ")[1:])
|
||||||
command_types.remove(assumed_trigger_type)
|
elif full_trigger_str.startswith(self.bot.nick):
|
||||||
command_types.insert(0, assumed_trigger_type)
|
trigger_type = "nickname_command"
|
||||||
|
trigger_prefix = str(full_trigger_str.split(" ")[0])
|
||||||
found = []
|
trigger_noprefix = " ".join(full_trigger_str.split(" ")[1:])
|
||||||
for command_type in command_types:
|
trigger_command = trigger_noprefix.split(" ")[0]
|
||||||
|
trigger_str = " ".join(trigger_noprefix.split(" ")[1:])
|
||||||
if command_type == "command":
|
elif full_trigger_str.startswith(tuple(["ACTION", "/me"])):
|
||||||
commands_list = self.valid_sopel_commands
|
trigger_type = "action_command"
|
||||||
elif command_type == "nickname_command":
|
trigger_prefix = "ACTION"
|
||||||
commands_list = self.valid_sopel_nickname_commands
|
trigger_noprefix = full_trigger_str
|
||||||
elif command_type == "action_command":
|
trigger_command = trigger_noprefix.split(" ")[0]
|
||||||
commands_list = self.valid_sopel_action_commands
|
trigger_str = " ".join(trigger_noprefix.split(" ")[1:])
|
||||||
|
|
||||||
if trigger_command in commands_list:
|
|
||||||
found.append(command_type)
|
|
||||||
|
|
||||||
if len(found):
|
|
||||||
trigger_type = found[0]
|
|
||||||
if trigger_type == "command":
|
|
||||||
trigger_prefix = self.config.prefix_list[0]
|
|
||||||
elif trigger_type == "nickname_command":
|
|
||||||
trigger_prefix = "%s," % self.bot.nick
|
|
||||||
elif trigger_type == "action_command":
|
|
||||||
trigger_prefix = "ACTION"
|
|
||||||
else:
|
else:
|
||||||
trigger_type = assumed_trigger_type
|
trigger_command = full_trigger_str.split(" ")[0]
|
||||||
trigger_prefix = assumed_trigger_prefix
|
trigger_str = " ".join(full_trigger_str.split(" ")[1:])
|
||||||
|
|
||||||
commands.append({
|
command_types = ["command", "nickname_command", "action_command"]
|
||||||
"trigger_type": trigger_type,
|
# Assume same command type until proven otherwise
|
||||||
"trigger_prefix": trigger_prefix,
|
assumed_trigger_type = first_trigger_type
|
||||||
"trigger_str": trigger_str,
|
assumed_trigger_prefix = first_trigger_prefix
|
||||||
"trigger_command": trigger_command,
|
|
||||||
"trigger_hostmask": trigger.hostmask,
|
# Still under the assumption that the command is most likely the same type as first command
|
||||||
"trigger_sender": trigger.sender
|
command_types.remove(assumed_trigger_type)
|
||||||
})
|
command_types.insert(0, assumed_trigger_type)
|
||||||
|
|
||||||
|
found = []
|
||||||
|
for command_type in command_types:
|
||||||
|
|
||||||
|
if command_type == "command":
|
||||||
|
commands_list = self.valid_sopel_commands
|
||||||
|
elif command_type == "nickname_command":
|
||||||
|
commands_list = self.valid_sopel_nickname_commands
|
||||||
|
elif command_type == "action_command":
|
||||||
|
commands_list = self.valid_sopel_action_commands
|
||||||
|
|
||||||
|
if trigger_command in commands_list:
|
||||||
|
found.append(command_type)
|
||||||
|
|
||||||
|
if len(found):
|
||||||
|
trigger_type = found[0]
|
||||||
|
if trigger_type == "command":
|
||||||
|
trigger_prefix = self.config.prefix_list[0]
|
||||||
|
elif trigger_type == "nickname_command":
|
||||||
|
trigger_prefix = "%s," % self.bot.nick
|
||||||
|
elif trigger_type == "action_command":
|
||||||
|
trigger_prefix = "ACTION"
|
||||||
|
else:
|
||||||
|
trigger_type = assumed_trigger_type
|
||||||
|
trigger_prefix = assumed_trigger_prefix
|
||||||
|
|
||||||
|
commands.append({
|
||||||
|
"trigger_type": trigger_type,
|
||||||
|
"trigger_prefix": trigger_prefix,
|
||||||
|
"trigger_str": trigger_str,
|
||||||
|
"trigger_command": trigger_command,
|
||||||
|
"trigger_hostmask": trigger.hostmask,
|
||||||
|
"trigger_sender": trigger.sender
|
||||||
|
})
|
||||||
|
|
||||||
return commands
|
return commands
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user