Skip to content

Bot API 10.4 update - #2655

Open
Brian-1812 wants to merge 8 commits into
eternnoir:masterfrom
Brian-1812:feat/bot-api-10.4-rest
Open

Brian-1812 wants to merge 8 commits into
eternnoir:masterfrom
Brian-1812:feat/bot-api-10.4-rest

Conversation

@Brian-1812

@Brian-1812 Brian-1812 commented Nov 12, 2026 •

Copy link
Copy Markdown

Description

The rest of Bot API 10.4. This PR is built on #2654 (widgets), so until that one merges it shows both commits. Only the last commit, "Bot API 10.4: remaining sections", is new here.

  • Ephemeral replies to callback queries: chat_id of the 14 send methods and EphemeralMessageParameters.receiver_user_id are optional. Pass chat_id=None; it is not sent.
  • Rich quotes: TextQuote.rich_texts, ReplyParameters.quote_rich_texts.
  • TON wallet: TonWalletTransfer, Message.ton_wallet_transfer, ChatFullInfo.ton_wallet_card. StoryAreaPosition is now AreaPosition; the old name still works and logs a deprecation warning.
  • Share themes: ChatShareTheme, EmojiType, backdrops, ChatFullInfo.share_theme, get_chat_share_theme_backdrops.
  • Gifts: get_unique_gift, delete_business_account_gift.
  • General: RichTextTonAddress, PaidMessagesWaived, new verify_user/verify_chat parameters, doc updates. README badge is 10.4.

chat_id stays the first positional argument, so it has no default. An ephemeral reply is bot.send_message(None, "text", ephemeral_message_parameters=...). Happy to change this if you prefer another shape.

Describe your tests

New unit tests parse doc-shaped JSON and check the request payloads, sync and async. cd tests && py.test: 339 passed, 73 skipped. I also ran all 14 send methods with chat_id=None against a local fake Bot API server: none of them sent chat_id. Not tested against the live API.

Python version: 3.12.2

OS: macOS 26.1

Checklist:

  • I added/edited example on new feature/change (if exists)
  • My changes won't break backward compatibility
  • I made changes both for sync and async

🤖 Generated with Claude Code

Brian-1812 and others added 7 commits November 11, 2026 22:34
Add the widget part of Bot API 10.4:
- types Widget, WidgetQuery, SharedWidgetQuery, WidgetQueryType
  (data, sign_data, sent_transaction), WidgetQueryWallet,
  InputWidgetMessageContent and InputSharedWidgetMessageContent;
- TonWalletCard, TonWalletCardSticker, TonNft and TonNftAttribute,
  because WidgetQueryTypeData.wallet_card uses them;
- Message.widget, ExternalReplyInfo.widget, Update.widget_query and
  Update.shared_widget_query;
- send_widget, send_shared_widget, answer_widget_query,
  edit_message_widget_data and edit_shared_widget_data, sync and async;
- widget_query_handler and shared_widget_query_handler, sync and async.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the parts of Bot API 10.4 that are not widgets:
- ephemeral replies to callback queries: chat_id of the 14 send methods
  and EphemeralMessageParameters.receiver_user_id are optional now;
  a None chat_id is not sent;
- TextQuote.rich_texts and ReplyParameters.quote_rich_texts;
- TonWalletTransfer, Message.ton_wallet_transfer and
  ChatFullInfo.ton_wallet_card;
- StoryAreaPosition is now AreaPosition; the old name stays as a
  deprecated subclass;
- ChatShareTheme (emoji, unique_gift), EmojiType (emoji, custom_emoji),
  ChatShareThemeBackdrop(s), ChatFullInfo.share_theme and
  get_chat_share_theme_backdrops;
- get_unique_gift and delete_business_account_gift;
- RichTextTonAddress, PaidMessagesWaived and Message.paid_messages_waived;
- custom_description_parse_mode and custom_description_entities in
  verify_user and verify_chat;
- doc text for the new MessageEntity types and suggested_username;
- README: Bot API 10.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- types: each :param description is on one line, like the other classes;
- answer_widget_query: use the API method names, as in the API text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- types: each :param description is on one line, like the other classes;
- answer_widget_query: use the API method names, as in the API text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- verify_user, verify_chat: the new parameters are marked "Optional.",
  like the parameters added in the Bot API 10.3 update;
- types: each :param description is on one line, like the other classes;
- tests: remove the two TeleBot/AsyncTeleBot tests that repeat the
  apihelper and types tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Brian-1812
Brian-1812 marked this pull request as ready for review November 12, 2026 14:22
@Badiboy
Badiboy requested a balanced review from Copilot November 13, 2026 20:34

Copilot AI 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.

🟡 Changes recommended

Active issues break compatibility with existing Update constructor calls, cause media handlers to skip widget messages, and make TON-address deserialization fail when the type field is present.

3 open issues
What changed in this PR

Extends pyTelegramBotAPI’s synchronous and asynchronous clients with the remaining Bot API 10.4 features, building on the widget support from #2654.

Changes:

  • Supports ephemeral callback replies without chat_id, rich quotes, TON wallet data, share themes, gift operations, and verification formatting.
  • Includes widget types, methods, and query handlers from the underlying PR.
  • Adds parsing, payload, and handler tests; updates API documentation and the supported-version badge.
File Description
tests/​test_types.py Tests new types, parsing, and serialization.
tests/​test_telebot.py Tests synchronous widget handlers and updates fixtures.
tests/​test_handler_backends.py Updates fixtures for widget query fields.
tests/​test_async_telebot.py Tests asynchronous widget handlers.
tests/​test_apihelper_95.py Tests new request payloads and omitted chat IDs.
telebot/​util.py Registers new service and update types.
telebot/​types.py Adds API models, fields, and serialization support.
telebot/​asyncio_helper.py Implements asynchronous request payload changes.
telebot/​async_telebot.py Exposes asynchronous methods and widget handlers.
telebot/​apihelper.py Implements synchronous request payload changes.
telebot/​__init__.py Exposes synchronous methods and widget handlers.
README.md Updates the supported Bot API badge to 10.4.

Review effort: Balanced

Comment thread telebot/types.py Resolved
Comment thread telebot/types.py Resolved
Comment thread telebot/util.py
'suggested_post_paid', 'gift_upgrade_sent', 'chat_owner_left', 'chat_owner_changed', 'managed_bot_created',
'poll_option_added', 'poll_option_deleted', 'community_chat_added', 'community_chat_removed',
'community_chat_joined'
'community_chat_joined', 'ton_wallet_transfer', 'paid_messages_waived'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual. Both proposal and included comment.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added 'widget' to content_type_media in cca2ae9.

@Badiboy Badiboy changed the title Bot API 10.4: remaining sections Bot API 10.4 update Nov 13, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Brian-1812

Copy link
Copy Markdown
Author

Updated: content_type_media now includes 'widget' (cca2ae9). I left the two Update constructor points unchanged, as you suggested. This PR now covers all of Bot API 10.4.

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.

3 participants