Search code examples
pythonparsingtelegrampyrogram

How to get caption from Telegramm message(Pyrogram)


I'm newbie at Python. I want to parse certain dialog(contains only captions to pics) with Pyrogram. But if i use iter_history() methog it 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


Solution

  • message.text is a message's text. If you want the caption of a message (or document rather), access message.caption.