From 4fb6c5afd5005237eed65693bd2f5e35eb995e48 Mon Sep 17 00:00:00 2001 From: JustYay Date: Tue, 10 Feb 2026 16:51:39 +1000 Subject: [PATCH] webapp open in browser option --- handlers/admin/settings/settings_config.py | 1 + handlers/instructions/instructions.py | 1 + handlers/keys/key_mode/key_cluster_mode.py | 8 ++++++-- handlers/keys/key_mode/key_country_mode.py | 7 ++++++- handlers/keys/key_view.py | 6 ++++++ handlers/notifications/special_notifications.py | 7 ++++++- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/handlers/admin/settings/settings_config.py b/handlers/admin/settings/settings_config.py index 8f315f43..7ad5ca69 100644 --- a/handlers/admin/settings/settings_config.py +++ b/handlers/admin/settings/settings_config.py @@ -60,6 +60,7 @@ MODES_TITLES: Final[dict[str, str]] = { "RANDOM_SUBSCRIPTIONS_ENABLED": "Случайные страны", "COUNTRY_SELECTION_ENABLED": "Режим стран", "REMNAWAVE_WEBAPP_ENABLED": "Remna WebApp", + "REMNAWAVE_WEBAPP_OPEN_IN_BROWSER": "WebApp в браузере", "HAPP_CRYPTOLINK_ENABLED": "Happ-ссылки", "LEGACY_LINKS_ENABLED": "Старые ссылки", "DIRECT_START_DISABLED": "Тихий режим", diff --git a/handlers/instructions/instructions.py b/handlers/instructions/instructions.py index 9d8481a9..58d15728 100644 --- a/handlers/instructions/instructions.py +++ b/handlers/instructions/instructions.py @@ -14,6 +14,7 @@ from config import ( DOWNLOAD_PC, HAPP_CRYPTOLINK, REMNAWAVE_WEBAPP, + REMNAWAVE_WEBAPP_OPEN_IN_BROWSER, SUPPORT_CHAT_URL, WEBHOOK_HOST, ) diff --git a/handlers/keys/key_mode/key_cluster_mode.py b/handlers/keys/key_mode/key_cluster_mode.py index f3a2e8b1..81376019 100644 --- a/handlers/keys/key_mode/key_cluster_mode.py +++ b/handlers/keys/key_mode/key_cluster_mode.py @@ -15,7 +15,7 @@ from aiogram.utils.keyboard import InlineKeyboardBuilder from sqlalchemy import update from bot import bot -from config import REMNAWAVE_WEBAPP, SUPPORT_CHAT_URL +from config import REMNAWAVE_WEBAPP, REMNAWAVE_WEBAPP_OPEN_IN_BROWSER, SUPPORT_CHAT_URL from core.bootstrap import BUTTONS_CONFIG, MODES_CONFIG from database import ( get_key_details, @@ -216,6 +216,7 @@ async def key_cluster_mode( else: if await is_full_remnawave_cluster(least_loaded_cluster, session): use_webapp = bool(MODES_CONFIG.get("REMNAWAVE_WEBAPP_ENABLED", REMNAWAVE_WEBAPP)) + open_in_browser = bool(MODES_CONFIG.get("REMNAWAVE_WEBAPP_OPEN_IN_BROWSER", REMNAWAVE_WEBAPP_OPEN_IN_BROWSER)) if use_webapp and final_link: use_webapp = await process_remnawave_webapp_override( remnawave_webapp=use_webapp, @@ -229,7 +230,10 @@ async def key_cluster_mode( and isinstance(final_link, str) and final_link.startswith(("http://", "https://")) ): - builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=final_link))) + if open_in_browser: + builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, url=final_link)) + else: + builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=final_link))) if tv_button_enabled: builder.row(InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|{email}")) else: diff --git a/handlers/keys/key_mode/key_country_mode.py b/handlers/keys/key_mode/key_country_mode.py index 1544a2b3..ac2b76db 100644 --- a/handlers/keys/key_mode/key_country_mode.py +++ b/handlers/keys/key_mode/key_country_mode.py @@ -22,6 +22,7 @@ from config import ( REMNAWAVE_LOGIN, REMNAWAVE_PASSWORD, REMNAWAVE_WEBAPP, + REMNAWAVE_WEBAPP_OPEN_IN_BROWSER, SUPPORT_CHAT_URL, ) from core.bootstrap import BUTTONS_CONFIG, MODES_CONFIG @@ -756,6 +757,7 @@ async def finalize_key_creation( ) use_webapp = bool(MODES_CONFIG.get("REMNAWAVE_WEBAPP_ENABLED", REMNAWAVE_WEBAPP)) + open_in_browser = bool(MODES_CONFIG.get("REMNAWAVE_WEBAPP_OPEN_IN_BROWSER", REMNAWAVE_WEBAPP_OPEN_IN_BROWSER)) if use_webapp and webapp_url: use_webapp = await process_remnawave_webapp_override( remnawave_webapp=use_webapp, @@ -770,7 +772,10 @@ async def finalize_key_creation( builder.row(InlineKeyboardButton(text=ROUTER_BUTTON, callback_data=f"connect_router|{key_name}")) else: if use_webapp and webapp_url: - builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=webapp_url))) + if open_in_browser: + builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, url=webapp_url)) + else: + builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=webapp_url))) if tv_button_enabled: builder.row(InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|{email}")) else: diff --git a/handlers/keys/key_view.py b/handlers/keys/key_view.py index 1eda0788..a15f07b5 100644 --- a/handlers/keys/key_view.py +++ b/handlers/keys/key_view.py @@ -23,6 +23,7 @@ from config import ( REMNAWAVE_LOGIN, REMNAWAVE_PASSWORD, REMNAWAVE_WEBAPP, + REMNAWAVE_WEBAPP_OPEN_IN_BROWSER, TOGGLE_CLIENT, USE_COUNTRY_SELECTION, ) @@ -393,6 +394,7 @@ async def build_key_view_payload(session: AsyncSession, key_name: str): country_selection_enabled = bool(MODES_CONFIG.get("COUNTRY_SELECTION_ENABLED", USE_COUNTRY_SELECTION)) remnawave_webapp_enabled = bool(MODES_CONFIG.get("REMNAWAVE_WEBAPP_ENABLED", REMNAWAVE_WEBAPP)) + open_in_browser = bool(MODES_CONFIG.get("REMNAWAVE_WEBAPP_OPEN_IN_BROWSER", REMNAWAVE_WEBAPP_OPEN_IN_BROWSER)) happ_cryptolink_enabled = bool(MODES_CONFIG.get("HAPP_CRYPTOLINK_ENABLED", HAPP_CRYPTOLINK)) response_message = key_message( @@ -423,6 +425,10 @@ async def build_key_view_payload(session: AsyncSession, key_name: str): if is_full_remnawave and final_link and use_webapp and not happ_cryptolink_enabled: if vless_enabled: builder.row(InlineKeyboardButton(text=ROUTER_BUTTON, callback_data=f"connect_router|{key_name}")) + elif open_in_browser: + builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, url=final_link)) + if tv_button_enabled: + builder.row(InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|{key_name}")) else: builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=final_link))) if tv_button_enabled: diff --git a/handlers/notifications/special_notifications.py b/handlers/notifications/special_notifications.py index e7d43db2..2dfa71ee 100644 --- a/handlers/notifications/special_notifications.py +++ b/handlers/notifications/special_notifications.py @@ -13,6 +13,7 @@ from config import ( NOTIFY_INACTIVE, NOTIFY_INACTIVE_TRAFFIC, REMNAWAVE_WEBAPP, + REMNAWAVE_WEBAPP_OPEN_IN_BROWSER, SUPPORT_CHAT_URL, ) from core.bootstrap import MODES_CONFIG, NOTIFICATIONS_CONFIG @@ -141,6 +142,7 @@ async def notify_users_no_traffic(bot: Bot, session: AsyncSession, current_time: return remnawave_webapp_enabled = bool(MODES_CONFIG.get("REMNAWAVE_WEBAPP_ENABLED", REMNAWAVE_WEBAPP)) + open_in_browser = bool(MODES_CONFIG.get("REMNAWAVE_WEBAPP_OPEN_IN_BROWSER", REMNAWAVE_WEBAPP_OPEN_IN_BROWSER)) messages = [] keys_to_mark_notified = [] @@ -195,7 +197,10 @@ async def notify_users_no_traffic(bot: Bot, session: AsyncSession, current_time: final_link = key.key or key.remnawave_link if is_full_remnawave and final_link and remnawave_webapp_enabled: - builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=final_link))) + if open_in_browser: + builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, url=final_link)) + else: + builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=final_link))) else: builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, callback_data=f"connect_device|{email}")) except Exception as error: