feat: support Bot API 10.3 - #295
Conversation
…s, message generation stop)
|
@negasus Pls review 🙏 |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
negasus
left a comment
There was a problem hiding this comment.
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/InputRichBlockButtonsincludingalign,RichBlockDocument(Document) andInputRichBlockDocument(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 plussendRichMessage, with the oldreceiver_user_id/callback_query_idremoved from exactly those and left in place where the docs still have them (answerCallbackQuery, theeditEphemeralMessage*anddeleteEphemeralMessagemethods). The examples still build. - The tagged-union additions follow the existing
marshalVariantpattern on both the marshal and unmarshal side, for bothRichBlockandInputRichBlock. go build,go test ./...,go vet,gofmtall 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.
|
Opened #298 for the rich message attachment gap I mentioned — it turned out to cover more than the document case: everything nested inside 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 |
Adds full Bot API 10.3 support (August 24, 2026), following the existing RichBlock / RichText tagged-union (
marshalVariant) and rawRequest patterns.Rich Messages
RichMessageButtonand theRichTextButtonvariant of theRichTextunion (type: "button").RichBlockandInputRichBlockunions:RichBlockButtons/InputRichBlockButtons,RichBlockExpandableBlockQuotation/InputRichBlockExpandableBlockQuotation,RichBlockDocument/InputRichBlockDocument, with the matchingRichBlockType*constants.is_compactonRichBlockTableandInputRichBlockTable.tg://document?id=links documented forInputRichMessageMedia.Ephemeral Messages
models.EphemeralMessageParameters(receiver_user_id,callback_query_id,replace_callback_query_message).sendMessage,sendAnimation,sendAudio,sendDocument,sendLivePhoto,sendPhoto,sendSticker,sendVideo,sendVideoNote,sendVoice,sendContact,sendLocation,sendVenue) now takeephemeral_message_parametersinstead ofreceiver_user_id+callback_query_id; the same parameter is added tosendRichMessage.rich_messageoneditEphemeralMessageText(textis now optional, as it is required only whenrich_messageis not given).show_caption_above_mediaoneditEphemeralMessageCaption.editEphemeralMessageMedia: the existingInputMediaform handling already attachesattach://files; covered by a test that asserts the multipart file part.can_send_welcome_messagesonChatAdministratorRights,ChatMemberAdministratorandpromoteChatMember.Reply markup
DisabledButtonwith thedisabledfield onInlineKeyboardButton.force_replyonInlineKeyboardMarkupandReplyKeyboardMarkup.General
can_stopandkeep_on_stoponsendMessageDraftandsendRichMessageDraft.MessageGenerationStoppedwith thestopped_message_generationfield onUpdateand theAllowedUpdateStoppedMessageGenerationconstant.CommunityChatJoinedwithcommunity_chat_joinedonMessage.text,entitiesandis_privateonUniqueGiftInfo.Breaking change
ReceiverUserIDandCallbackQueryIDare removed from the send method params (SendMessageParams,SendPhotoParams, ...). Bot API 10.3 replaced them withEphemeralMessageParameters: