python-telegram-bot
15.6K subscribers
90 links
The official channel for the python-telegram-bot library | https://python-telegram-bot.org
Download Telegram
Hi.

Many of you are eagerly waiting for the promised asyncio release. The developers team has been working on this for quite some time now and we are happy to say that the "14" release is closing in.

Many of you will also know that Telegram released an API update earlier today. So far we have added support for new API updates to version 13 rather quickly. However, each API update has slowed down the development of v14.

As the 6.0 API update is a relatively large one and an asyncio release is rather close at hand, we have decided to postpone adding support for the new API update until after an asyncio release is out. Our specific plan is as follows:

1️⃣ We do our best to get a v14 release out as fast as possible. This will be a pre-release.
2️⃣ We add support for Bot API 6.0 to v14.
3️⃣ We backport Bot API 6.0 to v13.
4️⃣ We positively consider backporting any Bot API updates to v13 as long as there is no stable v14 release. The backports may take more time than the updates for v14. If the development team has too few resources or the updates are too big, we may have to abandon API updates for v13 in favour of improving v14.

We are aware that our decision may not be convenient for everyone. We hope that you can understand that we aim to advance our library and not delay the asyncio release any more.

Sincerely,
the PTB development team
We've just released v20.0a0. 🥳
A big thank you to everyone who contributed to this release.

asyncio has arrived and with it major redesigns of our code base.

The release notes and changelogs are way too long to fit in a channel post, so this time we published them over at telegra.ph.
Please do not upgrade before reading the release notes!
python-telegram-bot
Hi. Occasionally the developer team of PTB is being asked about the status of the ptbtest library, which is intended to help write unit tests for bots built with python-telegram-bot. ptbtest is currently not maintained and not compatible with recent PTB…
Unfortunately, our call for maintainers for ptbtest was not successful. We therefore decided that the first person who reaches out to us and wants to take over maintenance of ptbtest will be granted the corresponding access rights and ownerships. We still expect that person to demonstrate a minimum level of experience with Python packaging, open source development and familiarity with ptbtest.
We've just released v13.12.
Thank you to everyone who contributed to this release.

