- Added notifications for successful payments in `api/core/notifications.py`. - Created main API entry point in `api/main.py` with FastAPI integration. - Established routing structure in `api/routes/__init__.py` and `api/routes/pally.py` for handling payment callbacks. - Developed billing handlers in `bot/handlers/billing.py` and `bot/handlers/buy.py` for subscription management. - Introduced state management for user interactions in `bot/states/`. - Created user interface elements in `bot/keyboards/` for navigation and payment processing. - Set up middleware for dependency injection in `bot/middlewares/di.py`. - Added support for user commands and interactions in `bot/handlers/common.py` and `bot/handlers/support.py`. - Implemented logging and error handling throughout the bot's functionality. - Created entry point script for API server in `entrypoints/api.sh`.
29 lines
960 B
Python
29 lines
960 B
Python
from aiogram import F, Router
|
|
from aiogram.fsm.context import FSMContext
|
|
from aiogram.types import CallbackQuery
|
|
from aiogram.utils.deep_linking import create_start_link
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from bot.keyboards.client import referals_kb
|
|
from bot.texts import REFERALS_MENU
|
|
from misc.utils import format_share_deep_link
|
|
from schemas.di import DependenciesDTO
|
|
|
|
router = Router()
|
|
|
|
|
|
@router.callback_query(F.data == "referal")
|
|
async def referal_menu(
|
|
cb: CallbackQuery, state: FSMContext, session: AsyncSession, deps: DependenciesDTO
|
|
):
|
|
await state.clear()
|
|
|
|
user = await deps.user_repository.get_user_by_id(session, cb.from_user.id)
|
|
referal_link = await create_start_link(cb.bot, f"ref_{user.id}", encode=True)
|
|
share_link = format_share_deep_link(referal_link)
|
|
|
|
await cb.message.edit_text(
|
|
REFERALS_MENU.format(balance=user.balance, link=referal_link),
|
|
reply_markup=referals_kb(share_link),
|
|
)
|