Search code examples
pythonnameerror

Nameerror telebot is not define


I' trying to make a bot telegram, but it throws Nameerror, exception on line bot = telebot.TeleBot("754102396:AAEpwiIrfb57pZ-8EKsHj30C1LQoWCIpqbI") it says telebot is not define

I tried uninstalling telebot and PyTelegramBotAPI then installing PyTelegramBotAPI==2.2.3 via pip, but only get worse. So I undo the changes.

Here is the code, I hope you can help me:

from telebot import TeleBot


bot = telebot.TeleBot("754102396:AAEpwiIrfb57pZ-8EKsHj30C1LQoWCIpqbI")

@bot.message_handler(commands = ["help", "start"])
def enviar_mensaje(message):
    bot.reply_to(message, "Hola, soy un bot")

@bot.message_handler(func=lambda message: True)
def message(message):
    bot.reply_to(message, message.text)

bot.polling()

Solution

  • Change this line to,

    bot = telebot.TeleBot("754102396:AAEpwiIrfb57pZ-8EKsHj30C1LQoWCIpqbI")
    

    to

    bot = TeleBot("754102396:AAEpwiIrfb57pZ-8EKsHj30C1LQoWCIpqbI")