diff --git a/hikka/modules/fheta.py b/hikka/modules/fheta.py new file mode 100644 index 0000000..30b2e22 --- /dev/null +++ b/hikka/modules/fheta.py @@ -0,0 +1,296 @@ +__version__ = (3, 3, 4) +# meta developer: @Foxy437 +# change-log: 🎉🎉🎉🎉🎉🎉🎉🎉 ADDED INLINE!!! +# ©️ Fixyres, 2024 +# 🌐 https://github.com/Fixyres/FHeta +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# 🔑 http://www.apache.org/licenses/LICENSE-2.0 + +import requests +import asyncio +import aiohttp +from .. import loader, utils +import json +import io +import inspect +from hikkatl.types import Message +import random +from ..types import InlineQuery + +@loader.tds +class FHeta(loader.Module): + '''Module for searching modules! Upload your modules to FHeta via fheta_robot.t.me!''' + + strings = { + "name": "FHeta", + "search": "🔎 Searching...", + "no_query": " Enter a query to search.", + "no_modules_found": " No modules found.", + "commands": "\n👨‍💻 Commands:\n{commands_list}", + "description": "\n📁 Description: {description}", + "result": "🔎 Result {index} by query: {query}\n{module_name} by {author}\n🖥 Repository: {repo_url}\n💾 Command for installation: {install_command}{description}{commands}\n\n\n", + "fetch_failed": " Failed to fetch the FHeta.", + "closest_match": "🔎 Result by query {query}:\n{module_name} by {author}\n🖥 Repository: {repo_url}\n💾 Command for installation: {install_command}{description}{commands}\n\n", + "inline_no_query": "Enter a query to search.", + "inline_no_modules_found": "No modules found.", + "inline_commands": "\n👨‍💻 Commands:\n{commands_list}", + "inline_description": "\n📁 Description: {description}", + "inline_result": "{module_name} by {author}\n🖥️ Repository: {repo_url}\n💾 Command for installation: {install_command}{description}{commands}\n\n\n", + "inline_descriptioon": "{description}", + "inline_no_modules_foound": "Try another request.", + "inline_noo_query": "Name, command, description, author." + } + + strings_ru = { + "name": "FHeta", + "search": "🔎 Поиск...", + "no_query": " Введите запрос для поиска.", + "no_modules_found": " Модули не найдены.", + "commands": "\n👨‍💻 Команды:\n{commands_list}", + "description": "\n📁 Описание: {description}", + "result": "🔎 Результат {index} по запросу: {query}\n{module_name} от {author}\n🖥 Репозиторий: {repo_url}\n💾 Команда для установки: {install_command}{description}{commands}\n\n\n", + "fetch_failed": " Не удалось получить данные для FHeta.", + "closest_match": "🔎 Результат по запросу {query}:\n{module_name} от {author}\n🖥 Репозиторий: {repo_url}\n💾 Команда для установки: {install_command}{description}{commands}\n\n", + "inline_no_query": "Введите запрос для поиска.", + "inline_no_modules_found": "Модули не найдены.", + "inline_commands": "\n👨‍💻 Команды:\n{commands_list}", + "inline_description": "\n📁 Описание: {description}", + "inline_result": "{module_name} от {author}\n🖥️ Репозиторий: {repo_url}\n💾 Команда для установки: {install_command}{description}{commands}\n\n\n", + "inline_descriptioon": "{description}", + "inline_no_modules_foound": "Попробуйте другой запрос.", + "inline_noo_query": "Название, команда, описание, автор." + } + + @loader.command(ru_doc="(запрос) - искать модули.") + async def fhetacmd(self, message): + '''(query) - search modules.''' + args = utils.get_args_raw(message) + if not args: + await utils.answer(message, self.strings["no_query"]) + return + + await utils.answer(message, self.strings["search"]) + modules = await self.search_modules(args) + + if not modules: + modules = await self.search_modules(args.replace(" ", "")) + + if not modules: + await utils.answer(message, self.strings["no_modules_found"]) + else: + seen_modules = set() + formatted_modules = [] + result_index = 1 + + for module in modules: + try: + repo_url = f"https://github.com/{module['repo']}" + install = module['install'] + + commands_section = "" + if "commands" in module and module['commands']: + commands_section = self.strings["commands"].format(commands_list="\n".join( + [f"{self.get_prefix()}{cmd['name']} {utils.escape_html(cmd['description'])}" for cmd in module['commands']] + )) + elif "commands" not in module or not module['commands']: + commands_section = self.strings["no_commands"] + + description_section = "" + if "description" in module and module["description"]: + description_section = self.strings["description"].format(description=utils.escape_html(module["description"])) + elif "description" not in module or not module["description"]: + description_section = self.strings["no_description"] + + author_info = utils.escape_html(module.get("author", "???")) + module_name = utils.escape_html(module['name'].replace('.py', '')) + module_key = f"{module_name}_{author_info}" + + if module_key in seen_modules: + continue + seen_modules.add(module_key) + + result = self.strings["result"].format( + index=result_index, + query=args, + module_name=module_name, + author=author_info, + repo_url=repo_url, + install_command=f"{self.get_prefix()}{install}", + description=description_section, + commands=commands_section + ) + formatted_modules.append(result) + result_index += 1 + except Exception: + continue + + if len(formatted_modules) == 1: + closest_match_result = formatted_modules[0] + await utils.answer(message, closest_match_result) + else: + results = "".join(formatted_modules) + await utils.answer(message, results) + + @loader.inline_handler(ru_doc="(запрос) - искать модули.") + async def fheta(self, query: InlineQuery): + args = query.args + if not args: + await query.answer( + [ + { + "type": "article", + "id": "no_query", + "title": self.strings["inline_no_query"], + "description": self.strings["inline_noo_query"], + "input_message_content": { + "message_text": self.strings["inline_no_query"], + "parse_mode": "HTML", + }, + "thumb_url": "https://raw.githubusercontent.com/Fixyres/FHeta/refs/heads/main/imgonline-com-ua-Resize-4EUHOHiKpwRTb4s.png", + } + ] + ) + return + + modules = await self.search_modules(args) + + if not modules: + modules = await self.search_modules(args.replace(" ", "")) + + if not modules: + await query.answer( + [ + { + "type": "article", + "id": "no_modules_found", + "title": self.strings["inline_no_modules_found"], + "description": self.strings["inline_no_modules_foound"], + "input_message_content": { + "message_text": self.strings["inline_no_modules_found"], + "parse_mode": "HTML", + }, + "thumb_url": "https://raw.githubusercontent.com/Fixyres/FHeta/refs/heads/main/imgonline-com-ua-Resize-KbaztxA3oS67p3m8.png", + } + ] + ) + return + + seen_modules = set() + results = [] + result_index = 1 + + for module in modules: + try: + repo_url = f"https://github.com/{module['repo']}" + install = module['install'] + + commands_section = "" + if "commands" in module: + commands_list = "\n".join( + [f"{self.get_prefix()}{cmd['name']} {utils.escape_html(cmd['description'])}" for cmd in module['commands']] + ) + commands_section = self.strings["inline_commands"].format(commands_list=commands_list) + + description_section = "" + if "description" in module: + description_section = self.strings["inline_description"].format(description=f"{utils.escape_html(module['description'])}") + + author_info = utils.escape_html(module.get("author", "???")) + module_name = utils.escape_html(module['name'].replace('.py', '')) + module_key = f"{module_name}_{author_info}" + + if module_key in seen_modules: + continue + seen_modules.add(module_key) + + results.append( + { + "type": "article", + "id": f"module_{result_index}", + "title": module_name, + "description": self.strings["inline_descriptioon"].format(description=utils.escape_html(module["description"])), + "input_message_content": { + "message_text": self.strings["inline_result"].format( + query=args, + module_name=module_name, + author=author_info, + repo_url=repo_url, + install_command=f"{self.get_prefix()}{install}", + description=description_section, + commands=commands_section, + ), + "parse_mode": "HTML", + "disable_web_page_preview": True, + }, + "thumb_url": "https://raw.githubusercontent.com/Fixyres/FHeta/refs/heads/main/imgonline-com-ua-Resize-SOMllzo0cPFUCor.png", + } + ) + result_index += 1 + + if result_index > 20: + break + except Exception: + continue + + await query.answer(results) + + async def search_modules(self, query: str): + url = "https://raw.githubusercontent.com/Fixyres/FHeta/refs/heads/main/modules.json" + async with aiohttp.ClientSession() as session: + async with session.get(url) as response: + if response.status == 200: + data = await response.text() + modules = json.loads(data) + + found_modules = [ + module for module in modules + if query.lower() in module.get("name", "").lower() + ] + + if not found_modules: + found_modules = [ + module for module in modules + if any(query.lower() in cmd.get("name", "").lower() for cmd in module.get("commands", [])) + ] + + if not found_modules: + found_modules = [ + module for module in modules + if query.lower() in module.get("author", "").lower() + ] + + if not found_modules: + found_modules = [ + module for module in modules + if query.lower() in module.get("description", "").lower() + ] + + return found_modules + + async def format_module(self, module, query): + repo_url = f"https://github.com/{module['repo']}" + install = module['install'] + + commands_section = "" + if "commands" in module: + commands_list = "\n".join([f"{self.get_prefix()}{cmd['name']} {cmd['description']}" for cmd in module['commands']]) + commands_section = self.strings["commands"].format(commands_list=commands_list) + + description_section = "" + if "description" in module: + description_section = self.strings["description"].format(description=module["description"]) + + author_info = module.get("author", "???") + module_name = module['name'].replace('.py', '') + + return self.strings["closest_match"].format( + query=query, + module_name=module_name, + author=author_info, + repo_url=repo_url, + install_command=f"{self.get_prefix()}{install}", + description=description_section, + commands=commands_section + ) \ No newline at end of file diff --git a/hikka/modules/presets.py b/hikka/modules/presets.py index 3594525..a727862 100644 --- a/hikka/modules/presets.py +++ b/hikka/modules/presets.py @@ -16,75 +16,75 @@ logger = logging.getLogger(__name__) PRESETS = { "fun": [ - "https://mods.hikariatama.ru/aniquotes.py", - "https://mods.hikariatama.ru/artai.py", - "https://mods.hikariatama.ru/inline_ghoul.py", - "https://mods.hikariatama.ru/lovemagic.py", - "https://mods.hikariatama.ru/mindgame.py", - "https://mods.hikariatama.ru/moonlove.py", - "https://mods.hikariatama.ru/neko.py", - "https://mods.hikariatama.ru/purr.py", - "https://mods.hikariatama.ru/rpmod.py", - "https://mods.hikariatama.ru/scrolller.py", - "https://mods.hikariatama.ru/tictactoe.py", - "https://mods.hikariatama.ru/trashguy.py", - "https://mods.hikariatama.ru/truth_or_dare.py", - "https://mods.hikariatama.ru/sticks.py", - "https://mods.hikariatama.ru/premium_sticks.py", - "https://heta.hikariatama.ru/MoriSummerz/ftg-mods/magictext.py", - "https://heta.hikariatama.ru/HitaloSama/FTG-modules-repo/quotes.py", - "https://heta.hikariatama.ru/HitaloSama/FTG-modules-repo/spam.py", - "https://heta.hikariatama.ru/SkillsAngels/Modules/IrisLab.py", - "https://heta.hikariatama.ru/Fl1yd/FTG-Modules/arts.py", - "https://heta.hikariatama.ru/SkillsAngels/Modules/Complements.py", - "https://heta.hikariatama.ru/Den4ikSuperOstryyPer4ik/Astro-modules/Compliments.py", - "https://heta.hikariatama.ru/vsecoder/hikka_modules/mazemod.py", + "https://heta.dan.tatar/aniquotes.py", + "https://heta.dan.tatar/artai.py", + "https://heta.dan.tatar/inline_ghoul.py", + "https://heta.dan.tatar/lovemagic.py", + "https://heta.dan.tatar/mindgame.py", + "https://heta.dan.tatar/moonlove.py", + "https://heta.dan.tatar/neko.py", + "https://heta.dan.tatar/purr.py", + "https://heta.dan.tatar/rpmod.py", + "https://heta.dan.tatar/scrolller.py", + "https://heta.dan.tatar/tictactoe.py", + "https://heta.dan.tatar/trashguy.py", + "https://heta.dan.tatar/truth_or_dare.py", + "https://heta.dan.tatar/sticks.py", + "https://heta.dan.tatar/premium_sticks.py", + "https://heta.dan.tatar/MoriSummerz/ftg-mods/magictext.py", + "https://heta.dan.tatar/HitaloSama/FTG-modules-repo/quotes.py", + "https://heta.dan.tatar/HitaloSama/FTG-modules-repo/spam.py", + "https://heta.dan.tatar/SkillsAngels/Modules/IrisLab.py", + "https://heta.dan.tatar/Fl1yd/FTG-Modules/arts.py", + "https://heta.dan.tatar/SkillsAngels/Modules/Complements.py", + "https://heta.dan.tatar/Den4ikSuperOstryyPer4ik/Astro-modules/Compliments.py", + "https://heta.dan.tatar/vsecoder/hikka_modules/mazemod.py", "https://raw.githubusercontent.com/coddrago/modules/main/dice.py", "https://raw.githubusercontent.com/coddrago/modules/main/loli.py", "https://raw.githubusercontent.com/coddrago/modules/main/DoxTool.py", "https://raw.githubusercontent.com/coddrago/modules/main/randomizer.py", ], "chat": [ - "https://mods.hikariatama.ru/activists.py", - "https://mods.hikariatama.ru/banstickers.py", - "https://mods.hikariatama.ru/hikarichat.py", - "https://mods.hikariatama.ru/inactive.py", - "https://mods.hikariatama.ru/keyword.py", - "https://mods.hikariatama.ru/tagall.py", - "https://mods.hikariatama.ru/voicechat.py", - "https://mods.hikariatama.ru/vtt.py", - "https://heta.hikariatama.ru/SekaiYoneya/Friendly-telegram/BanMedia.py", - "https://heta.hikariatama.ru/iamnalinor/FTG-modules/swmute.py", - "https://heta.hikariatama.ru/GeekTG/FTG-Modules/filter.py", + "https://heta.dan.tatar/activists.py", + "https://heta.dan.tatar/banstickers.py", + "https://heta.dan.tatar/hikarichat.py", + "https://heta.dan.tatar/inactive.py", + "https://heta.dan.tatar/keyword.py", + "https://heta.dan.tatar/tagall.py", + "https://heta.dan.tatar/voicechat.py", + "https://heta.dan.tatar/vtt.py", + "https://heta.dan.tatar/SekaiYoneya/Friendly-telegram/BanMedia.py", + "https://heta.dan.tatar/iamnalinor/FTG-modules/swmute.py", + "https://heta.dan.tatar/GeekTG/FTG-Modules/filter.py", "https://raw.githubusercontent.com/coddrago/modules/main/id.py", "https://raw.githubusercontent.com/coddrago/modules/main/clickon.py", ], "service": [ - "https://mods.hikariatama.ru/account_switcher.py", - "https://mods.hikariatama.ru/surl.py", - "https://mods.hikariatama.ru/httpsc.py", - "https://mods.hikariatama.ru/img2pdf.py", - "https://mods.hikariatama.ru/latex.py", - "https://mods.hikariatama.ru/pollplot.py", - "https://mods.hikariatama.ru/sticks.py", - "https://mods.hikariatama.ru/temp_chat.py", - "https://mods.hikariatama.ru/vtt.py", - "https://heta.hikariatama.ru/vsecoder/hikka_modules/accounttime.py", - "https://heta.hikariatama.ru/vsecoder/hikka_modules/searx.py", - "https://heta.hikariatama.ru/iamnalinor/FTG-modules/swmute.py", + "https://heta.dan.tatar/account_switcher.py", + "https://heta.dan.tatar/surl.py", + "https://heta.dan.tatar/httpsc.py", + "https://heta.dan.tatar/img2pdf.py", + "https://heta.dan.tatar/latex.py", + "https://heta.dan.tatar/pollplot.py", + "https://heta.dan.tatar/sticks.py", + "https://heta.dan.tatar/temp_chat.py", + "https://heta.dan.tatar/vtt.py", + "https://heta.dan.tatar/vsecoder/hikka_modules/accounttime.py", + "https://heta.dan.tatar/vsecoder/hikka_modules/searx.py", + "https://heta.dan.tatar/iamnalinor/FTG-modules/swmute.py", "https://raw.githubusercontent.com/coddrago/modules/main/modlist.py", ], "downloaders": [ - "https://mods.hikariatama.ru/musicdl.py", - "https://mods.hikariatama.ru/uploader.py", - "https://mods.hikariatama.ru/porn.py", - "https://mods.hikariatama.ru/web2file.py", - "https://heta.hikariatama.ru/AmoreForever/amoremods/instsave.py", - "https://heta.hikariatama.ru/CakesTwix/Hikka-Modules/tikcock.py", - "https://heta.hikariatama.ru/CakesTwix/Hikka-Modules/InlineYouTube.py", - "https://heta.hikariatama.ru/CakesTwix/Hikka-Modules/InlineSpotifyDownloader.py", - "https://heta.hikariatama.ru/GeekTG/FTG-Modules/downloader.py", - "https://heta.hikariatama.ru/Den4ikSuperOstryyPer4ik/Astro-modules/dl_yt_previews.py", + "https://heta.dan.tatar/musicdl.py", + "https://heta.dan.tatar/uploader.py", + "https://heta.dan.tatar/porn.py", + "https://heta.dan.tatar/web2file.py", + "https://heta.dan.tatar/AmoreForever/amoremods/instsave.py", + "https://heta.dan.tatar/CakesTwix/Hikka-Modules/tikcock.py", + "https://heta.dan.tatar/CakesTwix/Hikka-Modules/InlineYouTube.py", + "https://heta.dan.tatar/CakesTwix/Hikka-Modules/InlineSpotifyDownloader.py", + "https://heta.dan.tatar/GeekTG/FTG-Modules/downloader.py", + "https://heta.dan.tatar/Den4ikSuperOstryyPer4ik/Astro-modules/dl_yt_previews.py", ], } diff --git a/hikka/modules/update_notifier.py b/hikka/modules/update_notifier.py index 1cbd920..008b958 100644 --- a/hikka/modules/update_notifier.py +++ b/hikka/modules/update_notifier.py @@ -142,9 +142,9 @@ class UpdateNotifier(loader.Module): @loader.command() async def changelog(self, message: Message): """Shows the changelog of the last major update""" - with open('../CHANGELOG.md', mode='r', encoding='utf-8') as f: + with open('CHANGELOG.md', mode='r', encoding='utf-8') as f: changelog = f.read().split('##')[1].strip() - if self.client.hikka_me.premium: + if (await self._client.get_me()).premium: changelog.replace('🌑 Hikka', '🌘🌘🌘') await utils.answer(message, self.strings('changelog').format(changelog))