Skip to content

Support Bot API 10.5 - #1402

Merged
yagop merged 5 commits into
yagop:masterfrom
SM-26:feat/bot-api-10.5
Nov 24, 2026
Merged

yagop merged 5 commits into
yagop:masterfrom
SM-26:feat/bot-api-10.5

Conversation

@SM-26

@SM-26 SM-26 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor
  • npm run check is clean (typecheck src + test + examples, lint:core, check:edge, unit suite)
  • npm run build is clean
  • Generated files are untouched / regenerated (src/types/schemas.ts and src/core/api.ts come from npm run generate:types; never hand-edit)

Description

Adds support for Bot API 10.5 (November 22, 2026).

Regenerated src/types/schemas.ts and src/core/api.ts with bun scripts/api-parser.ts. The run was clean: no unmapped types and no return-type fallbacks.

Breaking changes

Both follow breaking changes in Bot API 10.5 itself. Both are marked Breaking in the CHANGELOG.

API surface compared with master:

  • Generated: 193 -> 194 methods (setMySettings added); 3 types added (BotFullInfo, SetMySettingsParams, SetMySettingsResult), none removed; one const + type added (CallbackQueryMode, from the generator's PRELUDE); one return type changed (GetMeResult: User -> BotFullInfo); 10 fields removed from User; text -> blocks in the two expandable-quotation types; inviter added to WriteAccessAllowed. Nothing else removed or retyped.
  • Hand-written: bot.botInfo, ctx.me and the Context constructor's me provider are typed BotFullInfo; RichMessageBuilder.expandableBlockquote(text, credit?) -> expandableBlockquote(blocks, credit?).

1. Bot-only fields removed from User

getMe now returns the new BotFullInfo. The fields that only getMe ever filled (can_join_groups, can_read_all_group_messages, supports_inline_queries, supports_guest_queries, can_connect_to_business, has_main_web_app, has_topics_enabled, allows_users_to_create_topics, can_manage_bots, supports_join_request_queries) are no longer on User.

// Before (10.4)
const me = await bot.api.getMe();        // User
me.can_join_groups;                      // boolean | undefined

function canInline(u: User) {
  return u.supports_inline_queries;      // compiled
}

// After (10.5)
const me = await bot.api.getMe();        // BotFullInfo
me.can_join_groups;                      // boolean (now required)

function canInline(u: User) {
  return u.supports_inline_queries;      // TS error: not on User
}
function canInline(me: BotFullInfo) {    // fix: take BotFullInfo
  return me.supports_inline_queries;
}

Not affected: const me: User = await bot.api.getMe() still compiles (BotFullInfo is assignable to User), and bot.botInfo / ctx.me are now typed BotFullInfo, so reading these fields from them keeps working.

2. Expandable block quotations take blocks, not text

RichBlockExpandableBlockQuotation and InputRichBlockExpandableBlockQuotation replace text with blocks. RichMessageBuilder.expandableBlockquote follows the wire format and now has the same signature as blockquote.

// Before (10.4)
new RichMessageBuilder().expandableBlockquote("Long text", "credit");
// -> { type: "expandable_blockquote", text: "Long text", credit: "credit" }

// After (10.5)
new RichMessageBuilder().expandableBlockquote((b) => b.paragraph("Long text"), "credit");
// -> { type: "expandable_blockquote", blocks: [{ type: "paragraph", text: "Long text" }], credit: "credit" }

A plain-JS caller that still passes a string sends blocks: "Long text", which Telegram rejects with a 400. I did not add a fallback that wraps a string in a paragraph; easy to add if you want one.

Upgrade checklist

  1. Code that reads a bot-only flag (can_join_groups, supports_inline_queries, ...) from a User: read it from getMe(), bot.botInfo or ctx.me instead, typed BotFullInfo.
  2. Code that types the getMe() result as User keeps compiling; change it to BotFullInfo to see the new fields.
  3. expandableBlockquote("text", credit) -> expandableBlockquote((b) => b.paragraph("text"), credit); a literal { type: "expandable_blockquote", text } -> { type: "expandable_blockquote", blocks: [...] }.
  4. Bots that set callback_query_mode to "auto" or "inline": handle presses without message (see below).

What's new

setMySettings - new method to change bot settings: inline mode, privacy mode, joining groups, topics in private chats, topic sidebar, callback_query_mode. has_topic_sidebar takes effect only while has_topics_enabled is on: with topics off, setMySettings({ has_topic_sidebar: true }) returns true but getMe keeps reporting false (checked live; noted in the CHANGELOG).

BotFullInfo - returned by getMe, with new active_usernames, inline_query_placeholder, needs_inline_query_location, has_topic_sidebar.

CallbackQueryMode - a typo-proof const for callback_query_mode, hand-curated in PRELUDE next to ParseMode: await api.setMySettings({ callback_query_mode: CallbackQueryMode.Inline }). The field stays string, so plain strings keep compiling, and the CallbackQueryMode type alias gives the union. Like ParseMode, it is hand-curated: a future fourth mode needs a PRELUDE edit, and plain strings keep working until then.

callback_query_mode - with "auto" or "inline", presses on the bot's own messages can arrive with inline_message_id instead of message. No type change (message was already optional), but for those presses ctx.chat is undefined, ctx.reply throws, and matchCallback does not match. Documented in the matchCallback comment, the ctx.reply doc, the README reply-tracking section, and the CHANGELOG; examples/17-callback-tracking.ts now edits through inline_message_id when message is absent. Only bots that opt in are affected.

WriteAccessAllowed.inviter - for users the owner invites with t.me/botinvite/<bot>. The link needs a client that knows it; per the lumex v2.5.0 release notes, an older one reads botinvite as a username and says the user does not exist.

Hand-work beyond regeneration

  • scripts/api-parser.ts: RETURN_OVERRIDES.getMe is now BotFullInfo; CallbackQueryMode in PRELUDE / PRELUDE_NAMES.
  • src/core/bot.ts, src/core/context.ts: bot.botInfo and ctx.me typed BotFullInfo.
  • src/core/richmessage.ts: expandableBlockquote takes nested blocks.
  • src/core/reply-tracking.ts, src/core/context.ts, README.md, examples/17-callback-tracking.ts: the callback_query_mode notes above.
  • test/unit/builders.test.ts: expandableBlockquote wire shape.
  • test/unit/serialize.test.ts: CallbackQueryMode is exported from the package root and serializes as its plain string.
  • test/unit/bot.test.ts: ctx.me is asserted as BotFullInfo.
  • test/e2e/methods.test.ts: setMySettings describe (writes back the current has_topic_sidebar, so nothing changes); getMe asserts has_topic_sidebar.
  • CHANGELOG under Unreleased, README badge v.10.5, regenerated doc/api.md.

Verification

  • npm run check: green (309 Bun unit tests). npm run test:node:unit: 286 pass on Node 26. npm run build: green.
  • Live e2e, scoped to getMe and setMySettings, against api.telegram.org with a throwaway bot: 2 pass.

Manual tests on production with a small script on this branch. Clients: Telegram for Android 13.3.1 (official Play Store app), Telegram X for Android 0.29.2.1832 (built November 18, before 10.5), Telegram Desktop 7.4.4, Web K, Web A, Telegram for iOS (latest from the App Store on the test day, exact version unknown). "Bot API" is what the API returned to the bot.

getMe / BotFullInfo

Bot API Android Telegram X Desktop Web K Web A iOS
Pass: returns BotFullInfo with active_usernames, has_topic_sidebar, needs_inline_query_location, and inline_query_placeholder when set N/A (no UI) N/A N/A N/A N/A N/A

setMySettings - has_topics_enabled + has_topic_sidebar

Bot API Android Telegram X Desktop Web K Web A iOS
Pass: getMe reflects both values Pass: topics in a sidebar No sidebar: topics show as service messages in the chat Pass: topics as tabs, or a side column after toggling Pass: sidebar Pass: sidebar Not tested

setMySettings - supports_inline_queries + inline_query_placeholder

Bot API Android Telegram X Desktop Web K Web A iOS
Pass: getMe returns the placeholder Pass: shown after @bot Pass Pass Pass Not shown Not tested

setMySettings - callback_query_mode: "inline"

Bot API Android Telegram X Desktop Web K Web A iOS
Pass: press arrives with only inline_message_id; editMessageText({ inline_message_id }) edits the message Pass Not tested (shows the edited text) Pass (answerCallbackQuery alert shown) Pass Not tested Not tested

Expandable block quotation with blocks

Bot API Android Telegram X Desktop Web K Web A iOS
Pass: accepted; the sent message echoes expandable_blockquote with the nested blocks and credit Renders, but expanded "Unsupported message" (no rich messages) Pass on 7.4.6 (November 24): starts collapsed with an expand arrow; 7.4.4 rendered it expanded Renders, but expanded Renders, but expanded Not tested

In every client that renders rich messages, a classic expandable_blockquote entity in the same chat renders collapsed, so the expanded rendering is on the client side. Desktop 7.4.6 now collapses the rich one too.

WriteAccessAllowed.inviter (t.me/botinvite)

Bot API Android Telegram X Desktop Web K Web A iOS
Not verified: the service message did not reach my listener Pass: invite sent from the owner side Not tested Not tested Not tested Not tested Pass: invitee sees "invited you to this bot" without /start

The invite cannot be repeated for the same user (deleting the chat or block/unblock still gives "already has a chat"), so I could not retry the Bot API side.

Notes

  • Client tables are a snapshot. Everything except inviter was verified against the Bot API itself (the "Bot API" column; inviter could not be retried, see its table). The other columns show how the apps rendered it on November 22, the day 10.5 came out, before most of them supported it (see the expandable quote row). I will repeat the client tests when the apps ship 10.5 support and update the tables; that does not block review.
  • Widgets (10.4) fail on production, unrelated to this PR. Since 2026-11-13, sendWidget returns Bad Request: INPUT_MEDIA_WIDGET_NOT_ALLOWED for general bots, even in a private chat (tdlib/telegram-bot-api#947). On 2026-11-21 the TDLib maintainer wrote that it is unknown whether general bots will be allowed again, and that there is no way to apply. So the widget e2e blocks in test/e2e/methods.test.ts fail regardless of this branch.
  • A ctx.editMessageText shortcut for presses without message is tracked in Add a ctx.editMessageText shortcut for presses that arrive without message (callback_query_mode) #1403.
  • ctx.reply still throws for a press without message. Falling back to the presser's chat would be right in a private chat but wrong in a group, so I kept the throw.

References

SM-26 and others added 3 commits November 22, 2026 11:14
Regenerate types and Api for setMySettings, BotFullInfo, WriteAccessAllowed.inviter
and the blocks-based expandable quotations. getMe now returns BotFullInfo, so
bot.botInfo and ctx.me are retyped, and RichMessageBuilder.expandableBlockquote
takes nested blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With Bot API 10.5 callback_query_mode, presses on the bot's own messages can
carry only inline_message_id. Note it in matchCallback, ctx.reply, the README
and the CHANGELOG, and let the paging example edit through inline_message_id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Verified live: with topics off, setMySettings({ has_topic_sidebar: true })
returns true but getMe keeps reporting false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yagop

yagop commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Thanks for the MR.

Two small requests before this lands - both follow-up-sized, but since the PR is already touching these spots:

1. Make callback_query_mode: CallbackQueryMode.Inline work.

The field is a prose enum we deliberately keep string (the MessageEntity.type / parse_mode convention), but callers currently have no typo-proof handle on its values. Please ship the const the way we ship ParseMode: hand-curated in the generator's PRELUDE (scripts/api-parser.ts, next to ParseMode), emitted into schemas.ts on regenerate - not a hand-edit of schemas.ts and not a new src/core module:

/** Every documented callback_query_mode value, typo-proof versus raw strings. */
export const CallbackQueryMode = {
  Default: "default",
  Auto: "auto",
  Inline: "inline",
} as const;
export type CallbackQueryMode = (typeof CallbackQueryMode)[number];

Then bun scripts/api-parser.ts + npm run generate:docs. Usage: await api.setMySettings({ callback_query_mode: CallbackQueryMode.Inline }) - the literal is assignable to the string param, plain-string callers keep compiling, and annotators get the union via the type alias. The accepted trade-off is the same as ParseMode's: hand-curated, so a future fourth mode needs a PRELUDE edit. If you want it stale-proof instead, the alternative is a phrase-check on the docs' "Must be one of ..." sentence that fails the generator run when the wording changes - happy either way, the const map is the minimum ask.

2. test/unit/bot.test.ts:293 - let seen: User | undefined should be BotFullInfo | undefined now that ctx.me is BotFullInfo (User is only used there as a type, so the line-4 import swaps too). Cosmetic, but it pins the new type where the test asserts it.

The ctx.editMessageText question from the description - moved to its own issue: #1403. It's out of scope here.

CallbackQueryMode (Default / Auto / Inline) is hand-curated in the
generator's PRELUDE next to ParseMode and emitted into schemas.ts.
callback_query_mode stays string. The generator checks the docs'
"Must be one of ..." sentence for setMySettings.callback_query_mode on
every run and fails if the listed modes differ from the const.

Also type ctx.me as BotFullInfo in test/unit/bot.test.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SM-26

SM-26 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Both are in 0f58fb1.

  1. CallbackQueryMode is in PRELUDE next to ParseMode and lands in schemas.ts on regenerate. I went with the stale-proof option as well: the generator now reads the "Must be one of ..." sentence of setMySettings.callback_query_mode and fails the run if the listed modes differ from the const (checked by adding a fake fourth mode, which fails the run as expected). A unit test in test/unit/serialize.test.ts imports the const from the package root and checks it goes out as "inline".

    One change to the snippet: (typeof CallbackQueryMode)[number] does not compile on an object (TS2537), so the alias is (typeof CallbackQueryMode)[keyof typeof CallbackQueryMode].

  2. test/unit/bot.test.ts now types seen as BotFullInfo, and the import swaps with it.

Thanks for opening #1403; I dropped the question from the description and linked the issue instead.

npm run check (309), test:node:unit (286 on Node 26), build, and the scoped live e2e for getMe / setMySettings all pass.

I'm marking the PR ready for review. The client tables in the description show how the apps rendered on release day; I will re-test and update them when the apps ship 10.5 support, without blocking the merge.

@SM-26
SM-26 marked this pull request as ready for review November 23, 2026 08:16
@yagop

yagop commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

The phrase-check turned out to be more than we want - that one's on me, it was the optional half of my ask. Let's keep the const exactly like ParseMode: hand-curated in the PRELUDE, no docs parsing, no machinery.

Concretely, please drop from scripts/api-parser.ts:

  • checkCallbackQueryModes() together with its doc comment,
  • the callbackQueryModesChecked flag, the if (m.name === "setMySettings") call site, and the post-loop guard,
  • the CALLBACK_QUERY_MODES const with its doc comment, and the Object.entries(CALLBACK_QUERY_MODES) interpolation in the PRELUDE - with the check gone, that interpolation has lost its only reason to exist (it was there to hand the check a JS value to compare against the docs). Inline the const literally in the PRELUDE, exactly like ParseMode is:
/** Every documented `callback_query_mode` value, typo-proof versus raw strings. */
export const CallbackQueryMode = {
  Default: "default",
  Auto: "auto",
  Inline: "inline",
} as const;
export type CallbackQueryMode = (typeof CallbackQueryMode)[keyof typeof CallbackQueryMode];

Keep everything else exactly as it is - the PRELUDE_NAMES entry, the serialize test, and the regenerated files. I verified locally that the whole simplification is output-neutral: after dropping the check and inlining the literal, bun scripts/api-parser.ts regenerates schemas.ts and api.ts byte-identical and biome stays clean, so the diff is confined to scripts/api-parser.ts. One small prose touch-up: the CHANGELOG entry loses its last sentence ("The generator checks it against the docs' list of modes on every run.").

Rationale, for the record: ParseMode is the precedent - curated, not parsed, and written as a plain literal in the PRELUDE. A three-value convenience const does not justify prose-parsing machinery (order-sensitive compare, quote-style handling, regex drift against the docs' wording), and it does not need a source-of-truth const plus interpolation to transcribe it either. If Telegram ever adds a fourth mode, the failure mode is benign: the const is missing a value until someone adds it, plain strings keep working, and ParseMode has carried exactly that trade-off for years.

Write CallbackQueryMode as a plain literal in the PRELUDE, like
ParseMode, and remove checkCallbackQueryModes() with its flag, call
site and guard. Generated output is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SM-26

SM-26 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Sorry for jumping the gun

Done in a8dd452: the check, its flag, call site and guard are gone, CallbackQueryMode is a plain literal in the PRELUDE like ParseMode, and the CHANGELOG sentence is dropped. The diff is confined to scripts/api-parser.ts and CHANGELOG.md.

One thing I noticed while regenerating: the docs have been reworded since November 22. The edit methods now say "the edited Message is returned; otherwise, True is returned", and the return-type rule at scripts/api-parser.ts:296 (/otherwise\s+True\s+is\s+returned/) no longer matches the comma. A fresh bun scripts/api-parser.ts therefore emits Message instead of Message | boolean for editMessageText, editMessageCaption, editMessageMedia, editMessageLiveLocation, stopMessageLiveLocation, editMessageReplyMarkup and setGameScore. I left those files as they were in this PR. Would you like me to open an issue for it?

Also, Telegram Desktop 7.4.6 now renders the rich expandable quote collapsed; I updated that cell in the description.

@yagop

yagop commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Verified a8dd452 - both items are exactly as requested:

  • CallbackQueryMode is a plain literal in the PRELUDE like ParseMode, the check/flag/call-site/guard/CALLBACK_QUERY_MODES are all gone, and the generated schemas.ts is byte-identical to the previous commit (regenerate + diff, api.ts untouched too). npm run check (309) and npm run build are green.
  • CHANGELOG now carries just the one definition sentence, correct.

The docs drift is real and exactly as you described it - I reproduced it independently: the fresh generator run narrows those seven edit methods from Message | boolean to Message, and the comma in "otherwise, True is returned" is what defeats the /otherwise\s+True\s+is\s+returned/ rule. The fix is one character class (/otherwise[,]?\s+True\s+is\s+returned/i) - verified locally that the regenerated api.ts comes back byte-identical. I did not touch the PR's files; this is a master-level generator bug, so I opened #1404 with the root cause and the verified fix. Over to whoever can take it on master.

From my side this is ready to merge, apart from whatever CI confirms. Nice work on the manual client tables.

@yagop
yagop merged commit 74158e1 into yagop:master Nov 24, 2026
7 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.

2 participants