feat: enhance subscription management with discount calculations and update support messages
This commit is contained in:
@@ -4,14 +4,9 @@ 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 config import settings
|
||||
from keyboards.client import return_to_menu
|
||||
from schemas.di import DependenciesDTO
|
||||
from services.user_service import UserServiceError
|
||||
from states.support import SupportStorage
|
||||
from texts import GENERAL_PROCESSING, STANDARD_FALLBACK, SUPPORT_INIT, SUPPORT_MSG_SENT
|
||||
from texts import SUPPORT_INIT
|
||||
|
||||
router = Router()
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -22,7 +17,6 @@ async def support_init(cb: CallbackQuery, state: FSMContext):
|
||||
await state.clear()
|
||||
|
||||
await cb.message.edit_text(text=SUPPORT_INIT, reply_markup=return_to_menu)
|
||||
await state.set_state(SupportStorage.prompt)
|
||||
|
||||
|
||||
@router.message(Command("support"))
|
||||
@@ -31,60 +25,3 @@ async def support_init_cmd(msg: Message, state: FSMContext):
|
||||
await msg.delete()
|
||||
|
||||
await msg.answer(text=SUPPORT_INIT, reply_markup=return_to_menu)
|
||||
await state.set_state(SupportStorage.prompt)
|
||||
|
||||
|
||||
@router.message(SupportStorage.prompt)
|
||||
async def received_message(
|
||||
msg: Message, state: FSMContext, session: AsyncSession, deps: DependenciesDTO
|
||||
):
|
||||
await state.clear()
|
||||
|
||||
notification_msg = await msg.reply(GENERAL_PROCESSING)
|
||||
|
||||
try:
|
||||
await deps.user_service.support_forward_message(session, msg, deps.rw_sdk)
|
||||
except UserServiceError:
|
||||
await msg.reply(STANDARD_FALLBACK)
|
||||
raise
|
||||
except Exception:
|
||||
await msg.reply(STANDARD_FALLBACK)
|
||||
logger.exception("Exception occured while trying to forward a msg to support")
|
||||
raise
|
||||
|
||||
await notification_msg.edit_text(SUPPORT_MSG_SENT, reply_markup=return_to_menu)
|
||||
await state.set_state(SupportStorage.prompt)
|
||||
|
||||
|
||||
@router.message(
|
||||
F.chat.id == settings.admin_group_id,
|
||||
F.message_thread_id.is_not(None),
|
||||
F.from_user.is_bot == False, # noqa: E712
|
||||
~Command("close"),
|
||||
~Command("refpay"),
|
||||
)
|
||||
async def handle_admin_message(
|
||||
msg: Message, state: FSMContext, session: AsyncSession, deps: DependenciesDTO
|
||||
):
|
||||
await state.clear()
|
||||
print(str(msg))
|
||||
|
||||
await deps.user_service.support_answer(session, msg)
|
||||
|
||||
|
||||
@router.message(F.chat.id == settings.admin_group_id, Command("close"))
|
||||
async def close_ticket(
|
||||
msg: Message, state: FSMContext, session: AsyncSession, deps: DependenciesDTO
|
||||
):
|
||||
await state.clear()
|
||||
|
||||
await deps.user_service.close_ticket(session, msg)
|
||||
|
||||
|
||||
@router.callback_query(F.message.chat.id == settings.admin_group_id, F.data == "close")
|
||||
async def close_ticket_cb(
|
||||
cb: CallbackQuery, state: FSMContext, session: AsyncSession, deps: DependenciesDTO
|
||||
):
|
||||
await state.clear()
|
||||
|
||||
await deps.user_service.close_ticket(session, cb.message)
|
||||
|
||||
Reference in New Issue
Block a user