Skip to content

fix(markup): adapt button helpers to layer 229 button types - #1855

Closed
OCharnyshevich wants to merge 1 commit into
gotd:feat/update-schemafrom
OCharnyshevich:fix/layer-229-markup
Closed

OCharnyshevich wants to merge 1 commit into
gotd:feat/update-schemafrom
OCharnyshevich:fix/layer-229-markup

Conversation

@OCharnyshevich

Copy link
Copy Markdown

Fixes the build of #1850 (layer 229). CI there fails because telegram/message/markup still uses the keyboardButton* constructors that layer 229 removed.

Layer 229 splits buttons into two concrete types: keyboardButton with a ButtonType for reply keyboards, and keyboardInlineButton with an InlineButtonType for inline keyboards. This PR ports the helpers to that model.

API changes

  • Helper names are unchanged. Return types follow the new model:
    • tg.KeyboardButton: Button, RequestPhone, RequestGeoLocation, RequestPoll, RequestPeer, SimpleWebView
    • tg.KeyboardInlineButton: URL, Callback, SwitchInline, Game, Buy, URLAuth, InputURLAuth, UserProfile, InputUserProfile, WebView
  • New generic helpers KeyboardButton(text, tg.ButtonTypeClass, style...) and InlineButton(text, tg.InlineButtonTypeClass, style...) cover any button type, including ones added later. The named helpers are built on them.
  • New helpers for the new inline types: Copy, Disabled.
  • New InlineButtonRow. Row/SingleRow take reply buttons; InlineRow, InlineKeyboard and the Row methods in message and message/inline take inline buttons.
  • URLAuth and UserProfile were reply-keyboard buttons. Layer 229 only has inline forms, so they are inline now.
  • Style options are unchanged.

Code that mixed reply and inline buttons in one row no longer compiles. The protocol no longer allows that either.

Tests

  • Split the row tests into inline and reply keyboards.
  • Added encode/decode round-trip tests for both keyboard kinds.
  • Extended the style tests to Copy and Disabled.

go build ./..., go vet ./telegram/... and go test ./... pass locally on top of #1850.

telegram/message/audio.go is not gofmt-clean on the #1850 branch. I left it out because it's unrelated.

Motivation

We need layer 229 for ephemeral bot messages. On layer 228 the server sends updateEphemeralBotCallbackQuery#9b380762, which is only in _schema/tdlib.tl. gotd can't decode it and drops the whole updates container, so callback buttons on ephemeral messages can't be handled.

@ernado
ernado deleted the branch gotd:feat/update-schema September 18, 2026 10:15
@ernado ernado closed this Sep 18, 2026
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.

2 participants