未定义Nameerror Telebot

时间:2019-05-25 15:55:44

标签: python nameerror

我正在尝试发出机器人电报,但它引发Nameerror,在线异常 bot = telebot.TeleBot("754102396:AAEpwiIrfb57pZ-8EKsHj30C1LQoWCIpqbI")telebot is not define

我尝试卸载telebotPyTelegramBotAPI,然后通过PyTelegramBotAPI==2.2.3安装pip,但情况变得更糟。所以我撤消了更改。

这是代码,希望您能为我提供帮助:

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()

1 个答案:

答案 0 :(得分:1)

将此行更改为

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

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