python-telegram-bot
16.3K subscribers
91 links
The official channel for the python-telegram-bot library | https://python-telegram-bot.org
Download Telegram
We've just released v20.0a5.
Thank you to everyone who contributed to this release.

If you want to upgrade from v20.0a4 to v20.0a5, please upgrade with pip install -U --pre python-telegram-bot.
Before upgrading from v13.x to v20.0a5, please carefully read the v20.0a0 release notes.

This update brings full support for Bot API 6.3. It also brings new features and some breaking changes.

The first breaking change is that the method File.download was split into the methods File.download_to_drive and File.download_to_memory.

The second breaking change is only relevant for those who run their bot against a local Bot API server: You will now have to explicitly tell PTB that you're doing this, by using ApplicationBuilder().token(TOKEN).local_mode(True).build(). The upside of this change is that you can now pass file paths as input for e.g. send_document independetly of whether you're using a local API server or not.

The final breaking change is another step in our effort to make PTB as free of third party dependencies as possible. In particular, now almost no third party dependencies are installed by default. To use features of the telegram.ext module that require these dependencies, you will have to install PTB e.g. via pip install python-telegram-bot[job-queue]. Please have a look at the readme for more information.

A notable new feature is the new attribute api_kwargs of all Telegram classes, which allows to access newly added fields even before PTB adds support for new API versions. Moreover, the string representations of the Telegram classes was completely overhauled.

Also, we're delighted to have two new developers in our team: clot27, @mr_lemontree, who have already contributed to this release!

The full changelog has become rather long, so please find it here.
We've just released v20.0a6.
Thank you to everyone who contributed to this release.

If you want to upgrade from v20.0a5 to v20.0a6, please upgrade with pip install -U --pre python-telegram-bot. Before upgrading from v13.x to v20.0a6, please carefully read the v20.0a0 release notes.

This is a bug fix release that addresses some issues of the previous release v20.0a5. In particular, the download methods of telegram.File are now actually named as originally announced.

For the full list of changes and improvements, please see below.

Bug Fixes

