@@ -102,18 +102,16 @@ errors such as ``[400 MEDIA_EMPTY]``.
102102The only exception are stickers' file ids; you can use them across different accounts without any problem, like this
103103one: ``CAADBAADyg4AAvLQYAEYD4F7vcZ43AI ``.
104104
105- Can I use Bot API's file_ids in Pyrogram?
106- -----------------------------------------
105+ Can I use Bot API's file_id values in Pyrogram?
106+ -----------------------------------------------
107107
108- :strike: ` Definitely! All file ids you might have taken from the Bot API are 100% compatible and re-usable in Pyrogram. `
108+ Definitely! All file ids you might have taken from the Bot API are 100% compatible and re-usable in Pyrogram.
109109
110- Starting from :doc: `Pyrogram v0.14.1 (Layer 100) <releases/v0.14.1 >`, the file_id format of all photo-like objects has
111- changed. Types affected are: :obj: `~pyrogram.Thumbnail `, :obj: `~pyrogram.ChatPhoto ` and :obj: `~pyrogram.Photo `. Any
112- other file id remains compatible with the Bot API.
110+ **However... **
113111
114112Telegram is slowly changing some server's internals and it's doing it in such a way that file ids are going to break
115113inevitably. Not only this, but it seems that the new, hypothetical, file ids could also possibly expire at anytime, thus
116- losing the *persistence * feature.
114+ losing the *persistence * feature (see ` What is a file_ref and why do I need it? `_) .
117115
118116This change will most likely affect the official :doc: `Bot API <topics/mtproto-vs-botapi >` too (unless Telegram
119117implements some workarounds server-side to keep backwards compatibility, which Pyrogram could in turn make use of) and
@@ -253,6 +251,31 @@ contact people using official apps. The answer is the same for Pyrogram too and
253251for usernames, meeting them in a common group, have their phone contacts saved or getting a message mentioning them,
254252either a forward or a mention in the message text.
255253
254+ What is a file_ref and why do I need it?
255+ ----------------------------------------
256+
257+ .. note ::
258+
259+ This FAQ is currently applicable to user accounts only. Bot accounts are still doing fine without a file_ref
260+ (even though this can change anytime since it's a Telegram's internal server behaviour).
261+
262+ Similarly to what happens with users and chats which need to first be encountered in order to interact with them, media
263+ messages also need to be "seen" recently before downloading or re-sending without uploading as new file.
264+
265+ **What is it meant by "they need to be seen recently"? **
266+
267+ That means you have to fetch the original media messages prior any action in order to get a valid and up to date value
268+ called file reference (file_ref) which, in pair with a file_id, enables you to interact with the media. This file_ref
269+ value won't last forever (usually 24h, but could expire anytime) and in case of errors you have to get a refreshed
270+ file_ref by re-fetching the original message (fetching forwarded media messages does also work).
271+
272+ **Ok, but what is a file_ref actually needed for? **
273+
274+ Nobody knows for sure, but is likely because that's the correct approach for handling tons of files uploaded by users in
275+ Telegram's cloud. Which means, as soon as the media message still exists, a valid file_ref can be obtained, otherwise,
276+ in case there's no more messages referencing a specific media, Telegram is able to free disk space by deleting old
277+ files.
278+
256279Code hangs when I stop, restart, add/remove_handler
257280---------------------------------------------------
258281
0 commit comments