first com2
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from .menus import router as menus_router
|
||||
from .support import router as support_router
|
||||
|
||||
routers = [menus_router]
|
||||
routers = [menus_router, support_router]
|
||||
|
||||
10
handlers/buy.py
Normal file
10
handlers/buy.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from aiogram import Router
|
||||
from aiogram.types import CallbackQuery
|
||||
from aiogram.fsm.context import FSMContext
|
||||
|
||||
from dto.di import DependenciesDTO
|
||||
|
||||
|
||||
router = Router()
|
||||
|
||||
# @router.callback_query()
|
||||
@@ -1,11 +1,12 @@
|
||||
from aiogram import Router
|
||||
from aiogram.filters import CommandStart, CommandObject
|
||||
from aiogram.types import Message
|
||||
from aiogram import Router, F
|
||||
from aiogram.filters import CommandStart, CommandObject, Command
|
||||
from aiogram.types import CallbackQuery, Message
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from dto.di import DependenciesDTO
|
||||
from keyboards.client import main_menu
|
||||
from texts import build_main_menu_text
|
||||
|
||||
router = Router()
|
||||
|
||||
@@ -28,19 +29,26 @@ async def fetch_referal(
|
||||
referal = data[0]
|
||||
await deps.user_service.add_user(session, user_id=msg.from_user.id, referal=referal)
|
||||
|
||||
await msg.reply(f"hi but....{referal}", reply_markup=main_menu)
|
||||
await msg.reply(build_main_menu_text(), reply_markup=main_menu)
|
||||
|
||||
|
||||
@router.message(CommandStart(deep_link=False))
|
||||
async def standard_start(msg: Message, command: CommandObject, state: FSMContext):
|
||||
await msg.reply("hii!", reply_markup=main_menu)
|
||||
@router.message(Command(commands=["start", "cancel"]))
|
||||
async def standard_start(
|
||||
msg: Message,
|
||||
command: CommandObject,
|
||||
state: FSMContext,
|
||||
session: AsyncSession,
|
||||
deps: DependenciesDTO,
|
||||
):
|
||||
await state.clear()
|
||||
|
||||
await deps.user_service.add_user(session, user_id=msg.from_user.id)
|
||||
|
||||
await msg.reply(build_main_menu_text(), reply_markup=main_menu)
|
||||
|
||||
|
||||
# INSANE HOW UNSTABLE THIS FUCKING SYSTEM IS
|
||||
# EVEN AFTER ROLLING EVERYTHING BACK
|
||||
# HALF OF MY APPS STILL DONT WORK
|
||||
# I FUCKING HATE THIS SHIT
|
||||
# I CANT PACMAN -SYU CUZ IT BREAKS NVIDIA DRIVERS AND MY 240HZ MONITOR
|
||||
# IS IN FUCKING 3 FPS **CONSTANTLY**
|
||||
# I CANT MAKE IT UP AND I REALLY CANT TAE IT ANYMORE.
|
||||
# wrap it up bud. we're gonna reset everything. bye. o7
|
||||
@router.callback_query(F.data == "menu:main")
|
||||
async def main_menu_cb(cb: CallbackQuery, state: FSMContext):
|
||||
await state.clear()
|
||||
|
||||
await cb.message.edit_text(build_main_menu_text(), reply_markup=main_menu)
|
||||
|
||||
69
handlers/support.py
Normal file
69
handlers/support.py
Normal file
@@ -0,0 +1,69 @@
|
||||
import logging
|
||||
from aiogram import Router, F
|
||||
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 dto.di import DependenciesDTO
|
||||
from services.user_service import UserServiceException
|
||||
from states.support import SupportStorage
|
||||
from texts import GENERAL_PROCESSING, STANDARD_FALLBACK, SUPPORT_INIT, SUPPORT_MSG_SENT
|
||||
from keyboards.client import return_to_menu
|
||||
|
||||
router = Router()
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@router.callback_query(F.data == "support")
|
||||
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(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 UserServiceException:
|
||||
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"),
|
||||
)
|
||||
async def handle_admin_message(
|
||||
msg: Message, state: FSMContext, session: AsyncSession, deps: DependenciesDTO
|
||||
):
|
||||
await state.clear()
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user