feat(subs): UNFINISHED hwid control

This commit is contained in:
agony
2026-06-16 16:24:02 +07:00
parent 7ab2293fe2
commit edfe1e6874
6 changed files with 55 additions and 7 deletions

View File

@@ -4,12 +4,13 @@ from aiogram.fsm.context import FSMContext
from aiogram.types import CallbackQuery, Message
from sqlalchemy.ext.asyncio import AsyncSession
from bot.keyboards.client import close_kb, main_menu, subscription_controls
from bot.keyboards.client import close_kb, construct_devices_list, main_menu, subscription_controls
from bot.keyboards.common import return_to_menu
from bot.texts import (
CALLBACK_FALLBACK,
FAQ_TEXT,
GENERAL_PROCESSING,
NO_CONNECTIONS,
NO_SUBSCRIPTION,
)
from db.models.users import User
@@ -17,7 +18,7 @@ from misc import utils
from misc.utils import build_main_menu_text, format_subscription_link
from schemas.di import DependenciesDTO
from schemas.subscriptions import InternalSquads, SubscriptionPlan
from services.rw import get_user_by_telegram_id
from services.rw import get_hwid_list, get_user_by_telegram_id
router = Router()
@@ -34,7 +35,7 @@ async def fetch_referal(
data = command.args.split("_")
if not data:
await standard_start(msg, command, state)
await standard_start(msg, state, session, deps)
return
referal = int(data[1])
@@ -126,7 +127,7 @@ async def sub_info(
return
if not user:
await cb.answer("1" + CALLBACK_FALLBACK)
await cb.answer(CALLBACK_FALLBACK)
return
if rw_user and not sub:
@@ -146,7 +147,7 @@ async def sub_info(
plan_price_paid=utils.calculate_price(dto),
)
except Exception:
await cb.answer("2" + CALLBACK_FALLBACK)
await cb.answer(CALLBACK_FALLBACK)
return
await cb.message.edit_text(
@@ -158,6 +159,25 @@ async def sub_info(
),
)
@router.callback_query(F.data == "hwid_control")
async def hwid_control(cb: CallbackQuery, state: FSMContext, deps: DependenciesDTO):
await state.clear()
await cb.message.edit_text(GENERAL_PROCESSING, reply_markup=close_kb)
rw_user = await get_user_by_telegram_id(deps.rw_sdk, cb.from_user.id)
if not rw_user:
await cb.message.edit_text(NO_SUBSCRIPTION, reply_markup=return_to_menu)
return
devices = await get_hwid_list(deps.rw_sdk, rw_user.uuid)
if not devices:
await cb.message.edit_text(NO_CONNECTIONS, reply_markup=return_to_menu)
return
await cb.message.edit_text(text="pepe", reply_markup=construct_devices_list(devices))
@router.callback_query(F.data == "toggle:autorenewal")
async def toggle_autorenewal(