Refactor bot handlers and keyboards; implement admin features
- Removed unused prehandling, referrals, support, and states files. - Updated admin and client handlers to improve structure and functionality. - Introduced admin filters and routers for better access control. - Added new billing and deposit functionalities for client interactions. - Enhanced keyboard layouts for admin and client menus. - Implemented promotion handling for admin users. - Updated configuration to include admin settings. - Improved utility functions for quote fetching and menu text building. - Added common handlers for undefined commands and message deletions.
This commit is contained in:
36
bot/handlers/admins/admins.py
Normal file
36
bot/handlers/admins/admins.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from aiogram import F, Router
|
||||
from aiogram.filters import Command
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.types import CallbackQuery, Message
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from bot.filters.admins import AdminFilter
|
||||
from bot.keyboards.admins import main_menu
|
||||
from misc.utils import build_adm_main_menu_text
|
||||
from schemas.di import DependenciesDTO
|
||||
|
||||
router = Router()
|
||||
|
||||
|
||||
@router.message(AdminFilter(), Command(commands=["start", "cancel"]))
|
||||
async def standard_start(
|
||||
msg: Message, state: FSMContext, session: AsyncSession, deps: DependenciesDTO
|
||||
):
|
||||
await state.clear()
|
||||
|
||||
users = await deps.user_repository.user_count(session)
|
||||
await msg.answer(
|
||||
build_adm_main_menu_text(user_count=users, user_id=msg.from_user.id), reply_markup=main_menu
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(AdminFilter(), F.data == "menu:main")
|
||||
async def main_menu_cb(
|
||||
cb: CallbackQuery, state: FSMContext, session: AsyncSession, deps: DependenciesDTO
|
||||
):
|
||||
await state.clear()
|
||||
|
||||
users = await deps.user_repository.user_count(session)
|
||||
await cb.message.edit_text(
|
||||
build_adm_main_menu_text(user_count=users, user_id=cb.from_user.id), reply_markup=main_menu
|
||||
)
|
||||
Reference in New Issue
Block a user