• Only Persist Arbitrary callback_data if ExtBot.callback_data_cache is Present (#3384)
• Improve Backwards Compatibility of TelegramObjects Pickle Behavior (#3382)
• Fix Naming and Keyword Arguments of File.download_* Methods (#3380)
• Fix Return Value Annotation of Chat.create_forum_topic (#3381)
We've just released v13.15.
Thank you to everyone who contributed to this release.

As usual, upgrade using pip install -U python-telegram-bot.

Please note that we have recently published the pre-release v20.0a0 and the focus of our development efforts is directed at v20. Our plans for the future of v13 are explained in the v20.0a0 release notes.

Major Changes:

• Full Support for API 6.3 (#3392)

Bug Fixes:

• Fix Bugs in Bot.answer_web_app_query (#3364)
We've just released v20.0b0.
Thank you to everyone who contributed to this release.

If you want to upgrade from v20.0a6 to v20.0b0, please upgrade with pip install -U --pre python-telegram-bot. Before upgrading from v13.x to v20.0b0, please carefully read the v20.0a0 release notes.

This release is the first beta release. It contains the last breaking changes that we had on our roadmap for v20. We are not planning to introduce any more breaking changes before releasing v20.0. Instead, we will mainly give the beta release a short testing period and fix any bugs that might come up. Then it's time for a v20.0 release.

For the legacy versions v13.x, this beta release means two things. Firstly, we are not going to backport API changes to v13.x anymore. Secondly, we will stop support for v13.x completely once the stable v20.0 release is there.

The breaking change in this release is that TelegramObject and its subclasses are now immutable, i.e. attributes of Update, Message and all other Telegram classes can no longer be overridden or deleted. Moreover, all attributes and return values of bot methods that formerly where lists are now tuples. With these changes, the library better reflects that all the objects usually represent a fixed state on the Telegram servers that can only be changed by making a request to the Bot API.

Please see below for the full changelog.

Major Changes

• Make TelegramObject Immutable (#3249)

Minor Changes, Documentation Improvements and CI

• Reduce Code Duplication in Testing Defaults (#3419)
• Add Notes and Warnings About Optional Dependencies (#3393)
• Simplify Internals of Bot Methods (#3396)
• Reduce Code Duplication in Several Bot Methods (#3385)
• Documentation Improvements (#3386, #3395, #3398, #3403 by Viicos)

Dependencies

• Bump pytest-xdist from 3.0.2 to 3.1.0 (#3415)
• Bump pytest-asyncio from 0.20.2 to 0.20.3 (#3417)
pre-commit autoupdate (#3409)
Happy New Year, everyone!

For the first day of 2023, we have a special surprise for you: We've just released v20.0 🤩
We want to thank everyone who contributed to this release, and we also want to thank the community for their patience and feedback during the pre-release phase!

v20.0 is the long await-ed stable release of the v20.x series that was first announced in January 2021 and got its first alpha release in May 2022. It redesigns python-telegram-bot to be built with the modern asyncio framework and brings a plethora of improvements. Before upgrading to v20.0 from an older version, please be sure to read the release notes of v20.0a0, which still give a good overview of the major changes in v20.0, as well as the transition guide. The transition guide also includes a script that can help easing a transition from v13.x to v20.0.

We are excited to finally make this step and are looking forward to an asyncio future of python-telegram-bot together with you.

As mentioned in the past release notes and announcements, this release marks the end of support for v13.x. While the documentation for the older versions will still be available, the v13.x series will no longer be updated, and we will also no longer provide support for these versions.

Apart from a new version number, this release also includes two notable changes. Firstly, it brings full support for Bot API 6.4. Moreover, bot methods now accept any kind of collections.abc.Sequence objects as input instead of only lists and tuples.

For the full list of changes and improvements, please see below.

Major Changes

• Full Support For Bot API 6.4 (#3449)

Minor Changes, Documentation Improvements and CI

• Documentation Improvements (#3428, #3423, #3429, #3441 by Eisberge, #3404, #3443 by zeshuaro)
• Allow Sequence Input for Bot Methods (#3412)
• Update Link-Check CI and Replace a Dead Link (#3456)
• Freeze Classes Without Arguments (#3453)
• Add New Constants (#3444)
• Override Bot.__deepcopy__ to Raise TypeError (#3446)
• Add Log Decorator to Bot.get_webhook_info (#3442)
• Add Documentation On Verifying Releases (#3436)
• Drop Undocumented Job.__lt__ (#3432)

Dependencies

• Downgrade sphinx to 5.3.0 to Fix Search (#3457)
• Bump sphinx from 5.3.0 to 6.0.0 (#3450)
We've just released v20.1.
Thank you to everyone who contributed to this release.

As usual, upgrade using pip install -U python-telegram-bot.

This update brings full support for Bot API 6.5.

⚠️ With the introduction of ChatJoinRequest.user_chat_id, Telegram emphasizes that User.id does not necessarily coincide with Chat.id in private chats with users. While this has been the case so far, and it's probably unlikely to change without the introduction of new Telegram features, we would like to make you aware of this. For example, this means that shortcut methods like User.send_message will break if User.id will ever not be equal to Chat.id.

Moreover, this release some new functionality and pushes the cross-reference links in the documentation to the next level.

For the full list of changes and improvements, please see below.

Major Changes

• Full Support for Bot API 6.5 (#3530)

New Features

• Add Application(Builder).post_stop (#3466)
• Add Chat.effective_name Convenience Property (#3485 by Viicos)
• Allow to Adjust HTTP Version and Use HTTP/2 by Default (#3506)

Documentation Improvements

• Enhance chatmemberbot Example (#3500)
• Automatically Generate Cross-Reference Links (#3501, #3529, #3523)
• Add Some Graphic Elements to Docs (#3535)
• Various Smaller Improvements (#3464, #3483, #3484, #3497 by shivamsn97, #3512 by CrsiX, #3515, #3498)

Minor Changes, Documentation Improvements and CI

• Update Copyright to 2023 (#3459)
• Stabilize Tests on Closing and Hiding the General Forum Topic (#3460)
• Fix Dependency Warning Typo (#3474)
• Cache Dependencies on GitHub Actions (#3469)
• Store Documentation Builts as GitHub Actions Artifacts (#3468)
• Add ruff to pre-commit Hooks (#3488)
• Improve Warning for days Parameter of JobQueue.run_daily (#3503)
• Improve Error Message for NetworkError (#3505)
• Lock Inactive Threads Only Once Each Day (#3510)
• Bump pytest from 7.2.0 to 7.2.1 (#3513)
• Check for 3D Arrays in check_keyboard_type (#3514)
• Explicit Type Annotations (#3508)
• Increase Verbosity of Type Completeness CI Job (#3531)
• Fix CI on Python 3.11 + Windows (#3547)

Dependencies

• Bump actions/stale from 6 to 7 (#3461)
• Bump dessant/lock-threads from 3.0.0 to 4.0.0 (#3462)
pre-commit autoupdate (#3470)
• Update httpx requirement from ~=0.23.1 to ~=0.23.3 (#3489)
• Update cachetools requirement from ~=5.2.0 to ~=5.2.1 (#3502)
• Improve Config for ruff and Bump to v0.0.222 (#3507)
• Update cachetools requirement from ~=5.2.1 to ~=5.3.0 (#3520)
• Bump isort to 5.12.0 (#3525)
• Update apscheduler requirement from ~=3.9.1 to ~=3.10.0 (#3532)
pre-commit autoupdate (#3537)
• Update cryptography requirement to >=39.0.1 to address Vulnerability (#3539)
We've just released v20.2.
Thank you to everyone who contributed to this release.

As usual, upgrade using pip install -U python-telegram-bot.

This update brings full support for Bot API 6.6.

Bot API 6.6 renamed several arguments and attributes from thumb to thumbnail and refactored some arguments of sticker related methods. We made these changes largely backwards compatible (also by slightly deviating from the official Bot API here and there). We still highly recommend to adapt your code to the new namings as we will eventually remove the deprecated arguments and attributes. Deprecation warnings are issued for all affected methods and attributes, which should help with these adaptions.

Moreover, since several users reported networking issues with HTTP/2, we reverted to HTTP/1.1 as the default protocol. HTTP/2 is still available via an optional dependency.

Major Changes

• Full Support for API 6.6 (#3584)
• Revert to HTTP/1.1 as Default and make HTTP/2 an Optional Dependency (#3576)

Minor Changes, Documentation Improvements and CI

• Documentation Improvements (#3565, #3600 by beiluonever)
• Handle Symbolic Links in was_called_by (#3552)
• Tidy Up Tests Directory (#3553)
• Enhance Application.create_task (#3543 by sam-mosleh)
• Make Type Completeness Workflow Usable for PRs from Forks (#3551)
• Refactor and Overhaul the Test Suite (#3426)

Dependencies

• Bump pytest-asyncio from 0.20.3 to 0.21.0 (#3624)
• Bump furo from 2022.12.7 to 2023.3.23 (#3625)
• Bump pytest-xdist from 3.2.0 to 3.2.1 (#3606)
pre-commit autoupdate (#3577)
• Update apscheduler requirement from ~=3.10.0 to ~=3.10.1 (#3572)
• Bump pytest from 7.2.1 to 7.2.2 (#3573)
• Bump pytest-xdist from 3.1.0 to 3.2.0 (#3550)
• Bump sphinxcontrib-mermaid from 0.7.1 to 0.8 (#3549)
We've just released v20.3.
Thank you to everyone who contributed to this release.

As usual, upgrade using pip install -U python-telegram-bot.

This update brings full support for Bot API 6.7.

Moreover, it introduces a brand-new stability policy. While earlier versions of python-telegram-bot also had stable interfaces, they had no explicit stability policy and this addition now closes that gap. Please be sure to give it a read.

Major Changes

• Full support for API 6.7 (#3673)
• Add a Stability Policy (#3622)

New Features

• Add Application.mark_data_for_update_persistence (#3607)
• Make Message.link Point to Thread View Where Possible (#3640 by Trifase)
• Localize Received datetime Objects According to Defaults.tzinfo (#3632 by Trifase)

Minor Changes, Documentation Improvements and CI

• Empower ruff (#3594)
• Drop Usage of sys.maxunicode (#3630)
• Add String Representation for RequestParameter (#3634)
• Stabilize CI by Rerunning Failed Tests (#3631)
• Give Loggers Better Names (#3623)
• Add Logging for Invalid JSON Data in BasePersistence.parse_json_payload (#3668)
• Improve Warning Categories & Stacklevels (#3674)
• Stabilize test_delete_sticker_set (#3685)
• Shield Update Fetcher Task in Application.start (#3657)
• Recover 100% Type Completeness (#3676)
• Documentation Improvements (#3628, #3636 by Yossi, #3694 by ibragimovgeorge)

Dependencies

• Bump actions/stale from 7 to 8 (#3644)
• Bump furo from 2023.3.23 to 2023.3.27 (#3643)
pre-commit autoupdate (#3646, #3688)
• Remove Deprecated codecov Package from CI (#3664)
• Bump sphinx-copybutton from 0.5.1 to 0.5.2 (#3662)
• Update httpx requirement from ~=0.23.3 to ~=0.24.0 (#3660)
• Bump pytest from 7.2.2 to 7.3.1 (#3661)
We’ve just released v20.4.

Thank you to everyone who contributed to this release.

As usual, upgrade using pip install -U python-telegram-bot.

This update drops support for Python 3.7, which reached its end of life on June 6th. python-telegram-bot now requires Python 3.8 or higher.

Moreover, this update introduces a new mechanism that allows to customize the concurrent handling of updates. This makes it possible to e.g. handle updates different chats concurrently while still processing updates from the same chat sequentially. See the updated wiki page on concurrency and the documentation of the new BaseUpdateProcessor class for more information.

Major Changes

• Drop Support for Python 3.7 (#3728, #3742 by @Trifase, #3749 by @thefunkycat, #3740 closes #3732, #3754 closes #3731, #3753, #3764, #3762, #3759 closes #3733)

New Features

• Make Integration of APScheduler into JobQueue More Explicit (#3695)
• Introduce BaseUpdateProcessor for Customized Concurrent Handling of Updates (#3654 closes #3509)

Minor Changes

• Fix Inconsistent Type Hints for timeout Parameter of Bot.get_updates (#3709 by @revolter)
• Use Explicit Optionals (#3692 by @MiguelX413)

Bug Fixes

• Fix Wrong Warning Text in KeyboardButton.__eq__ (#3768)

Documentation Improvements

• Explicitly set allowed_updates in Examples (#3741 by @Trifase closes #3726)
• Bump furo and sphinx (#3719)
• Documentation Improvements (#3698, #3708 by @revolter, #3767)
• Add Quotes for Installation Instructions With Optional Dependencies (#3780)
• Exclude Type Hints from Stability Policy (#3712)
• Set httpx Logging Level to Warning in Examples (#3746 closes #3743)

Internal Changes

• Drop a Legacy pre-commit.ci Configuration (#3697)
• Add Python 3.12 Beta to the Test Matrix (#3751)
• Use Temporary Files for Testing File Downloads (#3777)
• Auto-Update Changed Version in Other Files After Dependabot PRs (#3716)
• Add More ruff Rules (#3763)
• Rename _handler.py to _basehandler.py (#3761)
• Automatically Label pre-commit-ci PRs (#3713)
• Rework pytest Integration into GitHub Actions (#3776)
• Fix Two Bugs in GitHub Actions Workflows (#3739)

Dependency Updates

• Update cachetools requirement from ~=5.3.0 to ~=5.3.1 (#3738)
• Update aiolimiter requirement from ~=1.0.0 to ~=1.1.0 (#3707)
pre-commit autoupdate (#3791)
• Bump sphinxcontrib-mermaid from 0.8.1 to 0.9.2 (#3737)
• Bump pytest-xdist from 3.2.1 to 3.3.0 (#3705)
• Bump srvaroa/labeler from 1.5.0 to 1.6.0 (#3786)
• Bump dependabot/fetch-metadata from 1.5.1 to 1.6.0 (#3787)
• Bump dessant/lock-threads from 4.0.0 to 4.0.1 (#3785)
• Bump pytest from 7.3.2 to 7.4.0 (#3774)
• Update httpx requirement from ~=0.24.0 to ~=0.24.1 (#3715)
• Bump pytest-xdist from 3.3.0 to 3.3.1 (#3714)
• Bump pytest from 7.3.1 to 7.3.2 (#3758)
pre-commit autoupdate (#3747)
We’ve just released v20.5.
Thank you to everyone who contributed to this release.
As usual, upgrade using pip install -U python-telegram-bot.

This update brings support for Bot API 6.8. Moreover, it removes functionality that was deprecated with the introduction of Bot API 6.5, 6.6 or 6.7. The largest part of this is the renaming of all thumb(_*) arguments and attributes to thumbnail(_*). The removal of this functionality is in line with our stability policy.

Apart from that, this release brings a new argument has_args for CommandHandler as well as the new method Application.stop_running.

For the full list of changes and improvements, please see below.

Major Changes

• API 6.8 (#3853)
• Remove Functionality Deprecated Since Bot API 6.5, 6.6 or 6.7 (#3858)

New Features

• Extend Allowed Values for HTTP Version (#3823 closes #3821)
• Add has_args Parameter to CommandHandler (#3854 by @thatguylah closes #3798)
• Add Application.stop_running() and Improve Marking Updates as Read on Updater.stop() (#3804)

Minor Changes

• Type Hinting Fixes for WebhookInfo (#3871)
• Test and Document Exception.__cause__ on NetworkError (#3792 closes #3778)
• Add Support for Python 3.12 RC (#3847)

Documentation Improvements

• Remove Version Check from Examples (#3846)
• Documentation Improvements (#3803, #3797, #3816 by @trim21, #3829 by @aelkheir)
• Provide Versions of customwebhookbot.py with Different Frameworks (#3820 closes #3717)

Dependency Updates

pre-commit autoupdate (#3824)
• Bump srvaroa/labeler from 1.6.0 to 1.6.1 (#3870)
• Bump sphinx from 7.0.1 to 7.1.1 (#3818)
• Bump sphinx from 7.2.3 to 7.2.5 (#3869)
• Bump furo from 2023.5.20 to 2023.7.26 (#3817)
• Update apscheduler requirement from ~=3.10.3 to ~=3.10.4 (#3862)
• Bump sphinx from 7.2.2 to 7.2.3 (#3861)
• Bump pytest-asyncio from 0.21.0 to 0.21.1 (#3801)
• Bump sphinx-paramlinks from 0.5.4 to 0.6.0 (#3840)
• Update apscheduler requirement from ~=3.10.1 to ~=3.10.3 (#3851)
• Bump furo from 2023.7.26 to 2023.8.19 (#3850)
• Bump sphinx from 7.1.2 to 7.2.2 (#3852)
• Bump sphinx from 7.1.1 to 7.1.2 (#3827)
We’ve just released v20.6.
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 6.9. Moreover, it removes backward compatibility for functionality deprecated in API 6.8. This is in line with our stability policy.

For the full list of changes and improvements, please see the below changelog.

Major Changes

• Drop Backward Compatibility Layer Introduced in #3853 (API 6.8) (#3873)
• Full Support for Bot API 6.9 (#3898)

New Features

• Add Rich Equality Comparison to WriteAccessAllowed (#3911 closes #3909)
• Add __repr__ Methods Added in #3826 closes #3770 to Sphinx Documentation (#3901 closes #3889)
• Add String Representation for Selected Classes (#3826 closes #3770)

Minor Changes

• Add Support Python 3.12 (#3915)
• Documentation Improvements (#3910)

Internal Changes

• Verify Type Hints for Bot Method & Telegram Class Parameters (#3868)
• Move Bot API Tests to Separate Workflow File (#3912)
• Fix Failing file_size Tests (#3906)
• Set Threshold for DeepSource’s PY-R1000 to High (#3888)
• One-Time Code Formatting Improvement via --preview Flag of black (#3882)
• Move Dunder Methods to the Top of Class Bodies (#3883)
• Remove Superfluous Defaults.__ne__ (#3884)

Dependency Updates

pre-commit autoupdate (#3876)
• Update pre-commit Dependencies (#3916)
• Bump actions/checkout from 3 to 4 (#3914)
• Update httpx requirement from ~=0.24.1 to ~=0.25.0 (#3891)
• Bump furo from 2023.8.19 to 2023.9.10 (#3890)
• Bump sphinx from 7.2.5 to 7.2.6 (#3892)
• Update tornado requirement from ~=6.2 to ~=6.3.3 (#3675)
• Bump pytest from 7.4.0 to 7.4.2 (#3881)
We’ve just released v20.7.
Thank you to everyone who contributed to this release.
As usual, upgrade using pip install -U python-telegram-bot.

This release brings support for socket options, a filter for mentions and separate handling of write_timeout for media methods as new features. Moreover, inconsistencies in the handling of the read_timeout parameter for get_updates were fixed.
⚠️ Note that the changes related to timeout behavior come with some deprecations. Please pay attention to the warnings that PTB issues, especially if you have a custom implementation of the BaseRequest class.

For the full list of changes and improvements, please see the below changelog.

New Features

• Add JobQueue.scheduler_configuration and Corresponding Warnings (#3913 closes #3837)
• Add Parameter socket_options to HTTPXRequest (#3935 closes #2965)
• Add ApplicationBuilder.(get_updates_)socket_options (#3943)
• Improve write_timeout Handling for Media Methods (#3952)
• Add filters.Mention (#3941 closes #3799)
• Rename proxy_url to proxy and Allow httpx.{Proxy, URL} as Input (#3939 closes #3844)

Bug Fixes & Changes

• Adjust read_timeout Behavior for Bot.get_updates (#3963 closes #3893)
• Improve BaseHandler.__repr__ for Callbacks without __qualname__ (#3934)
• Fix Persistency Issue with Ended Non-Blocking Conversations (#3962)
• Improve Type Hinting for Arguments with Default Values in Bot (#3942)

Documentation Improvements

• Add Documentation for __aenter__ and __aexit__ Methods (#3907 closes #3886)
• Improve Insertion of Kwargs into Bot Methods (#3965)

Internal Changes

• Adjust Tests to New Error Messages (#3970)

Dependency Updates

• Bump pytest-xdist from 3.3.1 to 3.4.0 (#3975)
pre-commit autoupdate (#3967)
• Update httpx requirement from ~=0.25.1 to ~=0.25.2 (#3983)
• Bump pytest-xdist from 3.4.0 to 3.5.0 (#3982)
• Update httpx requirement from ~=0.25.0 to ~=0.25.1 (#3961)
• Bump srvaroa/labeler from 1.6.1 to 1.7.0 (#3958)
• Update cachetools requirement from ~=5.3.1 to ~=5.3.2 (#3954)
• Bump pytest from 7.4.2 to 7.4.3 (#3953)
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)
We’ve just released v21.0.
Thank you to everyone who contributed to this release.
As usual, upgrade using pip install -U python-telegram-bot.

This update brings full support for Bot API 7.1. Moreover, it removes backward compatibility for functionality deprecated in API 7.0. This is in line with our stability policy.

Moreover, this update brings a new major version. However, apart from the Bot API related removals, it does not contain any breaking changes and is backwards compatible to v20.x.

The bump of the major version is solely intended to mark that the next step in PTBs development after the introduction of v20.0 in January 2023. Since then, we have been working actively on smoothing out rough edges of v20, which sometimes involved deprecating functionality. To not carry old baggage around forever and ensure that PTB remains maintainable, this deprecated functionality will have to be removed at some point. This version bump brings us closer to that point, while still keeping the promise of a stable user interface that we formalized with our explicit stability policy.

For the full list of changes and improvements, please see below changelog.

Major Changes

• Remove Functionality Deprecated in API 7.0 (#4114 closes #4099)
• API 7.1 (#4118)

New Features

• Add Parameter media_write_timeout to HTTPXRequest and Method ApplicationBuilder.media_write_timeout (#4120 closes #3864)
• Handle Properties in TelegramObject.__setstate__ (#4134 closes #4111)

Bug Fixes

• Add Missing Slot to Updater (#4130 closes #4127)

Documentation Improvements

• Improve HTML Download of Documentation (#4146 closes #4050)
• Documentation Improvements (#4109, #4116)
• Update Copyright to 2024 (#4121 by @aelkheir closes #4041)

Internal Changes

• Apply pre-commit Checks More Widely (#4135)
• Refactor and Overhaul test_official (#4087 closes #3874)
• Run Unit Tests in PRs on Requirements Changes (#4144)
• Make Updater.stop Independent of CancelledError (#4126)

Dependency Updates

• Relax Upper Bound for httpx Dependency (#4148)
• Bump test-summary/action from 2.2 to 2.3 (#4142)
• Update cachetools requirement from ~=5.3.2 to ~=5.3.3 (#4141)
• Update httpx requirement from ~=0.26.0 to ~=0.27.0 (#4131)
We’ve just released v21.0.1.
As usual, upgrade using pip install -U python-telegram-bot.

This is a hotfix release for a faulty package configuration.

Bug Fixes

• Remove docs from Package (#4150)
Yesterday the Telegram team released Bot API 7.2. This update brings many changes, which we are already working on implementing.

However there is one major backward incompatible change, which is the removal of the fields StickerSet.is_animated/is_video. This unfortunately breaks the method Bot.get_sticker_set and affects all versions of our library. The current workaround for this if you have v20.8+ is to directly call
await bot.do_api_request("get_sticker_set", {"name": sticker_set_name})
and parse the resulting JSON return value. The upcoming version of the library will address this incompatibility.

Thank you for understanding and being patient.
We’ve just released v21.1.
Thank you to everyone who contributed to this release.
As usual, upgrade using pip install -U python-telegram-bot.

This update brings full support for Bot API 7.2. Moreover, it removes backward compatibility for functionality deprecated in API 7.1. This is in line with our stated policy

⚠️ Please note that the Bot API update includes breaking changes for Bot.set_sticker_set_thumbnail, InputSticker and StickerSet. See also our earlier post and this GitHub thread for additional information.
To integrate the Bot API changes well into the PTB framework, the Message.repl_* methods now also automatically pass the new business_connection_id parameter and the Update.effective_* properties consider the new update types as well.

Another change for the Message.reply_* methods is they now reply in the same topic by default.

For the full list of changes and improvements, please see the below changelog.

Major Changes

• API 7.2 (#4180 closes #4179 and #4181, #4181)
• Make ChatAdministratorRights/ChatMemberAdministrator.can_*_stories Required (API 7.1) (#4192)

Minor Changes

• Refactor Debug logging in Bot to Improve Type Hinting (#4151 closes #4010)

New Features

• Make Message.reply_* Reply in the Same Topic by Default (#4170 by @aelkheir closes #4139)
• Accept Socket Objects for Webhooks (#4161 closes #4078)
• Add Update.effective_sender (#4168 by @aelkheir closes #4085)

Documentation Improvements

• Documentation Improvements (#4171, #4158 by @teslaedison)

Internal Changes

• Temporarily Mark Tests with get_sticker_set as XFAIL due to API 7.2 Update (#4190)

Dependency Updates

pre-commit autoupdate (#4184)
• Bump dependabot/fetch-metadata from 1.6.0 to 2.0.0 (#4185)
We’ve just released v21.1.1.
Thank you to everyone who contributed to this release.
As usual, upgrade using pip install -U python-telegram-bot.

This is a bug fix release. It addresses a bug that was introduced in v21.1 in the new default behavior of the message_thread_id parameter of the shortcut methods Message.reply_*. Moreover, it’s now ensured that passing message_thread_id=None actually overrides the default behavior.

Bug Fixes

• Fix Bug With Parameter message_thread_id of Message.reply_* (#4207 closes #4205)

Minor Changes

• Remove Deprecation Warning in JobQueue.run_daily (#4206 by @Konano)
• Fix Annotation of EncryptedCredentials.decrypted_secret (#4199 by @marinelay closes #4198)
We've just released v21.2.
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 the new Bot API 7.3. Moreover, it removes backward compatibility for functionality deprecated in API 7.2. This is in line with our stated policy.
Moreover, it includes improvements for the startup and shutdown behavior of Application.

For the full list of changes and improvements, please see the below changelog.

Major Changes

• Full Support for Bot API 7.3 (#4246, #4260, #4243, #4248, #4242 closes #4236, #4247 by aelkheir)
• Remove Functionality Deprecated by Bot API 7.2 (#4245)

New Features

• Add Version to PTBDeprecationWarning (#4262 closes #4261)
• Handle Exceptions in building CallbackContext (#4222)

Bug Fixes

• Call Application.post_stop Only if Application.stop was called (#4211 closes #4210)
• Handle SystemExit raised in Handlers (#4157 closes #4155 and #4156)
• Make Birthdate.to_date Return a datetime.date Object (#4251)

Documentation Improvements

• Documentation Improvements (#4217)

Internal Changes

• Add New Rules to ruff Config (#4250)
• Adapt Test Suite to Changes in Error Messages (#4238)

Dependency Updates

• Bump furo from 2024.4.27 to 2024.5.6 (#4252)
pre-commit autoupdate (#4239)
• Bump pytest from 8.1.1 to 8.2.0 (#4231)
• Bump dependabot/fetch-metadata from 2.0.0 to 2.1.0 (#4228)
• Bump pytest-asyncio from 0.21.1 to 0.21.2 (#4232)
• Bump pytest-xdist from 3.6.0 to 3.6.1 (#4233)
• Bump furo from 2024.1.29 to 2024.4.27 (#4230)
• Bump srvaroa/labeler from 1.10.0 to 1.10.1 (#4227)
• Bump pytest from 7.4.4 to 8.1.1 (#4218)
• Bump sphinx from 7.2.6 to 7.3.7 (#4215)
• Bump pytest-xdist from 3.5.0 to 3.6.0 (#4215)
Hi all.

We have decided to deprecate the python-telegram-bot-raw library and no longer provide updates for it.

In Februrary 2021, we introduced the library python-telegram-bot-raw that provides the telegram module without telegram.ext. Back then, we felt this to be right thing to do since the rather new v13 had introduced additional required dependencies for the JobQueue.

Since then, v20 has seen the light of day. With v20, python-telegram-bot only has a single required dependency, httpx, for the networking backend. All other dependencies for opt-in functionality of telegram.ext are purely optional. Moreover, according to the numbers that we are aware of ([1], [2], [3], [4]), the python-telegram-bot-raw library never gained a considerable user base compared to python-telegram-bot.

Since maintaining python-telegram-bot-raw still consumes some resources and is currently also hindering the modernization of PTBs packaging setup, we have therefore made this decision. The next release of PTB will add a corresponding warning to python-telegram-bot-raw. This will be the last update for python-telegram-bot-raw.

What does this mean to you?

Almost nothing. All you have to do is remove that trailing -raw from your requirements file. That's it. No code changes are necessary, since python-telegram-bot-raw is a subset of python-telegram-bot. No additional dependencies will be installed.

Thank you for your understanding and your continued usage and support of the python-telegram-bot library.
Your PTB Developer Team
We've just released v21.3.
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 the new Bot API 7.4. Moreover, it removes backward compatibility for functionality deprecated in Bot API 7.3. This is in line with our stability policy.

As announced previously, this is also the last update for the python-telegram-bot-raw library. It will not receive any further updates. Please switch to using python-telegram-bot.

For the full list of changes and improvements, please see the below changelog.

Major Changes

• Full Support for Bot API 7.4 (#4286, #4280, #4285, #4276 closes #4275, #4283, #4278, #4279)
• Deprecate python-telegram-bot-raw (#4270)
• Remove Functionality Deprecated in Bot API 7.3 (#4266 closes #4244)

New Features

• Add Parameter chat_id to ChatMemberHandler (#4290 by uniquetrij closes #4287)

Documentation Improvements

• Documentation Improvements (#4264 closes #4240)

Internal Changes

• Add setuptools to requirements-dev.txt (#4282)
• Update Settings for pre-commit.ci (#4265)

Dependency Updates

• Bump pytest from 8.2.0 to 8.2.1 (#4272)