【问题标题】:(python-telegram-bot) AttributeError: 'Update' object has no attribute 'bot"(python-telegram-bot)AttributeError:“更新”对象没有属性“机器人”
【发布时间】: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


    【解决方案1】:

    解决了,我尝试的是 12 版的教程而不是 11 版的...

    【讨论】:

      猜你喜欢
      • 2023-01-18
      • 1970-01-01
      • 1970-01-01
      • 2020-03-21
      • 2021-09-26
      • 1970-01-01
      • 2021-07-10
      • 2020-07-03
      • 2018-05-12
      相关资源
      最近更新 更多