KurimuzonAkuma / pyrogram

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
https://pyrogram.org
GNU Lesser General Public License v3.0
321 stars 90 forks source link

The file id contains an expired file reference #54

Closed fivepe closed 1 month ago

fivepe commented 5 months ago

Checklist

Description

app.download_media(message, file_name=filename) some time it run 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 "upload.GetFile")

It may be because the download time is too long or there is a flood waiting. Can you automatically re-read the message and try to download?

Steps to reproduce

app.download_media(message, file_name=filename) show The file id contains an expired file reference

Code example

app.download_media(message, file_name=filename)

Logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyrogram/client.py", line 1007, in get_file
    r = await session.invoke(
  File "/usr/local/lib/python3.8/dist-packages/pyrogram/session/session.py", line 399, in invoke
    return await self.send(query, timeout=timeout)
  File "/usr/local/lib/python3.8/dist-packages/pyrogram/session/session.py", line 367, in send
    RPCError.raise_it(result, type(data))
  File "/usr/local/lib/python3.8/dist-packages/pyrogram/errors/rpc_error.py", line 91, in raise_it
    raise getattr(
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 "upload.GetFile")