首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AttributeError:对象'TeleBot‘没有属性'message_handler’

AttributeError:对象'TeleBot‘没有属性'message_handler’
EN

Stack Overflow用户
提问于 2021-09-19 12:16:35
回答 1查看 397关注 0票数 0

当我运行代码时,我会得到以下响应:

AttributeError:对象'TeleBot‘没有属性'message_handler’。

代码:

代码语言:javascript
复制
#!/usr/bin/python

# This is a simple echo bot using the decorator mechanism.
# It echoes any incoming text messages.

import telebot

API_TOKEN = 'my Private code'
bot = telebot.TeleBot(API_TOKEN)

# Handle '/start' and '/help'
@bot.message_handler(commands=['help', 'start'])
def send_welcome(message):
    bot.reply_to(message, """\
Hi there, I am EchoBot.
I am here to echo your kind words back to you. Just say anything nice and I'll say the exact same thing to you!\
""")

# Handle all other messages with content_type 'text' (content_types defaults to ['text'])
@bot.message_handler(func=lambda message: True)
def echo_message(message):
    bot.reply_to(message, message.text)

bot.polling()
EN

回答 1

Stack Overflow用户

发布于 2021-09-19 13:11:58

我相信telebot库使用的是MessageHandler,而不是message_handler。这是文档

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69243182

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档