Merge pull request #258 from JustYay/dev
[Feature] WebAPP Open in browser option
This commit is contained in:
@@ -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": "Тихий режим",
|
||||||
|
|||||||
@@ -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,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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,7 +230,10 @@ 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://"))
|
||||||
):
|
):
|
||||||
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:
|
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}"))
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -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,7 +772,10 @@ 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:
|
||||||
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:
|
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}"))
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -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,7 +197,10 @@ 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:
|
||||||
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:
|
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}"))
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
|||||||
Reference in New Issue
Block a user