@ere123242

Бот в телеграмме отвечает 2 раза подряд. Что делать?

Бот почему то отвечает 2 раза подряд.(Url и Ссылку на сайт убрал специально, а так она есть)
import telebot
from telebot import types

token=''
bot = telebot.TeleBot(token)
@bot.message_handler(commands=['start'])
def start_message(message):
    markup= types.ReplyKeyboardMarkup(resize_keyboard=True)
    item1 = types.KeyboardButton('Алкогольне')
    item2 = types.KeyboardButton('Десертные')
    item3 = types.KeyboardButton('Кислые')
    item4 = types.KeyboardButton('Кофейные')
    item5 = types.KeyboardButton('Молочные')
    item6 = types.KeyboardButton('Освежающие')
    item7 = types.KeyboardButton('Табачные')
    item8 = types.KeyboardButton('Фруктовые')
    item9 = types.KeyboardButton('Чайные')
    item10 = types.KeyboardButton('Ягодные')

    markup.add(item1, item2, item3, item4, item5, item6, item7, item8, item9, item10)

    bot.send_message(message.chat.id, ', {0.first_name}!'.format(message.from_user), reply_markup= markup)

@bot.message_handler(content_types=['text'])
def start_message(message):
    if message.chat.type == 'private':
        if message.text == 'Алкогольне':     
            from bs4 import BeautifulSoup
            import requests
                
            url = ""
            #Insert the link and put a random user-agent

            requests = requests.get(url)
            soup = BeautifulSoup(requests.text, "html.parser")
            teme = soup.find_all('div', class_='row')
            #Cooking Soup

            for temes  in teme:
                temes = temes.find("a", {'class' : 'card-title'})
                if temes is not None:
                    url_title = (temes.text)
                    bot.send_message(message.chat.id, url_title)

            for temes  in teme:
                temes = temes.find("p", {'class' : 'card-text'})
                if temes is not None:
                    url_title = (temes.text)
                    bot.send_message(message.chat.id, "Вкус: "+(url_title))
bot.infinity_polling()
  • Вопрос задан
  • 36 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы