Repository navigation
Telegram Bot API 10.5 support: bot settings from code (setMySettings), getMe returning the new BotFullInfo, callback queries addressed by inline_message_id, owner invite links and expandable quotations made of blocks — plus default request timeouts, UTF-16-safe entity parsing, a sub-router middleware fix, a generator rule that lets optional fields send false, "" and 0, and two new Claude Code skills (rich messages, Mini App authentication). lumex now requires Go 1.27. Module path: github.com/kbgod/lumex/v2.
The version is a proposal (
v2.5.0). Unlike 10.4, this release has breaking changes: 10.5 moved the bot's own fields out ofUserand changed expandable quotations upstream, fourteen fields became pointers so that their zero value can be sent at all, and the minimum Go version is now 1.27. Each one has a migration below. Verified againstv2.4.0: 193 → 194 methods with one signature changed (GetMe); one generated constructor changed (NewInputRichBlockExpandableBlockQuotation);Bot.Userremoved; ten fields removed fromUser,Textreplaced byBlocksin the two expandable-quotation types, and fourteen fields retyped to pointers. Nothing else was removed or retyped.
⚠️ Breaking changes
1. getMe returns BotFullInfo, and Bot embeds it instead of User. 10.5 split the bot's own account out of User into a new BotFullInfo class and made getMe return it. lumex.Bot follows. Promoted fields are unaffected — bot.ID, bot.Username, bot.CanJoinGroups, … worked through the embedded User and keep working through BotFullInfo, joined by the new bot.ActiveUsernames, bot.HasTopicSidebar, …. What breaks is code that names the embedded field itself, plus what GetMe returns:
// v2.4.0
log.Println(bot.User.Username) // the README and examples wrote this
me, err := bot.GetMe(ctx) // *lumex.User
r := router.New(&lumex.Bot{User: lumex.User{Username: "my_bot"}}) // in tests
// v2.5.0
log.Println(bot.Username) // also fine in v2.4.0
me, err := bot.GetMe(ctx) // *lumex.BotFullInfo
r := router.New(&lumex.Bot{Username: "my_bot"}) // Go 1.27: a promoted field set directly2. User lost the fields only getMe ever filled in: CanJoinGroups, CanReadAllGroupMessages, SupportsGuestQueries, SupportsInlineQueries, CanConnectToBusiness, HasMainWebApp, HasTopicsEnabled, AllowsUsersToCreateTopics, CanManageBots and SupportsJoinRequestQueries. They are on BotFullInfo — and therefore on bot — and were always false for any other user.
3. Expandable quotations hold blocks. RichBlockExpandableBlockQuotation.Text and InputRichBlockExpandableBlockQuotation.Text were replaced by Blocks, so a quotation can contain lists, tables or nested quotes. The constructor follows:
// v2.4.0
lumex.NewInputRichBlockExpandableBlockQuotation(lumex.PlainText("Long text…"))
// v2.5.0
lumex.NewInputRichBlockExpandableBlockQuotation([]lumex.InputRichBlock{
lumex.NewInputRichBlockParagraph(lumex.PlainText("Long text…")),
})4. Fields whose zero value means something are pointers. An optional field is tagged omitempty, which silently drops false and "". For most fields that is right, but for these the docs give the zero value its own meaning — so until now lumex could not, for example, send a non-anonymous poll (Telegram's default is anonymous), clear a widget's data, remove a forum topic's icon, or ask a request-users button for regular users only. They are now pointers: nil leaves the field out, new(value) (Go 1.26+) sends it, zero included.
| Type | Fields |
|---|---|
SendPollOpts |
IsAnonymous, AllowsRevoting |
PromoteChatMemberOpts |
CanRestrictMembers |
EditMessageWidgetDataOpts |
PublicData, ChatData |
EditForumTopicOpts |
IconCustomEmojiID |
ChatPermissions |
CanReactToMessages, CanEditTag, CanManageTopics |
KeyboardButtonRequestUsers |
UserIsBot, UserIsPremium |
KeyboardButtonRequestChat |
ChatIsForum, ChatHasUsername |
ForumTopicEdited (received) |
IconCustomEmojiID — "" means the icon was removed, nil that it wasn't edited |
// v2.4.0 — false was dropped, so the poll came out anonymous
bot.SendPoll(ctx, chatID, "Lunch?", options, lumex.SendPollOpts{IsAnonymous: false})
// v2.5.0
bot.SendPoll(ctx, chatID, "Lunch?", options, lumex.SendPollOpts{IsAnonymous: new(false)})
ctx.EditWidgetData(lumex.EditMessageWidgetDataOpts{ChatData: new(state)}) // new("") clears it5. Go 1.27 is required. go.mod now says go 1.27. go get raises your module's go line to match; with the default GOTOOLCHAIN=auto the go command fetches a 1.27 toolchain by itself, otherwise install Go 1.27.
🐹 Go 1.27
Besides the requirement, 1.27 lets a composite literal set promoted fields directly, which suits lumex's embedding-heavy types:
// A field of the embedded BotFullInfo — handy in tests:
r := router.New(&lumex.Bot{Username: "my_bot", ID: 42})
// A request with its embedded XxxOpts in one literal (e.g. for lumex.Call):
req := lumex.SendPhotoRequest{ChatID: chatID, Photo: photo, Caption: "hi", MessageThreadID: 5}Before 1.27 these needed the nested form (lumex.Bot{BotFullInfo: lumex.BotFullInfo{…}}, SendPhotoRequest{…, SendPhotoOpts: lumex.SendPhotoOpts{…}}) or assignments after the literal. The code base itself was brought up to date with go fix (promoted-field literals in menu.go / richmessage.go, atomic.Int32 in tests).
✨ Added
🤖 Bot API 10.5 surface (generated)
Bot settings
- New method
setMySettings—bot.SetMySettings(ctx, lumex.SetMySettingsOpts{…})with all fifteen parameters: inline mode (SupportsInlineQueries,InlineQueryPlaceholder,NeedsInlineQueryLocation,InlineFeedbackShareDenominator), privacy mode (CanReadAllGroupMessages), joining groups (CanJoinGroups), guest and join request queries, business accounts, managing and talking to other bots, forum topic mode in private chats (HasTopicsEnabled,AllowsUsersToCreateTopics,HasTopicSidebar) andCallbackQueryMode. Settings left out stay unchanged, which is why every field is a pointer:new(false)switches a setting off,new("")restores the default placeholder,new(int64(0))stops chosen inline results. - New enum
SetMySettingsCallbackQueryMode(…Default,…Auto,…Inline). - New
BotFullInfotype, returned bygetMe, with the newActiveUsernames,InlineQueryPlaceholder,NeedsInlineQueryLocationandHasTopicSidebar. CallbackQuery.InlineMessageIDcan now arrive for a message the bot sent itself, instead ofCallbackQuery.Message, depending oncallback_query_mode.
Bot invites
WriteAccessAllowed.Inviter— the owner who invited the user to a private chat with the bot throughhttps://t.me/botinvite/<bot_username>(up to 10 users at once). The bot may message invited users.
Rich messages
BlocksonRichBlockExpandableBlockQuotationandInputRichBlockExpandableBlockQuotation(see Breaking changes).
🧰 Framework helpers (hand-written)
- Router
Context.InlineMessageID()— the inline message a callback query, chosen inline result or widget query refers to.BotInvite()/OnBotInvite— a user the owner invited with the botinvite link.CallbackQuerySuffix(s)/OnCallbackQuerySuffixandCallbackQueryEquals(s)/OnCallbackQueryEquals, next toCallbackPrefix/OnCallbackPrefix.
- Entity parsing — Telegram's entity offsets are UTF-16 units, so slicing
msg.Textwith them breaks on emoji and most non-Latin text.ParsedMessageEntitycarries the entity'sTextand UTF-8Offset/Length(andURLfor aurlentity):msg.ParseEntities(),ParseCaptionEntities(),ParseAnyEntities()(caption, checklist, game, gift, poll texts too),ParseEntity(e),ParseCaptionEntity(e)and the…Types(map[lumex.MessageEntityType]struct{}{…})filters — all nil-safe;lumex.ParseEntities(text, entities),ParseEntity,ParseEntityTypesfor any other text. A malformed entity never panics: its range is clamped.
- Client timeouts —
DefaultRequestTimeout(30 s),DefaultUploadTimeout(5 min), and theWithRequestTimeout/WithUploadTimeoutclient options (see Changed). - New example
examples/tour-10.5— a menu-driven tour of the release in one message with ⬅️ Back on every submenu: whatgetMereports asBotFullInfo; a settings panel covering everysetMySettingsparameter (the placeholder is free text sent as a reply); the three callback modes with a button that shows whether a tap came withmessageorinline_message_id; an expandable quotation made of blocks; and the invite link, with a greeting for each invited user. It passes itsallowed_updates, so it works on a bot whose token remembers an older list. ItsRELEASE_NOTES.mdis this file.
🔄 Changed
- Every Bot API request is bounded by default: 30 s, or 5 min when it uploads files. A deadline already on the call's
ctxreplaces that limit, longer or shorter;<= 0disables it.GetUpdatesChangives each long poll its own deadline just beyond the poll timeout. Context.EditMessageTextedits byinline_message_idwhen the update carries no message — a callback from an inline message, or from the bot's own message undercallback_query_mode"inline"/"auto". It then returns(nil, true, nil); before, it failed withErrContextMessageIsNil.- The examples read
bot.Usernameinstead ofbot.User.Username;tour-10.3builds its expandable quotation from blocks andtour-10.4edits widget data withnew(…).
🐛 Fixed
- Sub-routers inherit their group's middlewares consistently.
UseStatecalled on aGroupdropped the group's middlewares:r.Group(requireAdmin).UseState("editing").OnMessage(h)ranhwithoutrequireAdmin. It now runs the global middlewares, thenrequireAdmin, then the state's, thenh.- Groups nested three or more levels deep ran their outer middlewares more than once.
- Routes registered on one group could share a handler slice, so registering a second route could replace the first route's handler.
- A
UseStatesub-router no longer keeps a stale copy of its parent's routes. - A sub-router fixes its middleware chain when it is created and when each route is registered:
sub.Use(mw)reaches only routes registered onsubafterwards.
- Zero values that could not be sent before can be now (Breaking change 4): non-anonymous polls, regular polls without revoting, channel admins promoted without the right to restrict members, cleared widget data, removed topic icons,
ChatPermissionsthat differ from their defaults, request-users / request-chat buttons that ask forFalse. ForumTopicEditedtells a removed icon ("") from an unedited one (nil).
🤖 Claude Code plugin
Plugin 1.3.0 → 1.4.0.
- New
rich-messagesskill — choosing HTML, Markdown or blocks; every ready-made constructor; inlineRichTextformatting; media and uploads; tables, lists, quotations, details, maps, formulas and buttons; streaming drafts; the limits; and the usual mistakes. - New
mini-app-authskill — authenticating Mini App users on a Go backend: send the rawinitData, parse it into a map of every field (a fixed struct breaks verification when Telegram adds a field), verify with the bot token (hash) for your own bot or with Telegram's Ed25519 key (signature, production and test keys) for another bot's — with an allowlist of bot ids — then checkauth_date; plus constant-time comparison, duplicate keys, sessions and a tested standard-library implementation. - The
lumexskill coversBotFullInfoandbot.Username, pointer options withnew(v),SetMySettings, callback queries without a message,OnBotInvite,OnCallbackQuerySuffix/OnCallbackQueryEquals, the entity parsing helpers, default timeouts, how sub-router middlewares compose and promoted-field literals (Go 1.27); it points to the two new skills and correctsInputFilePath, which returns(*InputFile, error). - The
telegram-widgetsskill edits widget data withnew(…).
⚙️ Internal
- Generator: a new
explicitZerolist (internal/gen/parse.go) types an optional field as a pointer when its zero value means something different from leaving it out.zeroCandidateflags likely ones from the docs' wording ("aren't specified remain unchanged", "defaults to True", "pass an empty string to remove … if omitted, … isn't changed", …);cmd/genprints a WARNING andTestExplicitZeroResolvedfails until each is decided —truefor a pointer,falsewhen the zero value is harmless — or when a key matches no field. Covered byTestExplicitZeroandTestZeroCandidate. - Docs snapshot bumped to 10.5; golden, determinism, no-untyped-fields and explicit-zero tests green, with 0 untyped fields across 396 object types, 69 enums, 29 unions and 194 methods.
- A maintainer-only Claude Code skill,
.claude/skills/bot-api-update, now holds the Bot API upgrade procedure — snapshot, warnings,keepPositional/explicitZero/patchUnionSubtypes, the router coverage test, tour rules, version bumps and these release notes — and CLAUDE.md points to it. go.modmoved togo 1.27and the code was modernised withgo fix; CI followsgo.mod(go-version-file)..gitignoreignoresexamples/localtest.
📦 Upgrade
go get github.com/kbgod/lumex/v2@v2.5.0
- Build with Go 1.27 or newer (see Breaking change 5).
- Only where code names the embedded
Userfield:bot.User.X→bot.X(which already worked in v2.4.0),bot.Useras a whole value →bot.BotFullInfo, andlumex.Bot{User: lumex.User{Username: …}}→lumex.Bot{Username: …}. GetMereturns*lumex.BotFullInfo: readCanJoinGroups,SupportsInlineQueriesand the other bot-only flags from it, not from aUser.- Wrap the text of an expandable quotation in a block, e.g.
NewInputRichBlockParagraph. - For the pointer fields in the table above:
Field: v→Field: new(v), and check fornilwhen readingChatPermissionsorForumTopicEdited. - Timeouts. A hand-rolled
GetUpdateslong poll withTimeout≥ 30 s, or an upload that takes over 5 minutes, needs its owncontext.WithTimeouton the call (orWithRequestTimeout/WithUploadTimeout) — otherwise the new default cuts it.GetUpdatesChanand the dispatcher already do this.
Good to know:
- Under
callback_query_mode"inline" (or "auto" for an inaccessible message), a callback query from the bot's own message has nomessage:ctx.Message()andctx.Chat()are nil andctx.ChatID()falls back to the sender — right in a private chat, wrong in a group.ctx.EditMessageTextkeeps working. has_topic_sidebartakes effect only with topics in private chats enabled: withhas_topics_enabledoff, Telegram accepts the call but keeps the sidebar off.- The
https://t.me/botinvite/…link needs a Telegram app that knows it; an older one readsbotinviteas a username and says the user doesn't exist.