Skip to content

API 9.6: Managed Bots#5197

Open
harshil21 wants to merge 13 commits intoapi-9.6-centralfrom
api-9.6-managed-bots
Open

API 9.6: Managed Bots#5197
harshil21 wants to merge 13 commits intoapi-9.6-centralfrom
api-9.6-managed-bots

Conversation

@harshil21
Copy link
Copy Markdown
Member

Completes the first section of Bot API 9.6 - Managed bots

Check-list for PRs

  • Added .. versionadded:: NEXT.VERSION, .. versionchanged:: NEXT.VERSION, .. deprecated:: NEXT.VERSION or ``.. versionremoved:: NEXT.VERSION` to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)
  • Created new or adapted existing unit tests
  • Documented code changes according to the CSI standard
  • Added myself alphabetically to AUTHORS.rst (optional)
  • Added new classes & modules to the docs and all suitable __all__ s
  • Checked the Stability Policy in case of deprecations or changes to documented behavior

If the PR contains API changes (otherwise, you can ignore this passage)

  • Checked the Bot API specific sections of the Stability Policy

  • Created a PR to remove functionality deprecated in the previous Bot API release (see here)

  • New Classes

    • Added self._id_attrs and corresponding documentation
    • __init__ accepts api_kwargs as keyword-only
  • Added New Shortcuts

    • In telegram.Chat & telegram.User for all methods that accept chat/user_id
    • In telegram.Message for all methods that accept chat_id and message_id
    • For new telegram.Message shortcuts: Added quote argument if methods accept reply_to_message_id
    • In telegram.CallbackQuery for all methods that accept either chat_id and message_id or inline_message_id
  • If Relevant

    • Added new constants at telegram.constants and shortcuts to them as class variables
    • Linked new and existing constants in docstrings instead of hard-coded numbers and strings
    • Added new message types to telegram.Message.effective_attachment
    • Added new handlers for new update types
    • Added new filters for new message (sub)types
    • Added or updated documentation for the changed class(es) and/or method(s)
    • Added the new method(s) to _extbot.py
    • Added or updated bot_methods.rst
    • Updated the Bot API version number in all places: README.rst (including the badge) and telegram.constants.BOT_API_VERSION_INFO
    • Added logic for arbitrary callback data in telegram.ext.ExtBot for new methods that either accept a reply_markup in some form or have a return type that is/contains telegram.Message

@harshil21 harshil21 requested a review from Copilot April 4, 2026 11:10
@harshil21 harshil21 added the ⚙️ bot-api affected functionality: bot-api label Apr 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds initial support for Telegram Bot API 9.6 “Managed Bots” to the library by introducing new API objects, update/handler support, bot methods, filters, and accompanying docs/tests.

Changes:

  • Introduces new Telegram objects: ManagedBotCreated, ManagedBotUpdated, KeyboardButtonRequestManagedBot, and PreparedKeyboardButton.
  • Adds new bot API methods + ExtBot wrappers: get_managed_bot_token, replace_managed_bot_token, save_prepared_keyboard_button.
  • Integrates managed-bot update handling via Update.managed_bot, ManagedBotUpdatedHandler, and a filters.StatusUpdate.MANAGED_BOT_CREATED filter.

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/test_user.py Extends User test coverage for can_manage_bots.
tests/test_update.py Adds managed_bot update test cases (effective_* coverage updated).
tests/test_preparedkeyboardbutton.py New tests for PreparedKeyboardButton.
tests/test_message.py Adds managed_bot_created message payload coverage.
tests/test_managedbot.py New tests for ManagedBotCreated/ManagedBotUpdated.
tests/test_keyboardbuttonrequestmanagedbot.py New tests for KeyboardButtonRequestManagedBot.
tests/test_keyboardbutton.py Extends KeyboardButton tests for request_managed_bot.
tests/test_bot.py Adds request-parameter assertions for new bot methods.
tests/ext/test_managedbotupdatedhandler.py New tests for ManagedBotUpdatedHandler.
tests/ext/test_filters.py Adds filter test coverage for MANAGED_BOT_CREATED.
tests/auxil/dummy_objects.py Adds dummy object entry for PreparedKeyboardButton.
tests/_files/test_photo.py Broadens accepted thumb.file_size values.
src/telegram/ext/filters.py Adds StatusUpdate.MANAGED_BOT_CREATED and includes it in StatusUpdate.ALL.
src/telegram/ext/_handlers/managedbotupdatedhandler.py Implements new ManagedBotUpdatedHandler.
src/telegram/ext/_extbot.py Adds ExtBot wrappers for managed-bot methods and save_prepared_keyboard_button.
src/telegram/ext/init.py Exposes ManagedBotUpdatedHandler in telegram.ext.
src/telegram/constants.py Adds MessageType.MANAGED_BOT_CREATED and UpdateType.MANAGED_BOT.
src/telegram/_user.py Adds User.can_manage_bots.
src/telegram/_update.py Adds Update.managed_bot parsing and effective_user support.
src/telegram/_preparedkeyboardbutton.py New PreparedKeyboardButton TelegramObject.
src/telegram/_message.py Adds Message.managed_bot_created parsing.
src/telegram/_managedbot.py New ManagedBotCreated and ManagedBotUpdated TelegramObjects.
src/telegram/_keyboardbuttonrequestmanagedbot.py New KeyboardButtonRequestManagedBot TelegramObject.
src/telegram/_keyboardbutton.py Adds KeyboardButton.request_managed_bot parsing/storage.
src/telegram/_bot.py Adds core bot methods for managed-bot tokens and saving prepared keyboard buttons.
src/telegram/init.py Exposes new objects from the top-level telegram package.
docs/source/telegram.preparedkeyboardbutton.rst Adds API docs page for PreparedKeyboardButton.
docs/source/telegram.managedbotupdated.rst Adds API docs page for ManagedBotUpdated.
docs/source/telegram.managedbotcreated.rst Adds API docs page for ManagedBotCreated.
docs/source/telegram.keyboardbuttonrequestmanagedbot.rst Adds API docs page for KeyboardButtonRequestManagedBot.
docs/source/telegram.ext.managedbotupdatedhandler.rst Adds API docs page for ManagedBotUpdatedHandler.
docs/source/telegram.ext.handlers-tree.rst Registers the new handler docs page in the handlers tree.
docs/source/telegram.at-tree.rst Registers new types docs pages in the available-types tree.
docs/source/inclusions/bot_methods.rst Updates bot methods listing for new API methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚙️ bot-api affected functionality: bot-api

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants