From 58316ec8b2a5ba890c10d02dab0bc1679771f079 Mon Sep 17 00:00:00 2001 From: John Doe Date: Sun, 12 Apr 2026 17:49:15 +0300 Subject: [PATCH] feat: Interface update --- Limoka.py | 255 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 133 insertions(+), 122 deletions(-) diff --git a/Limoka.py b/Limoka.py index 2f15d07..f3e3477 100644 --- a/Limoka.py +++ b/Limoka.py @@ -33,7 +33,7 @@ from .. import utils, loader from ..types import InlineCall logger = logging.getLogger("Limoka") -__version__ = (1, 4, 2) +__version__ = (1, 4, 3) WEIGHTS = { "inline.token_obtainment": 15, @@ -90,27 +90,27 @@ class Limoka(loader.Module): strings = { "name": "Limoka", "wait": ( - "Just wait\n" + "
Just wait\n" "🔍 A search is underway among {count} modules " "for the query: {query}\n" - "{fact}" + "{fact}
" ), "found_header": ( - "🔍 Found module {name} " + "
🔍 Found module {name} " "by query: {query}\n\n" "ℹ️ Description: {description}\n" "🧑‍💻 Developer: {username}\n\n" - "🏷 Tags: {tags}\n\n" + "🏷 Tags: {tags}\n\n
" ), "found_body": ("{commands}"), "found_footer": ( - "\n🪄 {prefix}dlm {url}{module_path}" + "
\n🪄 {prefix}dlm {url}{module_path}
" ), "caption_short": ( - "🔍 {safe_name}\n" + "
🔍 {safe_name}\n" "ℹ️ Description: {safe_desc}\n" "🧑‍💻 Dev: {dev_username}\n" - "🪄 {prefix}dlm {module_path}" + "🪄 {prefix}dlm {module_path}
" ), "command_template": "{emoji} {prefix}{command} — {description}\n", "inline_handler_template": "{inline_bot} {command} — {description}\n", @@ -125,63 +125,63 @@ class Limoka(loader.Module): 8: "8️⃣", 9: "9️⃣", }, - "404": " Not found by query: {query}", - "noargs": " No args", - "?": "🔎 Request too short / not found", - "no_info": "No information", + "404": "
Not found by query: {query}
", + "noargs": "
No args
", + "?": "
🔎 Request too short / not found
", + "no_info": "
No information
", "facts": [ - "🛡 The limoka catalog is carefully moderated!", - "🚀 Limoka performance allows you to search for modules quickly!", + "
🛡 The limoka catalog is carefully moderated!
", + "
🚀 Limoka performance allows you to search for modules quickly!
", ], - "inline404": "Not found", - "inline?": "Request too short / not found", - "inlinenoargs": "Please, enter query", + "inline404": "
Not found
", + "inline?": "
Request too short / not found
", + "inlinenoargs": "
Please, enter query
", "history": ( - "🔎 Your search history:\n" - "{history}" + "
🔎 Your search history:\n" + "{history}
" ), "filter_menu": "Choose filters", "filter_cat": "📑 Filter by Category", "apply_filters": "✅ Apply Filters", "clear_filters": "🗑 Clear Filters", "back_to_results": "🔙 Back to Results", - "empty_history": "🔎 Your search history is empty!", - "enter_query": "🔍 Enter new search query:", - "global_search": "🔍 Global search for {query} — found {count} modules", + "empty_history": "
🔎 Your search history is empty!
", + "enter_query": "
🔍 Enter new search query:
", + "global_search": "
🔍 Global search for {query} — found {count} modules
", "change_query": "🔍 Change query", - "no_modules": "No modules available.", + "no_modules": "
No modules available.
", "filter_title": "🏷 Filters", "category_title": "📂 Categories", - "selected_categories": "✅ Selected categories: {categories}", - "no_categories": "No categories found in the module database", - "select_category": "Select categories for query: {query}\n(You can select multiple)", + "selected_categories": "
✅ Selected categories: {categories}
", + "no_categories": "
No categories found in the module database
", + "select_category": "
Select categories for query: {query}\n(You can select multiple)
", "back": "🔙 Back", "category": "📁 {category}", - "no_category": "No category", + "no_category": "
No category
", "global_button": "🌍 Results", "filtered_button": "🏷️ Filtered search", "inline_search": "🔍 Search in Limoka", - "inline_no_results": "❌ No modules found", - "inline_error": "❌ Search error occurred", - "inline_short_query": "❌ Query too short (min 2 chars)", + "inline_no_results": "
❌ No modules found
", + "inline_error": "
❌ Search error occurred
", + "inline_short_query": "
❌ Query too short (min 2 chars)
", "inline_switch_pm": "💬 Open in chat", "inline_switch_pm_text": "🔍 Results for: {query}", - "inline_start_message": "🔍 Limoka Search\nType module name or keyword", - "first_page": "This is the first page!", - "last_page": "This is the last page!", - "display_error": "Error displaying module. Please try again.", - "error_occurred": "An error occurred. Please try again.", - "start_search_form": "🔍 Limoka Search\nEnter your query to search for modules:", - "global_search_form": "🔍 Global Search\nEnter your query to search ALL modules without filters:", - "history_cleared": "🧹 Search history cleared!", - "invalid_history_arg": " Invalid argument for history command. Use:\n.lshistory - show history\n.lshistory clear - clear history", + "inline_start_message": "
🔍 Limoka Search\nType module name or keyword
", + "first_page": "
This is the first page!
", + "last_page": "
This is the last page!
", + "display_error": "
Error displaying module. Please try again.
", + "error_occurred": "
An error occurred. Please try again.
", + "start_search_form": "
🔍 Limoka Search\nEnter your query to search for modules:
", + "global_search_form": "
🔍 Global Search\nEnter your query to search ALL modules without filters:
", + "history_cleared": "
🧹 Search history cleared!
", + "invalid_history_arg": "
Invalid argument for history command. Use:\n.lshistory - show history\n.lshistory clear - clear history
", "close": "❌ Close", - "watcher_no_tag": "❌ Invalid message format. No #limoka tag found.", - "watcher_invalid_format": "❌ Invalid format. Expected: #limoka:path:signature", - "watcher_signature_invalid": "❌ Signature invalid! Installation aborted.", - "watcher_loader_missing": "❌ Loader module not found.", - "watcher_module_not_found": "❌ Module not found in Limoka database: {path}", - "watcher_critical": "❌ Critical error: {error}", + "watcher_no_tag": "
❌ Invalid message format. No #limoka tag found.
", + "watcher_invalid_format": "
❌ Invalid format. Expected: #limoka:path:signature
", + "watcher_signature_invalid": "
❌ Signature invalid! Installation aborted.
", + "watcher_loader_missing": "
❌ Loader module not found.
", + "watcher_module_not_found": "
❌ Module not found in Limoka database: {path}
", + "watcher_critical": "
❌ Critical error: {error}
", "tags": { "herokutrusted": "Heroku Trusted", "hikkatrusted": "Hikka Trusted", @@ -190,111 +190,113 @@ class Limoka(loader.Module): "newbie": "Newbie", }, "indexing_in_progress": ( - "⚠️ Database is busy, " + "
⚠️ Database is busy, " "try again later. " "If issue persists, try " "removing limoka_index in the userbot's root folder. " - "If error persists again, report to developers" + "If error persists again, report to developers
" ), + "body_page": "Commands", } strings_ru = { "name": "Limoka", "wait": ( - "Подождите\n" + "
Подождите\n" "🔍 Идёт поиск среди {count} модулей по запросу: {query}\n" - "{fact}" + "{fact}
" ), "found_header": ( - "🔍 Найден модуль {name} " - "по запросу: {query}\n\n" - "ℹ️ Описание: {description}\n" - "🧑‍💻 Разработчик: {username}\n\n" - "🏷 Теги: {tags}\n\n" + "
🔍 Найден модуль {name} " + "по запросу: {query}
\n\n" + "
ℹ️ Описание: {description}
\n" + "
🧑‍💻 Разработчик: {username}
\n\n" + "
🏷 Теги: {tags}
\n\n" ), "found_body": ("{commands}"), "found_footer": ( - "\n🪄 {prefix}dlm {url}{module_path}" + "\n
🪄 {prefix}dlm {url}{module_path}
" ), "caption_short": ( - "🔍 {safe_name}\n" + "
🔍 {safe_name}\n" "ℹ️ Описание: {safe_desc}\n" "🧑‍💻 Разработчик: {dev_username}\n" - "🪄 {prefix}dlm {module_path}" + "🪄 {prefix}dlm {module_path}
" ), - "command_template": "{emoji} {prefix}{command} — {description}\n", + "command_template": "
{emoji} {prefix}{command} — {description}
\n", "inline_handler_template": "{inline_bot} {command} — {description}\n", "emojis": { - 1: "1️⃣", - 2: "2️⃣", - 3: "3️⃣", - 4: "4️⃣", - 5: "5️⃣", - 6: "6️⃣", - 7: "7️⃣", - 8: "8️⃣", - 9: "9️⃣", + 1: "1️⃣", + 2: "2️⃣", + 3: "3️⃣", + 4: "4️⃣", + 5: "5️⃣", + 6: "6️⃣", + 7: "7️⃣", + 8: "8️⃣", + 9: "9️⃣", + 10: "🔟" }, - "404": " Не найдено по запросу: {query}", - "noargs": " Нет аргументов", - "?": "🔎 Запрос слишком короткий / не найден", - "no_info": "Нет информации", + "404": "
Не найдено по запросу: {query}
", + "noargs": "
Нет аргументов
", + "?": "
🔎 Запрос слишком короткий / не найден
", + "no_info": "
Нет информации
", "facts": [ - "🛡 Каталог Limoka тщательно модерируется!", - "🚀 Limoka позволяет искать модули с невероятной скоростью!", + "
🛡 Каталог Limoka тщательно модерируется!
", + "
🚀 Limoka позволяет искать модули с невероятной скоростью!
", ( - "🔎 Limoka имеет лучший поиск*!\n" - "* В сравнении с предыдущей версией Limoka" + "
🔎 Limoka имеет лучший поиск*!\n" + "* В сравнении с предыдущей версией Limoka
" ), ], - "inline404": "Не найдено", - "inline?": "Запрос слишком короткий / не найден", - "inlinenoargs": "Введите запрос", + "inline404": "
Не найдено
", + "inline?": "
Запрос слишком короткий / не найден
", + "inlinenoargs": "
Введите запрос
", "history": ( - "🔎 История поиска:\n" - "{history}" + "
🔎 История поиска:\n" + "{history}
" ), "filter_menu": "Выберите фильтры", "filter_cat": "📑 Фильтр по категориям", "apply_filters": "✅ Применить фильтры", "clear_filters": "🗑 Очистить фильтры", "back_to_results": "🔙 Вернуться к результатам", - "empty_history": "🔎 История поиска пуста!", - "enter_query": "🔍 Введите новый поисковый запрос:", - "global_search": "🔍 Глобальный поиск по {query} — найдено {count} модулей", + "empty_history": "
🔎 История поиска пуста!
", + "enter_query": "
🔍 Введите новый поисковый запрос:
", + "global_search": "
🔍 Глобальный поиск по {query} — найдено {count} модулей
", "change_query": "🔍 Изменить запрос", - "no_modules": "Модули недоступны.", + "no_modules": "
Модули недоступны.
", "filter_title": "🏷 Фильтры", "category_title": "📂 Категории", - "selected_categories": "✅ Выбранные категории: {categories}", - "no_categories": "Категории не найдены в базе модулей", - "select_category": "Выберите категории для запроса: {query}\n(Можно выбрать несколько)", + "selected_categories": "
✅ Выбранные категории: {categories}
", + "no_categories": "
Категории не найдены в базе модулей
", + "select_category": "
Выберите категории для запроса: {query}\n(Можно выбрать несколько)
", "back": "🔙 Назад", "category": "📁 {category}", - "no_category": "Без категории", + "no_category": "
Без категории
", "global_button": "🌍 Результаты", "filtered_button": "🏷️ Поиск с фильтрами", "inline_search": "🔍 Поиск в Limoka", - "inline_no_results": "❌ Модули не найдены", - "inline_error": "❌ Ошибка поиска", - "inline_short_query": "❌ Запрос слишком короткий (мин. 2 символа)", + "inline_no_results": "
❌ Модули не найдены
", + "inline_error": "
❌ Ошибка поиска
", + "inline_short_query": "
❌ Запрос слишком короткий (мин. 2 символа)
", "inline_switch_pm": "💬 Открыть в чате", "inline_switch_pm_text": "🔍 Результаты для: {query}", - "inline_start_message": "🔍 Limoka Поиск\nВведите название модуля или ключевое слово", - "first_page": "Это первая страница!", - "last_page": "Это последняя страница!", - "display_error": "Ошибка отображения модуля. Пожалуйста, попробуйте еще раз.", - "error_occurred": "Произошла ошибка. Пожалуйста, попробуйте еще раз.", - "start_search_form": "🔍 Limoka Поиск\nВведите ваш запрос для поиска модулей:", - "global_search_form": "🔍 Глобальный Поиск\nВведите запрос для поиска ВСЕХ модулей без фильтров:", - "history_cleared": "🧹 История поиска очищена!", - "invalid_history_arg": " Неверный аргумент для команды истории. Используйте:\n.lshistory - показать историю\n.lshistory clear - очистить историю", + "inline_start_message": "
🔍 Limoka Поиск\nВведите название модуля или ключевое слово
", + "first_page": "
Это первая страница!
", + "last_page": "
Это последняя страница!
", + "display_error": "
Ошибка отображения модуля. Пожалуйста, попробуйте еще раз.
", + "error_occurred": "
Произошла ошибка. Пожалуйста, попробуйте еще раз.
", + "start_search_form": "
🔍 Limoka Поиск\nВведите ваш запрос для поиска модулей:
", + "global_search_form": "
🔍 Глобальный Поиск\nВведите запрос для поиска ВСЕХ модулей без фильтров:
", + "history_cleared": "
🧹 История поиска очищена!
", + "invalid_history_arg": "
Неверный аргумент для команды истории. Используйте:\n.lshistory - показать историю\n.lshistory clear - очистить историю
", "close": "❌ Закрыть", - "watcher_no_tag": "❌ Неверный формат сообщения. Тег #limoka не найден.", - "watcher_invalid_format": "❌ Неверный формат. Ожидается: #limoka:path:signature", - "watcher_signature_invalid": "❌ Неверная подпись! Установка отменена.", - "watcher_loader_missing": "❌ Модуль загрузчика не найден.", - "watcher_module_not_found": "❌ Модуль не найден в базе Limoka: {path}", - "watcher_critical": "❌ Критическая ошибка: {error}", + "watcher_no_tag": "
❌ Неверный формат сообщения. Тег #limoka не найден.
", + "watcher_invalid_format": "
❌ Неверный формат. Ожидается: #limoka:path:signature
", + "watcher_signature_invalid": "
❌ Неверная подпись! Установка отменена.
", + "watcher_loader_missing": "
❌ Модуль загрузчика не найден.
", + "watcher_module_not_found": "
❌ Модуль не найден в базе Limoka: {path}
", + "watcher_critical": "
❌ Критическая ошибка: {error}
", "tags": { "herokutrusted": "Heroku Trusted", "hikkatrusted": "Hikka Trusted", @@ -303,12 +305,13 @@ class Limoka(loader.Module): "newbie": "Новичок", }, "indexing_in_progress": ( - "⚠️ База данных занята, " + "
\u26a0\ufe0f База данных занята, " "попробуйте снова через несколько секунд. " "Если ошибка сохраняется, попробуйте " "удалить limoka_index в корневой папке юзербота. " - "Если ошибка сохраняется снова, сообщите разработчикам" + "Если ошибка сохраняется снова, сообщите разработчикам
" ), + "body_page": "Команды", "_cls_doc": "Модули теперь в одном месте с простым и удобным поиском!", } @@ -579,7 +582,12 @@ class Limoka(loader.Module): for i, cmd in enumerate(module_info.get("new_commands", []), 1): name = cmd.get("name", "") desc_map = cmd.get("description", {}) - emoji = self.strings["emojis"].get(i, "") + if i <= 10: + emoji = self.strings["emojis"].get(i, "") + else: + emoji = "" + for digit in str(i): + emoji += self.strings["emojis"].get(int(digit), "") desc = _get_lang_value(desc_map, lang) or self.strings["no_info"] commands.append( self.strings["command_template"].format( @@ -720,7 +728,7 @@ class Limoka(loader.Module): ], ] markup.append( - [{"text": self.strings.get("close", "❌ Close"), "action": "close"}] + [{"text": self.strings.get("close", "❌ Close"), "action": "close", "style": "danger"}] ) return markup @@ -752,7 +760,7 @@ class Limoka(loader.Module): ), }, { - "text": f"Body {page_body + 1}/{len(body_pages)}", + "text": f"{self.strings["body_page"]} {page_body + 1}/{len(body_pages)}", "callback": self._inline_void, }, { @@ -813,7 +821,7 @@ class Limoka(loader.Module): ] ) markup.append( - [{"text": self.strings.get("close", "❌ Close"), "action": "close"}] + [{"text": self.strings.get("close", "❌ Close"), "action": "close", "style": "danger"}] ) return markup @@ -867,9 +875,6 @@ class Limoka(loader.Module): filters = session["filters"] lang = self.user_lang - logger.info( - f"Displaying module: {module_path} for query: {query} with filters: {filters} in language: {lang}" - ) module_banner_raw = module_info.get("meta", {}).get("banner") photo = await self._validate_url(module_banner_raw) @@ -973,7 +978,7 @@ class Limoka(loader.Module): "args": (session, True), }, ], - [{"text": self.strings.get("close", "❌ Close"), "action": "close"}], + [{"text": self.strings.get("close", "❌ Close"), "action": "close", "style": "danger"}], ] text = self.strings["filter_menu"].format(query=query) + f"\n{filters_text}" await call.edit( @@ -1036,7 +1041,7 @@ class Limoka(loader.Module): ] ) buttons.append( - [{"text": self.strings.get("close", "❌ Close"), "action": "close"}] + [{"text": self.strings.get("close", "❌ Close"), "action": "close", "style": "danger"}] ) text = self.strings["select_category"].format(query=query) await call.edit(text, reply_markup=buttons) @@ -1096,7 +1101,7 @@ class Limoka(loader.Module): else [] ) markup.append( - [{"text": self.strings.get("close", "❌ Close"), "action": "close"}] + [{"text": self.strings.get("close", "❌ Close"), "action": "close", "style": "danger"}] ) await call.edit( self.strings["404"].format(query=query), reply_markup=markup @@ -1128,7 +1133,7 @@ class Limoka(loader.Module): else [] ) markup.append( - [{"text": self.strings.get("close", "❌ Close"), "action": "close"}] + [{"text": self.strings.get("close", "❌ Close"), "action": "close", "style": "danger"}] ) await call.edit( self.strings["404"].format(query=query), reply_markup=markup @@ -1218,6 +1223,7 @@ class Limoka(loader.Module): { "text": self.strings.get("close", "❌ Close"), "action": "close", + "style": "danger", } ], ], @@ -1262,6 +1268,7 @@ class Limoka(loader.Module): { "text": self.strings.get("close", "❌ Close"), "action": "close", + "style": "danger", } ], ] @@ -1386,7 +1393,7 @@ class Limoka(loader.Module): ], ] markup.append( - [{"text": self.strings.get("close", "❌ Close"), "action": "close"}] + [{"text": self.strings.get("close", "❌ Close"), "action": "close", "style": "danger"}] ) await self.inline.form( text=self.strings["start_search_form"], @@ -1450,6 +1457,7 @@ class Limoka(loader.Module): { "text": self.strings.get("close", "❌ Close"), "action": "close", + "style": "danger", } ], ] @@ -1479,6 +1487,7 @@ class Limoka(loader.Module): { "text": self.strings.get("close", "❌ Close"), "action": "close", + "style": "danger", } ], ], @@ -1501,6 +1510,7 @@ class Limoka(loader.Module): { "text": self.strings.get("close", "❌ Close"), "action": "close", + "style": "danger", } ], ], @@ -1520,6 +1530,7 @@ class Limoka(loader.Module): { "text": self.strings.get("close", "❌ Close"), "action": "close", + "style": "danger", } ], ], @@ -1552,7 +1563,7 @@ class Limoka(loader.Module): ] ) buttons.append( - [{"text": self.strings.get("close", "❌ Close"), "action": "close"}] + [{"text": self.strings.get("close", "❌ Close"), "action": "close", "style": "danger"}] ) await call.edit(text=text[:4096], reply_markup=buttons) @@ -1711,4 +1722,4 @@ class Limoka(loader.Module): await asyncio.sleep(5) await message.delete() except Exception: - pass + pass \ No newline at end of file