CommonClient: Move command marker to last_autofillable_command (#4907)

* handle autocomplete command when press question

* fix test

* add docstring to get_input_text_from_response

* fix line lenght
This commit is contained in:
Jérémie Bolduc
2025-10-04 23:39:30 -04:00
committed by GitHub
parent a2460b7fe7
commit f07fea2771
3 changed files with 17 additions and 8 deletions

View File

@@ -721,13 +721,22 @@ def get_intended_text(input_text: str, possible_answers) -> typing.Tuple[str, bo
def get_input_text_from_response(text: str, command: str) -> typing.Optional[str]:
"""
Parses the response text from `get_intended_text` to find the suggested input and autocomplete the command in
arguments with it.
:param text: The response text from `get_intended_text`.
:param command: The command to which the input text should be added. Must contain the prefix used by the command
(`!` or `/`).
:return: The command with the suggested input text appended, or None if no suggestion was found.
"""
if "did you mean " in text:
for question in ("Didn't find something that closely matches",
"Too many close matches"):
if text.startswith(question):
name = get_text_between(text, "did you mean '",
"'? (")
return f"!{command} {name}"
return f"{command} {name}"
elif text.startswith("Missing: "):
return text.replace("Missing: ", "!hint_location ")
return None