如何从 "update" 值中获取发件人信息

How can I fetch sender info from "update" value

我正在尝试从 'update' 参数中获取发件人信息,它返回了什么?我正在使用 'python-telegram-bot' 包

def startBot(update, context):
    update.message.reply_text('HI I am ww helper')

def main():
    updater = Updater(TOKEN, use_context=True)
    dp = updater.dispatcher
    dp.add_handler(CommandHandler("start", startBot))

您可以获得对发件人的参考 update.message.from_user

def startBot(update, context):
    print("USER:", update.message.from_user.first_name)
    update.message.reply_text('HI I am ww helper')

您可以在 official API as well as in the library 中找到 Update 对象的文档以供将来参考。