pyfork send_photo trouble [400 FILE_REFERENCE_EXPIRED]

89 views Asked by At

Using pyrogram and trying to send photo from getting telegram story from my channel I have following error:

pyrogram.errors.exceptions.bad_request_400.FileReferenceExpired: Telegram says: [400 FILE_REFERENCE_EXPIRED] - The file id contains an expired file reference, you must obtain a valid one by fetching the message from the origin context (caused by "messages.SendMedia")

I understand that the problem is somewhere in the expired link, but I don’t understand whether I should take the brothers from my history object or somewhere else?

app.start()
story = app.get_stories("me", 1)
if story.photo:
                # send to me story link
                link_story = app.export_story_link("me", 1)
                app.send_message("me", link_story.link)
                 # send to me story photo
                app.send_photo(chat_id="me", photo=story.photo.file_id)
app.stop()
1

There are 1 answers

0
Mukund On

This occurs when you are trying to download a file that is no longer available on the telegram servers.

  • You can download it by re-uploading the content and obtaining the file_id to it