【发布时间】:2019-11-27 05:06:00
【问题描述】:
第 10 行,开始 context.bot.send_message(chat_id=update.message.chat_id, text="我是机器人,请跟我说话!") AttributeError:“更新”对象没有属性“机器人”
我尝试在 python-telegram-bot github 页面上运行入门机器人时收到此错误
from telegram.ext import Updater
updater = Updater(token='xxx')
dispatcher = updater.dispatcher
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
def start(update, context):
context.bot.send_message(chat_id=update.message.chat_id, text="I'm a bot, please talk to me!")
from telegram.ext import CommandHandler
start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)
updater.start_polling()
请帮忙
【问题讨论】:
标签: python bots telegram python-telegram-bot