|
|
|
@ -183,8 +183,8 @@ class Plugin:
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def __save_question(self, question, match, preamble):
|
|
|
|
|
content = question[len(match):].strip()
|
|
|
|
|
def __save_question(self, question, matched, preamble):
|
|
|
|
|
content = question[len(matched):].strip()
|
|
|
|
|
content = content.rstrip("?").rstrip()
|
|
|
|
|
question = Question(preamble, content)
|
|
|
|
|
self.question = question
|
|
|
|
@ -228,23 +228,23 @@ class Plugin:
|
|
|
|
|
# If no_content is False (default), simply compare the parsed
|
|
|
|
|
# identifier with available identifiers.
|
|
|
|
|
if no_content:
|
|
|
|
|
match = lambda pc, ai: (
|
|
|
|
|
matches = lambda pc, ai: (
|
|
|
|
|
pc.raw == ai or pc.raw.startswith(ai + " ")
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
match = lambda pc, ai: pc.ident == ai
|
|
|
|
|
matches = lambda pc, ai: pc.ident == ai
|
|
|
|
|
# First case: the command identifier has been used.
|
|
|
|
|
if match(parsed_command, ident):
|
|
|
|
|
if matches(parsed_command, ident):
|
|
|
|
|
parsed_command.ident = ident
|
|
|
|
|
parsed_command.match = ident
|
|
|
|
|
parsed_command.matched = ident
|
|
|
|
|
self.__save_command(parsed_command)
|
|
|
|
|
return True
|
|
|
|
|
# Second case: an alias of the identifier has been used.
|
|
|
|
|
ident_aliases = aliases.get(ident, [])
|
|
|
|
|
for alias in ident_aliases:
|
|
|
|
|
if match(parsed_command, alias):
|
|
|
|
|
if matches(parsed_command, alias):
|
|
|
|
|
parsed_command.ident = ident
|
|
|
|
|
parsed_command.match = alias
|
|
|
|
|
parsed_command.matched = alias
|
|
|
|
|
self.__save_command(parsed_command)
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
@ -313,4 +313,4 @@ class Command:
|
|
|
|
|
# Raw command content (minus name and suffix), always set.
|
|
|
|
|
raw: str
|
|
|
|
|
# Identifier matched, possibly an alias. Set only when matched.
|
|
|
|
|
match: str = ""
|
|
|
|
|
matched: str = ""
|
|
|
|
|