When I run the code below the following error message is displayed: 'TeleBot' object has no attribute 'message_handler'.
import telebot
from telebot import types
keyboard1 = telebot.types.ReplyKeyboardMarkup()
keyboard1.row('Ok', 'Bye')
bot = telebot.TeleBot('API')
@bot.message_handler(commands=['start'])
def start_message(message):
bot.send_message(message.chat.id, 'Hi what do you want /start', reply_markup=keyboard1)
@bot.message_handler(content_types=['text'])
def send_text(message):
if message.text.lower() =='Hello':
bot.send_message(message.chat.id, message.text.upper() )
elif message.text.lower() =='Bye':
bot.send_message(message.chat.id,'see you soom' )
elif message.text.lower() == 'I love you':
bot.send_sticker(message.chat.id, 'API')
@bot.message_handler(content_types=['sticker'])
def sticker_id(message):
print(message)
bot.polling(none_stop=True)
So what is wrong? I have installed pip and others. I wrote it on python IDLE. I wanted to make a telegram bot which gives stickers.
Try this code:
pip3 uninstall telebot
pip3 uninstall PyTelegramBotAPI
pip3 install pyTelegramBotAPI
pip3 install --upgrade pyTelegramBotAPI
I did
pip3 uninstall telebot
Then
pip3 uninstall PyTelegramBotAPI
And then
pip3 install PyTelegramBotAPI==2.2.3
And it works now!
PyTelegramBotAPI 3.0 have lot of changes and 3.0 API docs are not there yet. WIP. Use 2.2.3 older version instead and make sure you don't have any other bot api like telebot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With