updaded start.py & config.py
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
import logging
|
||||
|
||||
from config import MESSAGE_FOR_START
|
||||
from config import COMMAND_MESSAGES
|
||||
|
||||
logger = logging.getLogger(__name__) # Получаем логгер для текущего модуля
|
||||
|
||||
@ -9,8 +9,15 @@ def register_handlers(bot: AsyncTeleBot): # Регистрирует все об
|
||||
|
||||
@bot.message_handler(commands=['start']) # Обработчик команды /start
|
||||
async def start_command(message):
|
||||
|
||||
# Отправка сообщения в тему или обычный чат
|
||||
send_message = bot.reply_to if message.is_topic_message else bot.send_message
|
||||
chat_id = message if message.is_topic_message else message.chat.id
|
||||
|
||||
try:
|
||||
logger.info(f"Команда START ({message.from_user.id})")
|
||||
await bot.send_message(message.chat.id, MESSAGE_FOR_START)
|
||||
|
||||
await send_message(chat_id, COMMAND_MESSAGES['start'])
|
||||
logger.info(f"Пользователь {message.from_user.id} запустил /start")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Команда START ({message.from_user.id}) {str(e)}")
|
||||
logger.error(f"Пользователь {message.from_user.id} запустил /start: {str(e)}")
|
Reference in New Issue
Block a user