From b657b9e95cce5e69b2d4dbee82d5b8f9ed3201d9 Mon Sep 17 00:00:00 2001 From: Egor Date: Sun, 12 Oct 2025 07:15:37 +0300 Subject: [PATCH] Fix broadcast buttons opening miniapp in text menu mode --- app/handlers/admin/messages.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/app/handlers/admin/messages.py b/app/handlers/admin/messages.py index 3f58fcd4..87d1b126 100644 --- a/app/handlers/admin/messages.py +++ b/app/handlers/admin/messages.py @@ -28,12 +28,21 @@ from app.localization.texts import get_texts from app.database.crud.user import get_users_list from app.database.crud.subscription import get_expiring_subscriptions from app.utils.decorators import admin_required, error_handler +from app.utils.miniapp_buttons import build_miniapp_or_callback_button logger = logging.getLogger(__name__) BUTTON_ROWS = BROADCAST_BUTTON_ROWS DEFAULT_SELECTED_BUTTONS = DEFAULT_BROADCAST_BUTTONS +TEXT_MENU_MINIAPP_BUTTON_KEYS = { + "balance", + "referrals", + "promocode", + "connect", + "subscription", +} + def get_message_buttons_selector_keyboard(language: str = "ru") -> types.InlineKeyboardMarkup: return get_updated_message_buttons_selector_keyboard(list(DEFAULT_SELECTED_BUTTONS), language) @@ -54,12 +63,20 @@ def create_broadcast_keyboard(selected_buttons: list, language: str = "ru") -> O if button_key not in selected_buttons: continue button_config = button_config_map[button_key] - row_buttons.append( - types.InlineKeyboardButton( - text=button_config["text"], - callback_data=button_config["callback"] + if settings.is_text_main_menu_mode() and button_key in TEXT_MENU_MINIAPP_BUTTON_KEYS: + row_buttons.append( + build_miniapp_or_callback_button( + text=button_config["text"], + callback_data=button_config["callback"], + ) + ) + else: + row_buttons.append( + types.InlineKeyboardButton( + text=button_config["text"], + callback_data=button_config["callback"] + ) ) - ) if row_buttons: keyboard.append(row_buttons)