From bbb4f33230163bdac56ef86fb64667ab11adfee2 Mon Sep 17 00:00:00 2001
From: Who? <155328415+coddrago@users.noreply.github.com>
Date: Fri, 13 Sep 2024 23:53:38 +0700
Subject: [PATCH] Update loader.py
---
hikka/modules/loader.py | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
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