feat: support Bot API 10.0#905
Conversation
| getFile(signal?: AbortSignal) { | ||
| const m = orThrow(this.msg, "getFile"); | ||
| const file = m.photo !== undefined | ||
| const file = m.photo !== undefined // handles both photos and live photos |
There was a problem hiding this comment.
TODO: To check file ids of LivePhotos
Idea: Should the video file represent the return value of live photo get file, or the static photos that are bundled together with the live photo?
LivePhoto.file_id: Identifier for the video file which can be used to download or reuse the file
There was a problem hiding this comment.
LivePhoto update
{
"update_id": 908295617,
"message": {
"message_id": 43,
"from": {
"id": 41284431,
"is_bot": false,
"first_name": "KnightNiwrem",
"username": "Knightniwrem",
"language_code": "en"
},
"chat": {
"id": -1003070712535,
"title": "Experiment forum",
"is_forum": true,
"type": "supergroup"
},
"date": 1778906082,
"live_photo": {
"photo": [
{
"file_id": "AgACAgUAAyEFAAS3B1rXAAMragfz4i5sDzmG878xthwwTUADm14AAn8Paxs2I0BUos5igkyexrsBAAMCAANzAAM7BA",
"file_unique_id": "AQADfw9rGzYjQFR4",
"file_size": 1189,
"width": 51,
"height": 90
},
{
"file_id": "AgACAgUAAyEFAAS3B1rXAAMragfz4i5sDzmG878xthwwTUADm14AAn8Paxs2I0BUos5igkyexrsBAAMCAANtAAM7BA",
"file_unique_id": "AQADfw9rGzYjQFRy",
"file_size": 16867,
"width": 180,
"height": 320
},
{
"file_id": "AgACAgUAAyEFAAS3B1rXAAMragfz4i5sDzmG878xthwwTUADm14AAn8Paxs2I0BUos5igkyexrsBAAMCAAN4AAM7BA",
"file_unique_id": "AQADfw9rGzYjQFR9",
"file_size": 70979,
"width": 450,
"height": 800
},
{
"file_id": "AgACAgUAAyEFAAS3B1rXAAMragfz4i5sDzmG878xthwwTUADm14AAn8Paxs2I0BUos5igkyexrsBAAMCAAN5AAM7BA",
"file_unique_id": "AQADfw9rGzYjQFR-",
"file_size": 147477,
"width": 720,
"height": 1280
},
{
"file_id": "AgACAgUAAyEFAAS3B1rXAAMragfz4i5sDzmG878xthwwTUADm14AAn8Paxs2I0BUos5igkyexrsBAAMCAAN3AAM7BA",
"file_unique_id": "AQADfw9rGzYjQFR8",
"file_size": 433857,
"width": 1441,
"height": 2560
}
],
"duration": 4,
"width": 718,
"height": 1280,
"mime_type": "video/mp4",
"file_id": "GgACAgUAAyEFAAS3B1rXAAMragfz4oMAAVl8Ks-Ez7tEuniI831DAAKMIwACNiNAVNH64jHkDmUdOwQ",
"file_unique_id": "AgADjCMAAjYjQFQ",
"file_size": 518452
},
"photo": [
{
"file_id": "AgACAgUAAyEFAAS3B1rXAAMragfz4i5sDzmG878xthwwTUADm14AAn8Paxs2I0BUos5igkyexrsBAAMCAANzAAM7BA",
"file_unique_id": "AQADfw9rGzYjQFR4",
"file_size": 1189,
"width": 51,
"height": 90
},
{
"file_id": "AgACAgUAAyEFAAS3B1rXAAMragfz4i5sDzmG878xthwwTUADm14AAn8Paxs2I0BUos5igkyexrsBAAMCAANtAAM7BA",
"file_unique_id": "AQADfw9rGzYjQFRy",
"file_size": 16867,
"width": 180,
"height": 320
},
{
"file_id": "AgACAgUAAyEFAAS3B1rXAAMragfz4i5sDzmG878xthwwTUADm14AAn8Paxs2I0BUos5igkyexrsBAAMCAAN4AAM7BA",
"file_unique_id": "AQADfw9rGzYjQFR9",
"file_size": 70979,
"width": 450,
"height": 800
},
{
"file_id": "AgACAgUAAyEFAAS3B1rXAAMragfz4i5sDzmG878xthwwTUADm14AAn8Paxs2I0BUos5igkyexrsBAAMCAAN5AAM7BA",
"file_unique_id": "AQADfw9rGzYjQFR-",
"file_size": 147477,
"width": 720,
"height": 1280
},
{
"file_id": "AgACAgUAAyEFAAS3B1rXAAMragfz4i5sDzmG878xthwwTUADm14AAn8Paxs2I0BUos5igkyexrsBAAMCAAN3AAM7BA",
"file_unique_id": "AQADfw9rGzYjQFR8",
"file_size": 433857,
"width": 1441,
"height": 2560
}
]
}
}
There was a problem hiding this comment.
Performed file.download() on both live_photo.file_id and photo[last].file_id. Verified that they mean different things: the former is a .mp4 representing the live photo, and the latter is a .jpg representing the static photo.
There was a problem hiding this comment.
Idea: Should the video file represent the return value of live photo get file, or the static photos that are bundled together with the live photo?
I went back and forth on this a few times. I now believe that if you want to process a live photo further in other systems, then it's helpful to actually download the photo. The photo is the relevant part, and the animation is a nice addition. Other systems with dedicated live photo support need to perform two unrelated downloads anyway, so they can use the generic ctx.getFile() for the photo and a specific ctx.api.getFile(ctx.msg.live_photo.file_id) for the live photo.
https://core.telegram.org/bots/api#may-8-2026
Closes #904.