Skip to content

Implement support for Bot API 10.5 features - #324

Merged
negasus merged 4 commits into
go-telegram:mainfrom
Zoomish:main
Nov 26, 2026
Merged

negasus merged 4 commits into
go-telegram:mainfrom
Zoomish:main

Conversation

@Zoomish

@Zoomish Zoomish commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • GetMe returns BotFullInfo. Fields that Telegram returned only from getMe move there, including active_usernames, inline_query_placeholder, needs_inline_query_location, has_topic_sidebar, has_main_web_app, and supports_join_request_queries. User keeps the fields sent for ordinary users. Inline queries use the documented supports_inline_queries name.
  • Add SetMySettings. A nil bool or integer is not sent, False() and a zero feedback denominator are sent, and a pointer to "" clears the inline placeholder. callback_query_mode is default, auto, or inline.
  • Callback queries from the bot's own messages can arrive with inline_message_id instead of message when that mode says so. WriteAccessAllowed.Inviter is the bot owner who invited the user into the private chat.
  • Expandable block quotations use blocks instead of text on both received and outgoing rich messages. Nested files inside those blocks are uploaded.

Tests

  • go test ./...
  • go vet ./...
  • gofmt

…h messages

- Introduced `InputRichBlockExpandableBlockQuotation` to handle expandable block quotations with nested blocks.
- Updated tests to validate the new structure and ensure proper serialization/deserialization.
- Modified `addInputRichBlockAttachments` to process expandable block quotations.
- Enhanced `GetMe` method to return `BotFullInfo` with additional fields.
- Added `SetMySettings` method for managing bot settings, including inline query placeholders and callback query modes.
@codecov-commenter

codecov-commenter commented Nov 22, 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 64.99%. Comparing base (4b50daf) to head (0dee556).
⚠️ Report is 5 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #324      +/-   ##
==========================================
+ Coverage   63.69%   64.99%   +1.29%     
==========================================
  Files          40       41       +1     
  Lines        3449     3568     +119     
==========================================
+ Hits         2197     2319     +122     
+ Misses       1194     1192       -2     
+ Partials       58       57       -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.

Thanks for the 10.5 update. I checked the changes against the official Bot API docs; the new method and field coverage look good. Could you make two small changes before merge?

  1. In models/user.go, please remove omitempty from the required fields of the new BotFullInfo type. According to https://core.telegram.org/bots/api#botfullinfo, only username, active_usernames, and inline_query_placeholder are optional. Decoding works now, but marshaling a valid response drops required false values such as can_join_groups. A small marshal test checking that a required false is present and an unset optional field is absent would cover this.
  2. In CHANGELOG.md, please distinguish the four newly added fields (active_usernames, inline_query_placeholder, needs_inline_query_location, has_topic_sidebar) from the existing getMe-only fields moved out of User. Please also label the Go API breaks explicitly: GetMe now returns *models.BotFullInfo instead of *models.User, and both expandable quotation types replace Text with Blocks.

go test ./... and go vet ./... passed on aeaba80.

@negasus

negasus commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Integration update: #323 has landed on main (c1313b8). Please sync this branch with main while addressing the review. In models/user_test.go, adapt the newly merged flag tests to BotFullInfo: preserve coverage for supports_join_request_queries and supports_inline_queries without adding either field back to the 10.5 User model.

@negasus

negasus commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

One more integration detail for the rebase: #320 is now on main. Please keep the successful GetMe username-cache update when switching its result to BotFullInfo. Passing the returned ID and Username to setUsername would avoid coupling the helper to either model. The addressed-command tests from #320 should still pass after the rebase.

@INKCR0W

INKCR0W commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

With the new CallbackQueryModeInline setting, callbacks from messages sent by the bot can have inline_message_id and no message. The inline keyboard example still dereferences Message.Message unconditionally, so it can panic in that mode. Could we handle the missing message in the example?

Telegram’s callback_query_mode docs

Keep the GetMe username cache, cover the moved flags on BotFullInfo, and spell out the API breaks.
@Zoomish
Zoomish requested a review from negasus November 23, 2026 12:09

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

Thanks for fixing the BotFullInfo JSON tags, documenting the breaking changes, and guarding the inline_keyboard example. Two other examples still assume every callback has an accessible message. With CallbackQueryModeInline, Telegram can send inline_message_id instead, so these examples can panic on a valid update. Could you address both before merge?

  1. In inline_keyboard_multiselect, check update.CallbackQuery.Message.Message immediately after AnswerCallbackQuery and return if it is nil, before changing currentOptions. The rest of this handler needs a chat and message ID.
  2. In the singleFlight middleware, use InlineMessageID as the key for an inline callback and (Chat.ID, Message.ID) for an accessible chat message. Message IDs are scoped to a chat. Please also handle the case where neither key is available without dereferencing a nil message.

go vet ./... and go test -race ./... passed on aa04dce.

Inline callbacks can omit the message. The multiselect example returns before changing state, and singleFlight keys those callbacks by inline_message_id.
@Zoomish
Zoomish requested a review from negasus November 24, 2026 11:35

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

Thanks for updating the callback examples. One routing issue remains in examples/middleware/main.go:33: MatchTypeExact with an empty pattern matches only empty callback data. A button with data: "btn" therefore bypasses singleFlight and reaches the default handler, which dereferences update.Message.Chat.ID and panics because callback updates have no top-level message. Could you switch this registration to bot.MatchTypePrefix with the existing empty pattern so callbacks with nonempty data reach the intended handler?

The other review items look addressed. go test -race ./... and go vet ./... passed on a local merge of 4930d09 with main (9e546ff).

An empty exact pattern only matches empty callback data, so other callbacks reached the default handler.
@negasus
negasus merged commit 284495d into go-telegram:main Nov 26, 2026
3 checks passed
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.

4 participants