Post content
We’ve just released v20.8. Thank you to everyone who contributed to this release. As usual, upgrade using pip install -U python-telegram-bot. This release brings full support for Bot API 7.0. A few comments are in order about this. 1️⃣ Bot API 7.0 introduced the classes MaybeInaccessibleMessage and InaccessibleMessage. To check if Message.pinned_message or CallbackQuery.message are usable, it hence no longer suffices to do if message.pinned_message/if callback_query.message. We have overridden MaybeInaccessibleMessage.__bool__ to ease the transition, but highly recommend to manually check your code for compatibility. You can use the helper property MaybeInaccessibleMessage.is_accessible or things like if message.pinned_message is not None/if isinstance(message.pinned_message, Message) instead. Note that Update.effective_message does not return MaybeInaccessibleMessage but only Message. 2️⃣ Constructing the arguments quote_position and quote_entities for the new ReplyParameters can be tedious. We have added helper methods Message.compute_quote_position_and_entities and Message.build_reply_arguments to make life easier for you. Note that to avoid confusion, we have deprecated the argument quote of Message.reply_* in favour of the new argument do_quote. 3️⃣ Due to the renaming of user_shared to users_shared, we deprecated filters.USER_SHARED in favour of the new filters.USERS_SHARED. We're pointing this out here, since accessing filters.USER_SHARED does not issue a warning at runtime. 4️⃣ We faced some difficulties while updating Message.text/caption_markdown/html to the new block quote entities. After contacting Telegram about inconsistencies in the handling of message entities, we were adviced to work with MessageEntity objects directly rather than converting them back into formatted strings as done by Message.text/caption_markdown/html. As these utility properties have been available in PTB for a long time, we have decided to still keep and extend them to new message entity types. However, they will handle only the most common use cases and might not be able to handle all edge cases. We have added corresponding notes to the documentation. Apart from Bot API related changes, this release adds a parameter pattern to PreCheckoutQueryHandler and adds filters.SuccessfulPayment. Moreover, to make new Bot API functionality available to you even before we release an update of the library, we have added the new method Bot.do_api_request that allows you to directly call any Bot API method even if it is not yet implemented in the library. Please also have a look at this wiki page on how PTB makes new Bot API functionality available to you. For the full list of changes and improvements, please see the documentation and below (we just left out dependency updates and internal changes to fit the message length limit). Major Changes • API 7.0 (#4034 closes #4033, #4038 by @aelkheir) Minor Changes • Fix Type Hint for filters Parameter of MessageHandler (#4039 by @Palaptin) • Deprecate filters.CHAT (#4083 closes #4062) • Improve Error Handling in Built-In Webhook Handler (#3987 closes #3979) New Features • Add Parameter pattern to PreCheckoutQueryHandler and filters.SuccessfulPayment (#4005 by @aelkheir closes #3752) • Add Missing Conversions of type to Corresponding Enum from telegram.constants (#4067) • Add Support for Unix Sockets to Updater.start_webhook (#3986 closes #3978) • Add Bot.do_api_request (#4084 closes #4053) • Add AsyncContextManager as Parent Class to BaseUpdateProcessor (#4001) Documentation Improvements • Documentation Improvements (#3919) • Add Docstring to Dunder Methods (#3929 closes #3926) • Documentation Improvements (#4002, #4079 by @kenjitagawa, #4104 by @xTudoS)