Skip to content

feat: support Bot API 10.1 (Rich Messages)#283

Open
aaliboyev wants to merge 1 commit into
go-telegram:mainfrom
aaliboyev:feat/bot-api-10.1-rich-messages
Open

feat: support Bot API 10.1 (Rich Messages)#283
aaliboyev wants to merge 1 commit into
go-telegram:mainfrom
aaliboyev:feat/bot-api-10.1-rich-messages

Conversation

@aaliboyev

Copy link
Copy Markdown

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.go discriminated-union style for the type unions, and the rawRequest wrapper style for methods).

Methods (methods.go / methods_params.go)

  • sendRichMessage
  • sendRichMessageDraft
  • rich_message parameter added to editMessageText

Types (models/)

  • Send side: InputRichMessage, InputRichMessageContent
  • Receive side: RichMessage (+ rich_message field on Message); the RichBlock union (21 variants, incl. RichBlockThinking); the RichText union; plus RichBlockCaption, RichBlockListItem, RichBlockTableCell

Notes for review

  • RichText is polymorphic — a value is a bare JSON string, an array of RichText, or a tagged object (25 variants, several recursively nesting text). It has a custom codec that dispatches on the first JSON byte; this is the one type that goes beyond the plain reaction.go shape.
  • Value receiver on MarshalJSON for RichText/RichBlock (vs the pointer receiver in reaction.go). This is deliberate: RichText appears as a non-pointer struct field (Text RichText) throughout the variants, and encoding/json silently skips a pointer-receiver MarshalJSON on non-addressable values — so a value receiver is required for correct marshaling of nested rich text. RichBlock uses a value receiver too for consistency.
  • RichBlockThinking is valid only in sendRichMessageDraft per 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, and go test ./... are clean.

README "Supports Bot API version" and CHANGELOG bumped to 10.1.

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.
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.

1 participant