From c76c8d65445544448281d072399da604d368472a Mon Sep 17 00:00:00 2001 From: Capybara-z Date: Thu, 5 Jun 2025 19:16:05 +0300 Subject: [PATCH] fix: android tv connection for remnawave --- handlers/instructions/instructions.py | 26 +++++----------------- handlers/keys/key_mode/key_cluster_mode.py | 2 +- handlers/keys/key_mode/key_country_mode.py | 2 +- handlers/keys/key_view.py | 2 +- 4 files changed, 9 insertions(+), 23 deletions(-) diff --git a/handlers/instructions/instructions.py b/handlers/instructions/instructions.py index 1bbc4c3e..95e89126 100644 --- a/handlers/instructions/instructions.py +++ b/handlers/instructions/instructions.py @@ -145,18 +145,11 @@ async def process_macos_menu(callback_query: CallbackQuery, session: Any): @router.callback_query(F.data.startswith("connect_tv|")) async def process_connect_tv(callback_query: CallbackQuery, session: Any): - data = callback_query.data.split("|") - key_name = data[1] - callback_data = callback_query.data - - if key_name == "direct" and len(data) > 2: - callback_data = f"continue_tv|{key_name}|{data[2]}" - else: - callback_data = callback_data.replace("connect_tv", "continue_tv") + key_name = callback_query.data.split("|")[1] builder = InlineKeyboardBuilder() builder.row( - InlineKeyboardButton(text=TV_CONTINUE, callback_data=callback_data) + InlineKeyboardButton(text=TV_CONTINUE, callback_data=f"continue_tv|{key_name}") ) builder.row(InlineKeyboardButton(text=BACK, callback_data=f"view_key|{key_name}")) builder.row(InlineKeyboardButton(text=MAIN_MENU, callback_data="profile")) @@ -172,20 +165,13 @@ async def process_connect_tv(callback_query: CallbackQuery, session: Any): @router.callback_query(F.data.startswith("continue_tv|")) async def process_continue_tv(callback_query: CallbackQuery, session: Any): - data = callback_query.data.split("|") - key_name = data[1] - subscription_link = None - - if key_name == "direct" and len(data) > 2: - subscription_link = data[2] - else: - record = await get_key_details(session, key_name) - subscription_link = record["key"] - + key_name = callback_query.data.split("|")[1] + record = await get_key_details(session, key_name) + subscription_link = record.get("key") or record.get("remnawave_link") message_text = SUBSCRIPTION_DETAILS_TEXT.format(subscription_link=subscription_link) builder = InlineKeyboardBuilder() - builder.row(InlineKeyboardButton(text=BACK, callback_data=f"connect_tv|{key_name}|{subscription_link}" if subscription_link else f"connect_tv|{key_name}")) + builder.row(InlineKeyboardButton(text=BACK, callback_data=f"connect_tv|{key_name}")) builder.row(InlineKeyboardButton(text=MAIN_MENU, callback_data="profile")) await edit_or_send_message( diff --git a/handlers/keys/key_mode/key_cluster_mode.py b/handlers/keys/key_mode/key_cluster_mode.py index c0626a12..509fe40c 100644 --- a/handlers/keys/key_mode/key_cluster_mode.py +++ b/handlers/keys/key_mode/key_cluster_mode.py @@ -153,7 +153,7 @@ async def key_cluster_mode( ) ) builder.row( - InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|direct|{final_link}") + InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|{email}") ) elif CONNECT_PHONE_BUTTON: builder.row( diff --git a/handlers/keys/key_mode/key_country_mode.py b/handlers/keys/key_mode/key_country_mode.py index da9f4728..51df4fd1 100644 --- a/handlers/keys/key_mode/key_country_mode.py +++ b/handlers/keys/key_mode/key_country_mode.py @@ -529,7 +529,7 @@ async def finalize_key_creation( ) ) builder.row( - InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|direct|{public_link or remnawave_link}") + InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|{email}") ) elif CONNECT_PHONE_BUTTON: builder.row( diff --git a/handlers/keys/key_view.py b/handlers/keys/key_view.py index 0030d3df..0d060d39 100644 --- a/handlers/keys/key_view.py +++ b/handlers/keys/key_view.py @@ -327,7 +327,7 @@ async def render_key_info( ) ) builder.row( - InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|direct|{final_link}") + InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|{key_name}") ) else: if CONNECT_PHONE_BUTTON: