Telezab/app/bot/handlers/cancel_input.py
UdoChudo ccb47d527f
All checks were successful
Build and Push Docker Images / build (push) Successful in 1m28s
refactor: modularize Telegram bot and add RabbitMQ client foundation
- Рефакторинг Telegram бота на модульную структуру для удобства поддержки и расширения
- Создан общий RabbitMQ клиент для Flask и Telegram компонентов
- Подготовлена базовая архитектура для будущего масштабирования и новых функций

Signed-off-by: UdoChudo <stream@udochudo.ru>
2025-06-16 09:08:46 +05:00

23 lines
990 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from telebot.types import CallbackQuery
from telebot import TeleBot
from app.bot.constants import UserStates
from app.bot.keyboards.main_menu import get_main_menu
from app.bot.states import UserStateManager
def register_callback_cancel_input(bot: TeleBot, state_manager: UserStateManager):
@bot.callback_query_handler(func=lambda call: call.data == "cancel_input")
def handle_cancel_input(call: CallbackQuery):
chat_id = call.message.chat.id
message_id = call.message.message_id
# Сброс состояния
state_manager.set_state(chat_id, UserStates.MAIN_MENU)
# Удаляем сообщение с кнопкой "Отмена"
bot.delete_message(chat_id, message_id)
bot.answer_callback_query(call.id)
bot.clear_step_handler_by_chat_id(chat_id)
# Отправляем главное меню
bot.send_message(chat_id, "❌ Действие отменено.", reply_markup=get_main_menu())