feat: enhance subscription management with discount calculations and update support messages
This commit is contained in:
@@ -4,9 +4,10 @@ from aiogram.fsm.context import FSMContext
|
||||
from aiogram.types import CallbackQuery, Message
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from keyboards.client import main_menu, return_to_menu
|
||||
from keyboards.client import close_kb, main_menu, return_to_menu
|
||||
from misc.utils import build_main_menu_text, format_subscription_link
|
||||
from schemas.di import DependenciesDTO
|
||||
from services.rw import get_user_by_telegram_id
|
||||
from texts import FAQ_TEXT, GENERAL_PROCESSING
|
||||
|
||||
router = Router()
|
||||
@@ -32,7 +33,7 @@ async def fetch_referal(
|
||||
session, user_id=msg.from_user.id, referal=referal, rw_sdk=deps.rw_sdk
|
||||
)
|
||||
|
||||
await msg.reply(
|
||||
await msg.answer(
|
||||
build_main_menu_text(format_subscription_link(user.subscription_link)),
|
||||
reply_markup=main_menu,
|
||||
)
|
||||
@@ -49,7 +50,7 @@ async def standard_start(
|
||||
|
||||
user = await deps.user_service.add_user(session, user_id=msg.from_user.id, rw_sdk=deps.rw_sdk)
|
||||
|
||||
await msg.reply(
|
||||
await msg.answer(
|
||||
build_main_menu_text(format_subscription_link(user.subscription_link)),
|
||||
reply_markup=main_menu,
|
||||
)
|
||||
@@ -88,3 +89,19 @@ async def faq(cb: CallbackQuery, state: FSMContext):
|
||||
await state.clear()
|
||||
|
||||
await cb.message.edit_text(FAQ_TEXT, reply_markup=return_to_menu)
|
||||
|
||||
|
||||
@router.callback_query(F.data == "sub_info")
|
||||
async def sub_info(
|
||||
cb: CallbackQuery, state: FSMContext, deps: DependenciesDTO, session: AsyncSession
|
||||
):
|
||||
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)
|
||||
user = await deps.user_service.update_user_link(session, cb.from_user.id, deps.rw_sdk)
|
||||
|
||||
await cb.message.edit_text(
|
||||
deps.user_service.format_subscription_message(rw_user, link=user.subscription_link),
|
||||
reply_markup=return_to_menu,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user