Repository navigation
Implement support for Bot API 10.5 features - #324
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
negasus
left a comment
There was a problem hiding this comment.
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?
- In
models/user.go, please removeomitemptyfrom the required fields of the newBotFullInfotype. According to https://core.telegram.org/bots/api#botfullinfo, onlyusername,active_usernames, andinline_query_placeholderare optional. Decoding works now, but marshaling a valid response drops requiredfalsevalues such ascan_join_groups. A small marshal test checking that a required false is present and an unset optional field is absent would cover this. - 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 ofUser. Please also label the Go API breaks explicitly:GetMenow returns*models.BotFullInfoinstead of*models.User, and both expandable quotation types replaceTextwithBlocks.
go test ./... and go vet ./... passed on aeaba80.
|
Integration update: #323 has landed on |
|
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. |
|
With the new |
Keep the GetMe username cache, cover the moved flags on BotFullInfo, and spell out the API breaks.
negasus
left a comment
There was a problem hiding this comment.
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?
- In inline_keyboard_multiselect, check
update.CallbackQuery.Message.Messageimmediately afterAnswerCallbackQueryand return if it is nil, before changingcurrentOptions. The rest of this handler needs a chat and message ID. - In the singleFlight middleware, use
InlineMessageIDas 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.
negasus
left a comment
There was a problem hiding this comment.
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.
Summary
GetMereturnsBotFullInfo. Fields that Telegram returned only fromgetMemove there, includingactive_usernames,inline_query_placeholder,needs_inline_query_location,has_topic_sidebar,has_main_web_app, andsupports_join_request_queries.Userkeeps the fields sent for ordinary users. Inline queries use the documentedsupports_inline_queriesname.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_modeisdefault,auto, orinline.inline_message_idinstead ofmessagewhen that mode says so.WriteAccessAllowed.Inviteris the bot owner who invited the user into the private chat.blocksinstead oftexton both received and outgoing rich messages. Nested files inside those blocks are uploaded.Tests
go test ./...go vet ./...gofmt