Skip to content

feat: support Bot API 10.0#905

Merged
KnorpelSenf merged 6 commits into
mainfrom
api-10
May 16, 2026
Merged

feat: support Bot API 10.0#905
KnorpelSenf merged 6 commits into
mainfrom
api-10

Conversation

@KnorpelSenf
Copy link
Copy Markdown
Member

@KnorpelSenf KnorpelSenf commented May 14, 2026

Comment thread src/context.ts
Comment thread src/context.ts Outdated
Comment thread src/context.ts
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
      }
    ]
  }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/context.ts
Comment thread src/context.ts
@KnorpelSenf KnorpelSenf merged commit 88912c7 into main May 16, 2026
6 checks passed
@KnorpelSenf KnorpelSenf deleted the api-10 branch May 16, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update grammY to support Telegram Bot API 10.0

2 participants