如何从 Telegramm 消息中获取标题(Pyrogram)

How to get caption from Telegramm message(Pyrogram)

我是 Python 的新手。我想用 Pyrogram 解析某些对话框(只包含图片的标题)。但是如果我使用 iter_history() 方法 returns none if message contains pic+text.Like that.

import asyncio
from pyrogram import Client

app = Client("my_acc")
target = "dialog_example"  # "me" refers to your own chat (Saved Messages)

with app:
    for message in app.iter_history(target):
        print(message.text)

None

Process finished with exit code 0

message.text 是消息的正文。如果您想要消息(或文档)的标题,请访问 message.caption.