【问题标题】:Receiving Data about bot user, Profile pic, Profile count接收有关机器人用户、个人资料图片、个人资料计数的数据
【发布时间】:2021-03-31 21:54:51
【问题描述】:

我开始编写一个机器人,它可以为我提供来自电报用户的简单信息,例如用户名、ID 和个人资料照片,以及他们获得了多少个人资料。 根据python-telegram-bot package (telegram.ext) 我写了这段代码,错误是“导致错误“'total_count'”

def start(update, context):
    update.message.reply_text('Hello There!')
    user = update.message.from_user
    print('You talk with user {} and his user ID: {} '.format(user['username'], user['id']))
    userprofilephotos = update.message.from_user
    print('The user total profile {}'.format(userprofilephotos['total_count']))

我导入了这些东西

import logging
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, ConversationHandler

【问题讨论】:

    标签: python telegram telegram-bot python-telegram-bot


    【解决方案1】:

    您忘记调用get_profile_photos 方法(文档here

    userprofilephotos = update.message.from_user.get_profile_photos()
    

    现在应该可以正常工作了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-29
      • 2017-09-30
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-25
      • 2014-09-15
      相关资源
      最近更新 更多