Объект TeleBot не содержит атрибут message_handler, хотя должен
import config
import telebot
import requests
from bs4 import BeautifulSoup as BS
bot = telebot.TeleBot(config.token)
@bot.message_handler(commands=['start'])
def main(message):
bot.send_message(message.chat.id, 'Текст')
if __name__ == '__main__':
bot.polling(none_stop=True)
Я пытаюсь написать бота, который по команде отображает цену на сайте, но по неведомым причинам в telebot'е нет атрибута message_handler
Ответы (2 шт):
Автор решения: nomnoms12
→ Ссылка
- Удалите модуль
telebot:pip uninstall telebot - Установите
pytelegrambotapi:pip install -U pytelegrambotapi
Автор решения: Radzhab
→ Ссылка
1) pip uninstall telebot
2) pip install pytelegrambotapi
Вот рабочий код
import config
import telebot
import requests
from bs4 import BeautifulSoup as BS
bot = telebot.TeleBot(config.token)
@bot.message_handler(commands=["start"])
def cmd_start(message):
bot.send_message(message.chat.id, 'Текст')
if __name__ == '__main__':
bot.polling(none_stop=True)
