webapp open in browser option

This commit is contained in:
JustYay
2026-02-10 16:51:39 +10:00
committed by Boris Kovalskii
parent 0aa4cf0996
commit bb8b07c318
6 changed files with 26 additions and 4 deletions
@@ -60,6 +60,7 @@ MODES_TITLES: Final[dict[str, str]] = {
"RANDOM_SUBSCRIPTIONS_ENABLED": "Случайные страны", "RANDOM_SUBSCRIPTIONS_ENABLED": "Случайные страны",
"COUNTRY_SELECTION_ENABLED": "Режим стран", "COUNTRY_SELECTION_ENABLED": "Режим стран",
"REMNAWAVE_WEBAPP_ENABLED": "Remna WebApp", "REMNAWAVE_WEBAPP_ENABLED": "Remna WebApp",
"REMNAWAVE_WEBAPP_OPEN_IN_BROWSER": "WebApp в браузере",
"HAPP_CRYPTOLINK_ENABLED": "Happ-ссылки", "HAPP_CRYPTOLINK_ENABLED": "Happ-ссылки",
"LEGACY_LINKS_ENABLED": "Старые ссылки", "LEGACY_LINKS_ENABLED": "Старые ссылки",
"DIRECT_START_DISABLED": "Тихий режим", "DIRECT_START_DISABLED": "Тихий режим",
+1
View File
@@ -14,6 +14,7 @@ from config import (
DOWNLOAD_PC, DOWNLOAD_PC,
HAPP_CRYPTOLINK, HAPP_CRYPTOLINK,
REMNAWAVE_WEBAPP, REMNAWAVE_WEBAPP,
REMNAWAVE_WEBAPP_OPEN_IN_BROWSER,
SUPPORT_CHAT_URL, SUPPORT_CHAT_URL,
WEBHOOK_HOST, WEBHOOK_HOST,
) )
+5 -1
View File
@@ -15,7 +15,7 @@ from aiogram.utils.keyboard import InlineKeyboardBuilder
from sqlalchemy import update from sqlalchemy import update
from bot import bot 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 core.bootstrap import BUTTONS_CONFIG, MODES_CONFIG
from database import ( from database import (
get_key_details, get_key_details,
@@ -216,6 +216,7 @@ async def key_cluster_mode(
else: else:
if await is_full_remnawave_cluster(least_loaded_cluster, session): if await is_full_remnawave_cluster(least_loaded_cluster, session):
use_webapp = bool(MODES_CONFIG.get("REMNAWAVE_WEBAPP_ENABLED", REMNAWAVE_WEBAPP)) 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: if use_webapp and final_link:
use_webapp = await process_remnawave_webapp_override( use_webapp = await process_remnawave_webapp_override(
remnawave_webapp=use_webapp, remnawave_webapp=use_webapp,
@@ -229,6 +230,9 @@ async def key_cluster_mode(
and isinstance(final_link, str) and isinstance(final_link, str)
and final_link.startswith(("http://", "https://")) and final_link.startswith(("http://", "https://"))
): ):
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))) builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=final_link)))
if tv_button_enabled: if tv_button_enabled:
builder.row(InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|{email}")) builder.row(InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|{email}"))
@@ -22,6 +22,7 @@ from config import (
REMNAWAVE_LOGIN, REMNAWAVE_LOGIN,
REMNAWAVE_PASSWORD, REMNAWAVE_PASSWORD,
REMNAWAVE_WEBAPP, REMNAWAVE_WEBAPP,
REMNAWAVE_WEBAPP_OPEN_IN_BROWSER,
SUPPORT_CHAT_URL, SUPPORT_CHAT_URL,
) )
from core.bootstrap import BUTTONS_CONFIG, MODES_CONFIG 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)) 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: if use_webapp and webapp_url:
use_webapp = await process_remnawave_webapp_override( use_webapp = await process_remnawave_webapp_override(
remnawave_webapp=use_webapp, remnawave_webapp=use_webapp,
@@ -770,6 +772,9 @@ async def finalize_key_creation(
builder.row(InlineKeyboardButton(text=ROUTER_BUTTON, callback_data=f"connect_router|{key_name}")) builder.row(InlineKeyboardButton(text=ROUTER_BUTTON, callback_data=f"connect_router|{key_name}"))
else: else:
if use_webapp and webapp_url: if use_webapp and 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))) builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=webapp_url)))
if tv_button_enabled: if tv_button_enabled:
builder.row(InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|{email}")) builder.row(InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|{email}"))
+6
View File
@@ -23,6 +23,7 @@ from config import (
REMNAWAVE_LOGIN, REMNAWAVE_LOGIN,
REMNAWAVE_PASSWORD, REMNAWAVE_PASSWORD,
REMNAWAVE_WEBAPP, REMNAWAVE_WEBAPP,
REMNAWAVE_WEBAPP_OPEN_IN_BROWSER,
TOGGLE_CLIENT, TOGGLE_CLIENT,
USE_COUNTRY_SELECTION, 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)) 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)) 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)) happ_cryptolink_enabled = bool(MODES_CONFIG.get("HAPP_CRYPTOLINK_ENABLED", HAPP_CRYPTOLINK))
response_message = key_message( 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 is_full_remnawave and final_link and use_webapp and not happ_cryptolink_enabled:
if vless_enabled: if vless_enabled:
builder.row(InlineKeyboardButton(text=ROUTER_BUTTON, callback_data=f"connect_router|{key_name}")) 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: else:
builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=final_link))) builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=final_link)))
if tv_button_enabled: if tv_button_enabled:
@@ -13,6 +13,7 @@ from config import (
NOTIFY_INACTIVE, NOTIFY_INACTIVE,
NOTIFY_INACTIVE_TRAFFIC, NOTIFY_INACTIVE_TRAFFIC,
REMNAWAVE_WEBAPP, REMNAWAVE_WEBAPP,
REMNAWAVE_WEBAPP_OPEN_IN_BROWSER,
SUPPORT_CHAT_URL, SUPPORT_CHAT_URL,
) )
from core.bootstrap import MODES_CONFIG, NOTIFICATIONS_CONFIG 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 return
remnawave_webapp_enabled = bool(MODES_CONFIG.get("REMNAWAVE_WEBAPP_ENABLED", REMNAWAVE_WEBAPP)) 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 = [] messages = []
keys_to_mark_notified = [] keys_to_mark_notified = []
@@ -195,6 +197,9 @@ async def notify_users_no_traffic(bot: Bot, session: AsyncSession, current_time:
final_link = key.key or key.remnawave_link final_link = key.key or key.remnawave_link
if is_full_remnawave and final_link and remnawave_webapp_enabled: if is_full_remnawave and final_link and remnawave_webapp_enabled:
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))) builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=final_link)))
else: else:
builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, callback_data=f"connect_device|{email}")) builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, callback_data=f"connect_device|{email}"))