diff --git a/bot/handlers/start.py b/bot/handlers/start.py index 1b001dd..e6d4dab 100644 --- a/bot/handlers/start.py +++ b/bot/handlers/start.py @@ -96,6 +96,7 @@ async def on_bot_started(event: BotStarted, context: BaseContext) -> None: @router.message_created(Command("start")) async def on_start_command(event: MessageCreated, context: BaseContext) -> None: + """commands_info: Главное меню""" chat_id, user_id = event.get_ids() if user_id is None or chat_id is None: return @@ -237,3 +238,72 @@ async def on_contact_shared( text=menu_text, attachments=[main_menu_kb()], ) + + +# ── /menu ───────────────────────────────────────────────────────────────────── + +@router.message_created(Command("menu")) +async def on_menu_command(event: MessageCreated, context: BaseContext) -> None: + """commands_info: Показать меню""" + chat_id, user_id = event.get_ids() + if user_id is None or chat_id is None: + return + + bot_user = await get_bot_user_by_max_id(user_id) + if not bot_user or not bot_user["is_authorized"]: + return + + from bot.handlers.create_ticket import cleanup_ticket_flow + await cleanup_ticket_flow(event.bot, context) + await context.set_state(None) + + from bot.handlers.menu import build_main_menu_text + await bot_send( + event.bot, + chat_id=chat_id, + user_id=user_id, + text=await build_main_menu_text(bot_user), + attachments=[main_menu_kb()], + ) + + +# ── /cancel ─────────────────────────────────────────────────────────────────── + +@router.message_created(Command("cancel")) +async def on_cancel_command(event: MessageCreated, context: BaseContext) -> None: + """commands_info: Отменить текущее действие""" + chat_id, user_id = event.get_ids() + if user_id is None or chat_id is None: + return + + bot_user = await get_bot_user_by_max_id(user_id) + if not bot_user or not bot_user["is_authorized"]: + return + + from bot.handlers.create_ticket import cleanup_ticket_flow + from bot.states import CommentStates, TicketStates + + state = await context.get_state() + active_states = [ + TicketStates.waiting_description, + TicketStates.collecting_attachments, + TicketStates.confirming, + CommentStates.waiting_text, + ] + + if state in active_states: + await cleanup_ticket_flow(event.bot, context) + cancel_text = "❌ Действие отменено.\n\n" + else: + cancel_text = "" + + await context.set_state(None) + + from bot.handlers.menu import build_main_menu_text + await bot_send( + event.bot, + chat_id=chat_id, + user_id=user_id, + text=cancel_text + await build_main_menu_text(bot_user), + attachments=[main_menu_kb()], + ) diff --git a/data/support.db-shm b/data/support.db-shm index 36a1946..bc52efb 100644 Binary files a/data/support.db-shm and b/data/support.db-shm differ diff --git a/data/support.db-wal b/data/support.db-wal index dd101ba..7fafbd0 100644 Binary files a/data/support.db-wal and b/data/support.db-wal differ