From 2449f2e4e9555aba40907d5f5f748a18af0e473e Mon Sep 17 00:00:00 2001 From: Who? <155328415+coddrago@users.noreply.github.com> Date: Sat, 14 Sep 2024 00:11:50 +0700 Subject: [PATCH] Update unit_heta.py --- hikka/modules/unit_heta.py | 128 ------------------------------------- 1 file changed, 128 deletions(-) diff --git a/hikka/modules/unit_heta.py b/hikka/modules/unit_heta.py index 1521e5f..1ca4fa5 100644 --- a/hikka/modules/unit_heta.py +++ b/hikka/modules/unit_heta.py @@ -342,134 +342,6 @@ class UnitHeta(loader.Module): int(data["dl_id"]), ) - @loader.command() - async def mlcmd(self, message: Message): - if not (args := utils.get_args_raw(message)): - await utils.answer(message, self.strings("args")) - return - - exact = True - if not ( - class_name := next( - ( - module.strings("name") - for module in self.allmodules.modules - if args.lower() - in { - module.strings("name").lower(), - module.__class__.__name__.lower(), - } - ), - None, - ) - ): - if not ( - class_name := next( - reversed( - sorted( - [ - module.strings["name"].lower() - for module in self.allmodules.modules - ] - + [ - module.__class__.__name__.lower() - for module in self.allmodules.modules - ], - key=lambda x: difflib.SequenceMatcher( - None, - args.lower(), - x, - ).ratio(), - ) - ), - None, - ) - ): - await utils.answer(message, self.strings("404")) - return - - exact = False - - try: - module = self.lookup(class_name) - sys_module = inspect.getmodule(module) - except Exception: - await utils.answer(message, self.strings("404")) - return - - link = module.__origin__ - - text = ( - f"🧳 {utils.escape_html(class_name)}" - if not utils.check_url(link) - else ( - f'📼 Link for' - f" {utils.escape_html(class_name)}:" - f' {link}\n\n{self.strings("not_exact") if not exact else ""}' - ) - ) - - text = ( - self.strings("link").format( - class_name=utils.escape_html(class_name), - url=link, - not_exact=self.strings("not_exact") if not exact else "", - prefix=utils.escape_html(self.get_prefix()), - ) - if utils.check_url(link) - else self.strings("file").format( - class_name=utils.escape_html(class_name), - not_exact=self.strings("not_exact") if not exact else "", - prefix=utils.escape_html(self.get_prefix()), - ) - ) - - file = io.BytesIO(sys_module.__loader__.data) - file.name = f"{class_name}.py" - file.seek(0) - - await utils.answer_file( - message, - 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 - @loader.inline_handler(thumb_url="https://img.icons8.com/color/512/hexa.png") async def heta(self, query: InlineQuery) -> typing.List[dict]: if not query.args: