Open
Conversation
And the field request_managed_bot in KeyboardButton
Contributor
There was a problem hiding this comment.
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, andPreparedKeyboardButton. - 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 afilters.StatusUpdate.MANAGED_BOT_CREATEDfilter.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the first section of Bot API 9.6 - Managed bots
Check-list for PRs
.. versionadded:: NEXT.VERSION,.. versionchanged:: NEXT.VERSION,.. deprecated:: NEXT.VERSIONor ``.. versionremoved:: NEXT.VERSION` to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)AUTHORS.rst(optional)__all__sIf 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
self._id_attrsand corresponding documentation__init__acceptsapi_kwargsas keyword-onlyAdded New Shortcuts
telegram.Chat&telegram.Userfor all methods that acceptchat/user_idtelegram.Messagefor all methods that acceptchat_idandmessage_idtelegram.Messageshortcuts: Addedquoteargument if methods acceptreply_to_message_idtelegram.CallbackQueryfor all methods that accept eitherchat_idandmessage_idorinline_message_idIf Relevant
telegram.constantsand shortcuts to them as class variablestelegram.Message.effective_attachmenttelegram.ext.ConversationHandler_extbot.pybot_methods.rstREADME.rst(including the badge) andtelegram.constants.BOT_API_VERSION_INFOtelegram.ext.ExtBotfor new methods that either accept areply_markupin some form or have a return type that is/containstelegram.Message