To upgrade from v13.x to v13.12, use 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.0 (#3027)
⚠️ Note that all parameters, attributes and classes with voice_chat/VoiceChat in their name have been renamed to video_chat/VideoChat in order to comply with the Bot API update. The old names have been kept for backwards compatibility. Also note that after the next API update, only HTTPS links will be allowed in the login_url argument of InlineKeyboardButton.
• Drop Support for Python 3.6 (#3027)

Minor Changes:

• Documentation Improvements (#3029)
We've just released v20.0a1.
Thank you to everyone who contributed to this release.

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

This update brings a few breaking changes compared to v20.0a0, but none of them are as disruptive as the changes introduced in v20.0a0. Let us highlight a few of them:

CallbackContext.DEFAULT_TYPE was moved to ContextTypes.DEFAULT_TYPE.
• Support for ujson was dropped. If you want to use a 3rd party JSON library, you can do so by using a custom implementation of BaseRequest.
• The day argument of JobQueue.run_daily was changed to align with cron, i.e. 0 is now Sunday and 6 is Saturday
• The context argument of JobQueue.run_* was renamed to data and similarly for Job.context - in hopes of avoiding confusion in the future.

This release also brings some new features, including Application.post_init to effortlessly execute asyncio code on startup and version info in the style of sys.version_info.

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

Major Changes:

• Drop Support for ujson and instead BaseRequest.parse_json_payload (#3037, #3072)
• Drop InputFile.is_image (#3053)
• Drop Explicit Type conversions in __init__ s (#3056)
• Handle List-Valued Attributes More Consistently (#3057)
• Split {Command, Prefix}Handler And Make Attributes Immutable (#3045)
• Align Behavior Of JobQueue.run_daily With cron (#3046 by jcnecio)
• Make PTB Specific Keyword-Only Arguments for PTB Specific in Bot methods (#3035 by tal66)
• Adjust Equality Comparisons to Fit Bot API 6.0 (#3033)
• Add Tuple Based Version Info (#3030)- Improve Type Annotations for CallbackContext and Move Default Type Alias to ContextTypes.DEFAULT_TYPE (#3017, #3023)
• Rename Job.context to Job.data (#3028 by aditya-yadav-27)
• Rename Handler to BaseHandler (#3019)

New Features:

• Add Application.post_init (#3078)
• Add Arguments chat/user_id to CallbackContext And Example On Custom Webhook Setups (#3059)
• Add Convenience Property Message.id (#3077 by dglitxh)
• Add Example for WebApp (#3052)
• Rename telegram.bot_api_version to telegram.__bot_api_version__ (#3030)

Bug Fixes:

• Fix Non-Blocking Entry Point in ConversationHandler (#3068)
• Escape Backslashes in escape_markdown (#3055)

Dependencies:

• Update httpx requirement from ~=0.22.0 to ~=0.23.0 (#3069)
• Update cachetools requirement from ~=5.0.0 to ~=5.2.0 (#3058, #3080)

Minor Changes, Documentation Improvements and CI:

• Move Examples To Documentation (#3089)
• Documentation Improvements and Update Dependencies (#3010, #3007 by KnorpelSenf, #3012, #3067 by Aditya-Rajgor, #3081, #3082)
• Improve Some Unit Tests (#3026)
• Update Code Quality dependencies (#3070, #3032,#2998, #2999)
• Don't Set Signal Handlers On Windows By Default (#3065)
• Split {Command, Prefix}Handler And Make Attributes Immutable (#3045)
• Apply isort and Update pre-commit.ci Configuration (#3049)
• Adjust pre-commit Settings for isort (#3043)
• Add Version Check to Examples (#3036)
• Use Collection Instead of List and Tuple (#3025)
• Remove Client-Side Parameter Validation (#3024)
• Don't Pass Default Values of Optional Parameters to Telegram (#2978)
• Stabilize Application.run_* on Python 3.7 (#3009)
• Ignore Code Style Commits in git blame (#3003)
• Adjust Tests to Changed API Behavior (#3002)
We've just released v20.0a2.
Thank you to everyone who contributed to this release.

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

This update brings full support for Bot API 6.1 along with some minor, non-breaking changes.

Note that a backport of API 6.1 to v13.x will be released before the end of this week.

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

Major Changes

• Full Support for API 6.1 (#3112)

New Features

• Add Additional Shortcut Methods to Chat (#3115 by aditya-yadav-27)
• Mermaid-based Example State Diagrams (#3090 by cyc8)

Minor Changes, Documentation Improvements and CI

• Documentation Improvements (#3103, #3121 by ExalFabu, #3098 by david-shiko)
• Stabilize CI (#3119)
• Bump pyupgrade from 2.32.1 to 2.34.0 (#3096)
• Bump furo from 2022.6.4 to 2022.6.4.1 (#3095)
• Bump mypy from 0.960 to 0.961 (#3093)
We've just released v13.13.
Thank you to everyone who contributed to this release.

To upgrade from v13.x to v13.13, use 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.1 (#3117)
We've just released v20.0a3.
Thank you to everyone who contributed to this release.

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

This update brings full support for Bot API 6.2. It also brings a brand-new mechanism for rate limiting API requests. This is a replacement for the former MessageQueue and is well-integrated into the PTB framework. Also check out our updated wiki page on this topic!

Major Changes

• Full Support for API 6.2 (#3195)

New Features

• New Rate Limiting Mechanism (#3148)
• Make chat/user_data Available in Error Handler for Errors in Jobs (#3152)
• Add Application.post_shutdown (#3126 by ExalFabu)

Bug Fixes

• Fix helpers.mention_markdown for Markdown V1 and Improve Related Unit Tests (#3155)
• Add api_kwargs Parameter to Bot.log_out and Improve Related Unit Tests (#3147)
• Make Bot.delete_my_commands a Coroutine Function (#3136)
• Fix ConversationHandler.check_update not respecting per_user (#3128)

Minor Changes, Documentation Improvements and CI

• Add Python 3.11 to Test Suite & Adapt Enum Behaviour (#3168)
• Drop Manual Token Validation (#3167)
• Simplify Unit Tests for Bot.send_chat_action (#3151)
• Drop pre-commit Dependencies from requirements-dev.txt (#3120)
• Change Default Values for concurrent_updates and connection_pool_size (#3127)
• Documentation Improvements (#3139, #3153 by pawanrai9999, #3135 by aditya-yadav-27)
• Type Hinting Fixes (#3202)

Dependencies

• Bump sphinx from 5.0.2 to 5.1.1 (#3177)
• Update pre-commit Dependencies (#3085)
• Bump pytest-asyncio from 0.18.3 to 0.19.0 (#3158)
• Update tornado requirement from ~=6.1 to ~=6.2 (#3149)
• Bump black from 22.3.0 to 22.6.0 (#3132)
• Bump actions/setup-python from 3 to 4 (#3131)
We've just released v20.0a4.

This is a hot fix release for a bug in setup.py that prevented optional dependencies from being recognized correctly.

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

• Fix a Bug in setup.py Regarding Optional Dependencies (#3209)
We've just released v13.14.
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.2 (#3203)

Minor Changes:

• Documentation Improvements (#3144, #3140 by javad94, #3164 by javad94)
• Pin tornado to Version 6.1 (#3145)
It's time for Hacktoberfest again! 💻🥨

Hacktoberfest is an event that encourages developers and everyone else to contribute to open source repositories. If you ever thought about starting coding or giving back to your favourite open source repositories, now is the time! Head over to the hacktoberfest website to learn more about it.

This is also a great opportunity to contribute to python-telegram-bot 🙂 We have already prepared a few issues on our repositories, but feel free to begin a hunt for improvements and fixes by yourself! We'd like to especially point out issue #3109 and #3110, which are about improving our documentation. These issues can be tackled in multiple pull requests and are perfect for first time contributors.

⚠️ If you want to tackle an issue, please be sure to
• leave a comment on the issue before you work on it, so that we can assign you. That way, we avoid duplicate pull requests for the same issue by several people.
• read the contribution guide.

For questions about making contributions to python-telegram-bot we also have a dedicated developer chat group, where you can get focused help if you run into problems while preparing your pull request.
Hacktoberfest has ended and we're happy to report that several contributions were proposed by first-time contributors, most of which have already been merged. We want to sincerely thank everyone who participated in this event!

Of course contributions are just as welcome outside of Hacktoberfest 🙃 Feel free to join us in the development group chat and we'll be happy to get you started.
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)