diff --git a/hikka/modules/loader.py b/hikka/modules/loader.py index 75b2413..0279bc8 100644 --- a/hikka/modules/loader.py +++ b/hikka/modules/loader.py @@ -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"▫️ {utils.escape_html(self.get_prefix())}{utils.escape_html(cmd)}:" + f" {utils.escape_html(cmd_doc)}" + 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