Update loader.py

pull/2/head
Who? 2024-09-13 23:53:38 +07:00 committed by GitHub
parent 94f58adfac
commit bbb4f33230
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 36 additions and 0 deletions

View File

@ -1276,3 +1276,39 @@ class LoaderMod(loader.Module):
file,
caption=text,
)
def _format_result(
self,
result: dict,
query: str,
no_translate: bool = False,
) -> str:
commands = "\n".join([
f"▫️ <code>{utils.escape_html(self.get_prefix())}{utils.escape_html(cmd)}</code>:"
f" <b>{utils.escape_html(cmd_doc)}</b>"
for cmd, cmd_doc in result["module"]["commands"].items()
])
kwargs = {
"name": utils.escape_html(result["module"]["name"]),
"dev": utils.escape_html(result["module"]["dev"]),
"commands": commands,
"cls_doc": utils.escape_html(result["module"]["cls_doc"]),
"mhash": result["module"]["hash"],
"query": utils.escape_html(query),
"prefix": utils.escape_html(self.get_prefix()),
}
strings = (
self.strings.get("result", "en")
if self.config["translate"] and not no_translate
else self.strings("result")
)
text = strings.format(**kwargs)
if len(text) > 1980:
kwargs["commands"] = "..."
text = strings.format(**kwargs)
return text