Задать вопрос
Ответы пользователя по тегу Telegram
  • Бот отвечает только на /start, остальное игнорирует. Почему?

    import telebot
    from telebot import types
    
    bot = telebot.TeleBot("TOKEN")
    
    @bot.message_handler(commands=['start'])
    def send_welcome(message):
        bot.send_message(message.chat.id, 'Приветствие'.format(message.from_user, bot.get_me()), parse_mode='html')
    
    @bot.message_handler(content_types=['text', 'photo'])
    def send_reply(message):
        if message.text:
            text = message.text.lower()  # Приводим текст сообщения к нижнему регистру
            if text == 'привет':
                bot.send_message(message.chat.id, 'Ответ')
            elif text == 'текст_1':
                bot.send_photo(message.chat.id, 'URL')
            elif text == 'текст_2':
                bot.send_photo(message.chat.id, 'URL')
            elif text == 'текст_3':
                bot.send_photo(message.chat.id, 'URL')
            elif text == 'текст_4':
                bot.send_photo(message.chat.id, 'URL')
            elif text == 'текст_5':
                bot.send_photo(message.chat.id, 'URL')
            else:
                bot.send_message(message.chat.id, 'Я тебя не понимаю...')
        elif message.photo:
            bot.send_message(message.chat.id, 'Вы отправили фото!')
    
    bot.polling(none_stop=True)
    Ответ написан
    Комментировать