From 7376788ad6bbfabf2e6fdd8339f602db20a252bc Mon Sep 17 00:00:00 2001
From: Who? <155328415+coddrago@users.noreply.github.com>
Date: Mon, 18 Nov 2024 20:37:26 +0700
Subject: [PATCH 1/4] Update ua.yml
---
hikka/langpacks/ua.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hikka/langpacks/ua.yml b/hikka/langpacks/ua.yml
index be764d8..0d64356 100644
--- a/hikka/langpacks/ua.yml
+++ b/hikka/langpacks/ua.yml
@@ -247,7 +247,7 @@ settings:
alias_removed: "👍 Аліас {}
видалено."
no_alias: "🚫 Аліаса {}
не існує"
db_cleared: "👍 Базу очищена"
- hikka: "{} {}.{}.{} {}\n\n💜 Hikka-TL: {}\n\n⌨️ Developer: t.me/hikariatama\n🔥
+ hikka: "{} {}.{}.{} {}\n\n💜 Telethon: 1.37.0\n\n⌨️ Developer: t.me/hikariatama\n🔥
Forked by t.me/codrago"
_cls_doc: "Керування базовими налаштуваннями юзербота"
confirm_cleardb: "⚠️ Ви впевнені, що хочете зкинути базу даних?"
@@ -307,7 +307,7 @@ inline_stuff:
bot_username_invalid: "🚫 Неправильний нік бота. Він має закінчитися на bot
і бути не коротше ніж 5 символів"
bot_username_occupied: "🚫 Такий нік бота вже зайнятий"
bot_updated: "🎉 Налаштування збережені. Для їх застосування треба перезавантажити юзербота"
- this_is_hikka: "🌘 Привіт! Це Hikka — потужний модульний Telegram юзербот. Ви можете встановити його на свій акаунт!\n\n🌍 GitHub\n👥 Чат підтримки"
+ this_is_hikka: "🌘 Привіт! Це Hikka — потужний модульний Telegram юзербот. Ви можете встановити його на свій акаунт!\n\n🌍 GitHub\n👥 Чат підтримки"
_cmd_doc_ch_hikka_bot: "<юзернейм> - Змінити юзернейм інлайн бота"
test:
@@ -623,4 +623,4 @@ $inline:
command_msg: "🌘 Команда «{}»\n\n{}"
command: "🌘 Команда «{}»"
button403: "Ви не можете натиснути на цю кнопку!"
- keep_id: "⚠️ Не видаляйте ID! {}"
\ No newline at end of file
+ keep_id: "⚠️ Не видаляйте ID! {}"
From 2ed36608c50f6770b9bf13a12ce2dbd7a2fb2493 Mon Sep 17 00:00:00 2001
From: Who? <155328415+coddrago@users.noreply.github.com>
Date: Mon, 18 Nov 2024 20:37:28 +0700
Subject: [PATCH 2/4] Update en.yml
---
hikka/langpacks/en.yml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hikka/langpacks/en.yml b/hikka/langpacks/en.yml
index aa1fc5c..6319596 100644
--- a/hikka/langpacks/en.yml
+++ b/hikka/langpacks/en.yml
@@ -259,7 +259,7 @@ I also recommend resetting all built-in module configurations to their default v
alias_removed: "👍 Alias {}
removed."
no_alias: "🚫 Alias {}
does not exist"
db_cleared: "👍 Database cleared"
- hikka: "{} {}.{}.{} {}\n\n💜 Hikka-TL: {}\n\n⌨️ Developer: t.me/hikariatama\n🔥 Forked By t.me/codrago"
+ hikka: "{} {}.{}.{} {}\n\n💜 Telethon: 1.37.0\n\n⌨️ Developer: t.me/hikariatama\n🔥 Forked By t.me/codrago"
confirm_cleardb: "⚠️ Are you sure, that you want to clear database?"
cleardb_confirm: "🗑 Clear database"
cancel: "🚫 Cancel"
@@ -320,7 +320,7 @@ inline_stuff:
bot_username_invalid: "🚫 Specified bot username is invalid. It must end with bot
and contain at least 4 symbols"
bot_username_occupied: "🚫 This username is already occupied"
bot_updated: "🎉 Config successfully saved. Restart userbot to apply changes"
- this_is_hikka: "🌘 Hi! This is Hikka — powerful modular Telegram userbot. You can install it to your account!\n\n🌍 GitHub\n👥 Support chat"
+ this_is_hikka: "🌘 Hi! This is Hikka — powerful modular Telegram userbot. You can install it to your account!\n\n🌍 GitHub\n👥 Support chat"
_cmd_doc_ch_hikka_bot: " - Change your Hikka inline bot username"
_cls_doc: "Provides support for inline stuff"
@@ -652,3 +652,4 @@ $inline:
command: "🌘 Command «{}»"
button403: "You are not allowed to press this button!"
keep_id: "⚠️ Do not remove ID! {}"
+
From 0c71f780d500acc755599633b6a6a2ab529b3cba Mon Sep 17 00:00:00 2001
From: Who? <155328415+coddrago@users.noreply.github.com>
Date: Mon, 18 Nov 2024 20:37:32 +0700
Subject: [PATCH 3/4] Update ru.yml
---
hikka/langpacks/ru.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hikka/langpacks/ru.yml b/hikka/langpacks/ru.yml
index 3095366..1af855d 100644
--- a/hikka/langpacks/ru.yml
+++ b/hikka/langpacks/ru.yml
@@ -247,7 +247,7 @@ settings:
alias_removed: "👍 Алиас {}
удален."
no_alias: "🚫 Алиас {}
не существует"
db_cleared: "👍 База очищена"
- hikka: "{} {}.{}.{} {}\n\n💜 Hikka-TL: {}\n\n⌨️ Developer: t.me/hikariatama\n🔥
+ hikka: "{} {}.{}.{} {}\n\n💜 Telethon: 1.37.0\n\n⌨️ Developer: t.me/hikariatama\n🔥
Forked by t.me/codrago"
_cls_doc: "Управление базовыми настройками юзербота"
confirm_cleardb: "⚠️ Вы уверены, что хотите сбросить базу данных?"
@@ -307,7 +307,7 @@ inline_stuff:
bot_username_invalid: "🚫 Неправильный ник бота. Он должен заканчиваться на bot
и быть не короче чем 5 символов"
bot_username_occupied: "🚫 Такой ник бота уже занят"
bot_updated: "🎉 Настройки сохранены. Для их применения нужно перезагрузить юзербот"
- this_is_hikka: "🌘 Привет! Это Hikka — мощный модульный Telegram юзербот. Вы можете установить его на свой аккаунт!\n\n🌍 GitHub\n👥 Чат поддержки"
+ this_is_hikka: "🌘 Привет! Это Hikka — мощный модульный Telegram юзербот. Вы можете установить его на свой аккаунт!\n\n🌍 GitHub\n👥 Чат поддержки"
_cmd_doc_ch_hikka_bot: "<юзернейм> - Изменить юзернейм инлайн бота"
test:
From 117b7daaadb331df31c8bd375436aa023931517a Mon Sep 17 00:00:00 2001
From: Who? <155328415+coddrago@users.noreply.github.com>
Date: Mon, 18 Nov 2024 20:39:04 +0700
Subject: [PATCH 4/4] bug fix
---
hikka/modules/fheta.py | 101 +++++++++++++++++++++++++++++++++--------
1 file changed, 83 insertions(+), 18 deletions(-)
diff --git a/hikka/modules/fheta.py b/hikka/modules/fheta.py
index 30b2e22..60d8cc4 100644
--- a/hikka/modules/fheta.py
+++ b/hikka/modules/fheta.py
@@ -1,6 +1,6 @@
-__version__ = (3, 3, 4)
+__version__ = (3, 3, 5)
# meta developer: @Foxy437
-# change-log: 🎉🎉🎉🎉🎉🎉🎉🎉 ADDED INLINE!!!
+# change-log: 🎉🎉🎉🎉🎉🎉🎉🎉 ADDED INLINE!!! ADDED UKRAINIAN!!!
# ©️ Fixyres, 2024
# 🌐 https://github.com/Fixyres/FHeta
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,6 +18,7 @@ import inspect
from hikkatl.types import Message
import random
from ..types import InlineQuery
+import difflib
@loader.tds
class FHeta(loader.Module):
@@ -31,8 +32,8 @@ class FHeta(loader.Module):
"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",
+ "fetch_failed": "❌ Error.",
+ "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\n",
"inline_no_query": "Enter a query to search.",
"inline_no_modules_found": "No modules found.",
"inline_commands": "\n👨💻 Commands:\n{commands_list}",
@@ -51,8 +52,8 @@ class FHeta(loader.Module):
"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",
+ "fetch_failed": "❌ Ошибка.",
+ "closest_match": "🔎 Результат по запросу: {query}
\n{module_name}
от {author}\n🖥 Репозиторий: {repo_url}\n💾 Команда для установки: {install_command}
{description}{commands}\n\n\n",
"inline_no_query": "Введите запрос для поиска.",
"inline_no_modules_found": "Модули не найдены.",
"inline_commands": "\n👨💻 Команды:\n{commands_list}",
@@ -63,7 +64,27 @@ class FHeta(loader.Module):
"inline_noo_query": "Название, команда, описание, автор."
}
- @loader.command(ru_doc="(запрос) - искать модули.")
+ strings_ua = {
+ "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": "❌ Помилка.",
+ "closest_match": "🔎 Результат за запитом: {query}
\n{module_name}
від {author}\n🖥 Репозиторій: {repo_url}\n💾 Команда для встановлення: {install_command}
{description}{commands}\n\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="(запрос) - искать модули.", ua_doc="(запит) - шукати модулі.")
async def fhetacmd(self, message):
'''(query) - search modules.'''
args = utils.get_args_raw(message)
@@ -78,6 +99,23 @@ class FHeta(loader.Module):
modules = await self.search_modules(args.replace(" ", ""))
if not modules:
+ 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()
+ all_modules = json.loads(data)
+
+ module_names = [module['name'] for module in all_modules]
+ closest_matches = difflib.get_close_matches(args, module_names, n=1, cutoff=0.5)
+
+ if closest_matches:
+ closest_module = next((m for m in all_modules if m['name'] == closest_matches[0]), None)
+ if closest_module:
+ formatted_module = await self.format_module(closest_module, args)
+ await utils.answer(message, formatted_module)
+ return
+
await utils.answer(message, self.strings["no_modules_found"])
else:
seen_modules = set()
@@ -95,17 +133,18 @@ class FHeta(loader.Module):
[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"]
+ commands_section = ""
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"]
+ description_section = ""
author_info = utils.escape_html(module.get("author", "???"))
module_name = utils.escape_html(module['name'].replace('.py', ''))
- module_key = f"{module_name}_{author_info}"
+ module_namee = utils.escape_html(module['name'].replace('.py', '').lower())
+ module_key = f"{module_namee}_{author_info}"
if module_key in seen_modules:
continue
@@ -127,14 +166,23 @@ class FHeta(loader.Module):
continue
if len(formatted_modules) == 1:
- closest_match_result = formatted_modules[0]
+ closest_match_result = self.strings["closest_match"].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
+ )
await utils.answer(message, closest_match_result)
else:
results = "".join(formatted_modules)
await utils.answer(message, results)
- @loader.inline_handler(ru_doc="(запрос) - искать модули.")
+ @loader.inline_handler(ru_doc="(запрос) - искать модули.", ua_doc="(запит) - шукати модулі.")
async def fheta(self, query: InlineQuery):
+ '''(query) - search modules.'''
args = query.args
if not args:
await query.answer(
@@ -159,6 +207,20 @@ class FHeta(loader.Module):
if not modules:
modules = await self.search_modules(args.replace(" ", ""))
+ if not modules:
+ 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()
+ all_modules = json.loads(data)
+
+ module_names = [module['name'] for module in all_modules]
+ closest_matches = difflib.get_close_matches(args, module_names, n=3, cutoff=0.4)
+
+ if closest_matches:
+ modules = [m for m in all_modules if m['name'] in closest_matches]
+
if not modules:
await query.answer(
[
@@ -187,7 +249,7 @@ class FHeta(loader.Module):
install = module['install']
commands_section = ""
- if "commands" in module:
+ if "commands" in module and module['commands']:
commands_list = "\n".join(
[f"{self.get_prefix()}{cmd['name']}
{utils.escape_html(cmd['description'])}" for cmd in module['commands']]
)
@@ -195,11 +257,14 @@ class FHeta(loader.Module):
description_section = ""
if "description" in module:
- description_section = self.strings["inline_description"].format(description=f"{utils.escape_html(module['description'])}")
+ description_section = self.strings["inline_description"].format(description=utils.escape_html(module['description']))
+ else:
+ description_section = ""
author_info = utils.escape_html(module.get("author", "???"))
module_name = utils.escape_html(module['name'].replace('.py', ''))
- module_key = f"{module_name}_{author_info}"
+ module_namee = utils.escape_html(module['name'].replace('.py', '').lower())
+ module_key = f"{module_namee}_{author_info}"
if module_key in seen_modules:
continue
@@ -210,7 +275,7 @@ class FHeta(loader.Module):
"type": "article",
"id": f"module_{result_index}",
"title": module_name,
- "description": self.strings["inline_descriptioon"].format(description=utils.escape_html(module["description"])),
+ "description": self.strings["inline_descriptioon"].format(description=module.get('description', utils.escape_html(module.get('author', '???')))),
"input_message_content": {
"message_text": self.strings["inline_result"].format(
query=args,
@@ -229,7 +294,7 @@ class FHeta(loader.Module):
)
result_index += 1
- if result_index > 20:
+ if result_index > 50:
break
except Exception:
continue
@@ -293,4 +358,4 @@ class FHeta(loader.Module):
install_command=f"{self.get_prefix()}{install}",
description=description_section,
commands=commands_section
- )
\ No newline at end of file
+ )