Conversation
Telegram Premium - Added the method giftPremiumSubscription, allowing bots to gift a user a Telegram Premium subscription paid in Telegram Stars.
Telegram Premium - Added the field premium_subscription_duration to the class TransactionPartnerUser for transactions involving a Telegram Premium subscription purchased by the bot. - Added the field transaction_type to the class TransactionPartnerUser, simplifying the differentiation and processing of all transaction types.
There was a problem hiding this comment.
Pull Request Overview
This PR introduces Telegram Premium subscription gifting functionality and related API changes. Key updates include adding the new method gift_premium_subscription in both the extbot and bot modules, updating the TransactionPartnerUser class to require a new transaction_type (and premium_subscription_duration), and adding the PremiumSubscription enum with associated constants.
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_official/exceptions.py | Extended the ignored parameters mapping to include TransactionPartnerUser.transaction_type. |
| tests/test_bot.py | Added tests for gift_premium_subscription with validations for proper parameter mapping. |
| tests/_payment/stars/test_transactionpartner.py | Updated tests and fixtures for TransactionPartnerUser to incorporate transaction_type and premium_subscription_duration. |
| tests/_payment/stars/test_startransactions.py | Adjusted TransactionPartnerUser instantiations; one instance uses a nonstandard transaction_type. |
| telegram/ext/_extbot.py | Added gift_premium_subscription method and its alias giftPremiumSubscription. |
| telegram/constants.py | Introduced the PremiumSubscription enum and updated the constants list. |
| telegram/_payment/stars/transactionpartner.py | Updated TransactionPartnerUser to enforce and include transaction_type and premium_subscription_duration in equality comparisons. |
| telegram/_bot.py | Added gift_premium_subscription with thorough docstrings and created camelCase aliases. |
| changes/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml | Updated changelog to reference a new pull request closing threads. |
Files not reviewed (1)
- docs/source/inclusions/bot_methods.rst: Language not supported
Bibo-Joshi
left a comment
There was a problem hiding this comment.
Hey, thanks for another api 9.0 PR :D You didn't request a review yet, I hope it's okay that I went ahead already anways. I saw only a few minor things in the code. What I did notice is that a shortcut User.gift_premium_subscription would make sense :)
- Add shortcut User.gift_premium_subscription - Add a missing ".. versionadded" - Update "deprecations" change note to recommend using keyword arguments for added required fields to existing classes.
|
Perfectly fine, I just forgot to request the review :D |
# Conflicts: # changes/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml
Check-list for PRs
.. versionadded:: NEXT.VERSION,.. versionchanged:: NEXT.VERSION,.. deprecated:: NEXT.VERSIONor.. versionremoved:: NEXT.VERSIONto the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)CSI standard <https://standards.mousepawmedia.com/en/stable/csi.html>____all__sStability Policy <https://docs.python-telegram-bot.org/stability_policy.html>_ in case of deprecations or changes to documented behaviorIf the PR contains API changes (otherwise, you can ignore this passage)
Checked the Bot API specific sections of the
Stability Policy <https://docs.python-telegram-bot.org/stability_policy.html>_Created a PR to remove functionality deprecated in the previous Bot API release (
see here <https://docs.python-telegram-bot.org/en/stable/stability_policy.html#case-2>_)New classes:
self._id_attrsand corresponding documentationAdded new shortcuts:
~telegram.Chat& :class:~telegram.Userfor all methods that acceptchat/user_id~telegram.Messagefor all methods that acceptchat_idandmessage_id~telegram.Messageshortcuts: Addedquoteargument if methods acceptsreply_to_message_id~telegram.CallbackQueryfor all methods that accept eitherchat_idandmessage_idorinline_message_idIf relevant:
telegram.constantsand shortcuts to them as class variables_extbot.pybot_methods.rstTelegram Premium