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

31 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

# app/bot/handlers/help.py
from flask import Flask
from telebot.types import Message
from telebot import logger, TeleBot
from app.bot.constants import UserStates
from app.bot.keyboards.main_menu import get_main_menu
from app.bot.states import UserStateManager
from app.bot.utils.auth import auth
from config import HELP_URL
def register_handlers(bot: TeleBot,app: Flask,state_manager: UserStateManager):
@bot.message_handler(commands=['help'])
@bot.message_handler(func=lambda msg: msg.text == "Помощь")
def handle_help(message: Message):
chat_id = message.chat.id
username = f"{message.from_user.username}" if message.from_user.username else "N/A"
with app.app_context():
if not auth(chat_id, app):
bot.send_message(chat_id, "❌ Вы не авторизованы для использования этого бота.")
logger.warning(f"Неавторизованный пользователь {chat_id} @{username}")
state_manager.set_state(chat_id, UserStates.REGISTRATION)
return
help_text = (
'<b>/start</b> - Показать меню бота\n'
'<b>Настройки</b> - Перейти в режим настроек и управления подписками\n'
'<b>Активные события</b> - Получение всех нерешённых событий мониторинга по выбранным сервисам выбранного региона\n'
f'<b>Помощь</b> - <a href="{HELP_URL}">Описание всех возможностей бота</a>')
bot.send_message(message.chat.id, help_text, parse_mode="HTML", reply_markup=get_main_menu())