feat: support Bot API 10.1 (Rich Messages)#283
Open
aaliboyev wants to merge 1 commit into
Open
Conversation
Add the Rich Messages framework from Bot API 10.1 (June 11, 2026). Methods: - sendRichMessage, sendRichMessageDraft - rich_message parameter on editMessageText Types: - InputRichMessage, InputRichMessageContent (send side) - RichMessage (+ Message.rich_message), the RichBlock union (21 variants including RichBlockThinking) and the polymorphic RichText union (string | array | 25 tagged variants), plus RichBlockCaption, RichBlockListItem, RichBlockTableCell Round-trip tests for both unions and the new methods; README + CHANGELOG bumped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bot API 10.1 — Rich Messages
Adds the Rich Messages framework introduced in Bot API 10.1 (June 11, 2026). Follows the existing patterns in the library (the
reaction.godiscriminated-union style for the type unions, and therawRequestwrapper style for methods).Methods (
methods.go/methods_params.go)sendRichMessagesendRichMessageDraftrich_messageparameter added toeditMessageTextTypes (
models/)InputRichMessage,InputRichMessageContentRichMessage(+rich_messagefield onMessage); theRichBlockunion (21 variants, incl.RichBlockThinking); theRichTextunion; plusRichBlockCaption,RichBlockListItem,RichBlockTableCellNotes for review
RichTextis polymorphic — a value is a bare JSON string, an array ofRichText, or a tagged object (25 variants, several recursively nestingtext). It has a custom codec that dispatches on the first JSON byte; this is the one type that goes beyond the plainreaction.goshape.MarshalJSONforRichText/RichBlock(vs the pointer receiver inreaction.go). This is deliberate:RichTextappears as a non-pointer struct field (Text RichText) throughout the variants, andencoding/jsonsilently skips a pointer-receiverMarshalJSONon non-addressable values — so a value receiver is required for correct marshaling of nested rich text.RichBlockuses a value receiver too for consistency.RichBlockThinkingis valid only insendRichMessageDraftper the spec (ephemeral), and the field type is modeled accordingly.Tests
Round-trip (unmarshal → marshal → assert) coverage for both unions — including the polymorphic string/array/object forms and recursive nesting — and request-shape tests for the two new methods.
gofmt,go vet, andgo test ./...are clean.README "Supports Bot API version" and CHANGELOG bumped to 10.1.