Skip to content

feat: support Bot API 10.3 - #295

Merged
negasus merged 2 commits into
go-telegram:mainfrom
ingvarch:feature/bot-api-10.3
Aug 26, 2026
Merged

negasus merged 2 commits into
go-telegram:mainfrom
ingvarch:feature/bot-api-10.3

Conversation

@ingvarch

Copy link
Copy Markdown
Contributor

Adds full Bot API 10.3 support (August 24, 2026), following the existing RichBlock / RichText tagged-union (marshalVariant) and rawRequest patterns.

Rich Messages

  • New RichMessageButton and the RichTextButton variant of the RichText union (type: "button").
  • New block types in the RichBlock and InputRichBlock unions:
    RichBlockButtons / InputRichBlockButtons,
    RichBlockExpandableBlockQuotation / InputRichBlockExpandableBlockQuotation,
    RichBlockDocument / InputRichBlockDocument, with the matching
    RichBlockType* constants.
  • is_compact on RichBlockTable and InputRichBlockTable.
  • tg://document?id= links documented for InputRichMessageMedia.

Ephemeral Messages

  • New models.EphemeralMessageParameters (receiver_user_id, callback_query_id, replace_callback_query_message).
  • The 13 send methods (sendMessage, sendAnimation, sendAudio, sendDocument, sendLivePhoto, sendPhoto, sendSticker, sendVideo, sendVideoNote, sendVoice, sendContact, sendLocation, sendVenue) now take ephemeral_message_parameters instead of receiver_user_id + callback_query_id; the same parameter is added to sendRichMessage.
  • rich_message on editEphemeralMessageText (text is now optional, as it is required only when rich_message is not given).
  • show_caption_above_media on editEphemeralMessageCaption.
  • Upload of new files in editEphemeralMessageMedia: the existing InputMedia form handling already attaches attach:// files; covered by a test that asserts the multipart file part.
  • can_send_welcome_messages on ChatAdministratorRights, ChatMemberAdministrator and promoteChatMember.

Reply markup

  • New DisabledButton with the disabled field on InlineKeyboardButton.
  • force_reply on InlineKeyboardMarkup and ReplyKeyboardMarkup.

General

  • can_stop and keep_on_stop on sendMessageDraft and sendRichMessageDraft.
  • New MessageGenerationStopped with the stopped_message_generation field on Update and the AllowedUpdateStoppedMessageGeneration constant.
  • New CommunityChatJoined with community_chat_joined on Message.
  • text, entities and is_private on UniqueGiftInfo.
  • README and CHANGELOG bumped to 10.3 (v1.24.0).

Breaking change

ReceiverUserID and CallbackQueryID are removed from the send method params (SendMessageParams, SendPhotoParams, ...). Bot API 10.3 replaced them with EphemeralMessageParameters:

// before
b.SendMessage(ctx, &bot.SendMessageParams{ChatID: id, Text: "hi", ReceiverUserID: uid, CallbackQueryID: cq})

// after
b.SendMessage(ctx, &bot.SendMessageParams{
      ChatID: id,
      Text:   "hi",
      EphemeralMessageParameters: &models.EphemeralMessageParameters{ReceiverUserID: uid, CallbackQueryID: cq},
})

AnswerCallbackQueryParams.CallbackQueryID is unchanged.

@ingvarch

Copy link
Copy Markdown
Contributor Author

@negasus Pls review 🙏

@codecov-commenter

codecov-commenter commented Aug 24, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.35%. Comparing base (d7672bb) to head (8c6bcec).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #295      +/-   ##
==========================================
+ Coverage   43.80%   48.35%   +4.54%     
==========================================
  Files          34       34              
  Lines        2785     2827      +42     
==========================================
+ Hits         1220     1367     +147     
+ Misses       1506     1400     -106     
- Partials       59       60       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@negasus negasus left a comment

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.

Excellent work. I went through this against the official 10.3 documentation rather than just the changelog — pulled the API page and diffed the field tables of every new type against what you wrote — and it holds up completely.

What I verified:

  • All 22 changelog items are implemented, nothing missing and nothing invented.
  • Field tables match the docs exactly for RichMessageButton (all 11 fields), RichTextButton, RichBlockButtons / InputRichBlockButtons including align, RichBlockDocument (Document) and InputRichBlockDocument (InputMediaDocument, caption ignored), RichBlockExpandableBlockQuotation, DisabledButton, EphemeralMessageParameters, MessageGenerationStopped, CommunityChatJoined — names, types, json tags, optionality, and the discriminator values (expandable_blockquote, buttons, document, button).
  • All 14 methods got ephemeral_message_parameters — the 13 send methods plus sendRichMessage, with the old receiver_user_id / callback_query_id removed from exactly those and left in place where the docs still have them (answerCallbackQuery, the editEphemeralMessage* and deleteEphemeralMessage methods). The examples still build.
  • The tagged-union additions follow the existing marshalVariant pattern on both the marshal and unmarshal side, for both RichBlock and InputRichBlock.
  • go build, go test ./..., go vet, gofmt all clean.

One detail worth calling out because it looked like a slip and is not: can_send_welcome_messages without omitempty on ChatAdministratorRights and ChatMemberAdministrator is correct — that field is required in the docs, while the can_manage_tags / can_manage_topics neighbours are Optional. Nice attention to detail. (It did surface some older drift on our side: can_post_stories, can_edit_stories and can_delete_stories are required in the docs but carry omitempty here. Not yours, I will deal with it separately.)

The tests are the right kind, too — asserting actual multipart field values, including the attach:// part in EditEphemeralMessageMedia, rather than just round-tripping structs.

Merging as is. I am going to adjust the CHANGELOG myself in a follow-up commit: the version and its date are mine to pick when I cut the release, and I need to fold in the #297 entry that landed just before this.

Separately, while checking the tg://document?id= item I found that attachments inside rich messages never reach the multipart form at all — buildRequestForm has no case for InputRichMessage, so it falls through to plain JSON encoding and the attach:// file part is silently dropped. That predates this PR (I reproduced it on main, it has been there since 10.1), so it is not a blocker here, but 10.3 makes it more visible. I will open an issue for it.

@negasus
negasus merged commit 571c7a6 into go-telegram:main Aug 26, 2026
1 check passed
@negasus

negasus commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Opened #298 for the rich message attachment gap I mentioned — it turned out to cover more than the document case: everything nested inside InputRichMessage is affected, both the Media array and the media-carrying InputRichBlock* types, across sendRichMessage, sendRichMessageDraft, editMessageText and editEphemeralMessageText. Again, not from your changes — it predates them.

I also adjusted the CHANGELOG after merging, as I said I would: dated v1.24.0 to the release day rather than the API release day, folded in #297, and used the [BREAKING] prefix that earlier entries use. And I fixed the older omitempty drift on can_post_stories / can_edit_stories / can_delete_stories that your PR made me notice. Thanks again for the thorough work.

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.

3 participants