From ff62e5304a7186bb9a068b28e2ad83895fd5e315 Mon Sep 17 00:00:00 2001 From: aelkheir <90580077+aelkheir@users.noreply.github.com> Date: Thu, 1 May 2025 08:26:44 +0300 Subject: [PATCH 1/6] Add class `StarAmount` and method `getBusinessAccountStarBalance`. Business Accounts - Added the class StarAmount and the method getBusinessAccountStarBalance, allowing bots to check the current Telegram Star balance of a managed business account. --- docs/source/inclusions/bot_methods.rst | 2 + docs/source/telegram.payments-tree.rst | 1 + docs/source/telegram.staramount.rst | 6 +++ telegram/__init__.py | 2 + telegram/_bot.py | 42 +++++++++++++++ telegram/_payment/stars/staramount.py | 68 +++++++++++++++++++++++ telegram/constants.py | 37 +++++++++++++ telegram/ext/_extbot.py | 22 ++++++++ tests/_payment/stars/test_staramount.py | 72 +++++++++++++++++++++++++ tests/auxil/dummy_objects.py | 2 + tests/test_business_methods.py | 15 ++++++ 11 files changed, 269 insertions(+) create mode 100644 docs/source/telegram.staramount.rst create mode 100644 telegram/_payment/stars/staramount.py create mode 100644 tests/_payment/stars/test_staramount.py diff --git a/docs/source/inclusions/bot_methods.rst b/docs/source/inclusions/bot_methods.rst index c649471828b..32f85d5171b 100644 --- a/docs/source/inclusions/bot_methods.rst +++ b/docs/source/inclusions/bot_methods.rst @@ -413,6 +413,8 @@ - Used for getting information about the business account. * - :meth:`~telegram.Bot.get_business_account_gifts` - Used for getting gifts owned by the business account. + * - :meth:`~telegram.Bot.get_business_account_star_balance` + - Used for getting the amount of Stars owned by the business account. * - :meth:`~telegram.Bot.read_business_message` - Used for marking a message as read. * - :meth:`~telegram.Bot.delete_story` diff --git a/docs/source/telegram.payments-tree.rst b/docs/source/telegram.payments-tree.rst index 3e6f42bdc97..94e4fec3c99 100644 --- a/docs/source/telegram.payments-tree.rst +++ b/docs/source/telegram.payments-tree.rst @@ -22,6 +22,7 @@ Your bot can accept payments from Telegram users. Please see the `introduction t telegram.shippingaddress telegram.shippingoption telegram.shippingquery + telegram.staramount telegram.startransaction telegram.startransactions telegram.successfulpayment diff --git a/docs/source/telegram.staramount.rst b/docs/source/telegram.staramount.rst new file mode 100644 index 00000000000..9d5a6e24572 --- /dev/null +++ b/docs/source/telegram.staramount.rst @@ -0,0 +1,6 @@ +StarAmount +========== + +.. autoclass:: telegram.StarAmount + :members: + :show-inheritance: diff --git a/telegram/__init__.py b/telegram/__init__.py index 1014bec3ea0..2ce505930e6 100644 --- a/telegram/__init__.py +++ b/telegram/__init__.py @@ -241,6 +241,7 @@ "ShippingAddress", "ShippingOption", "ShippingQuery", + "StarAmount", "StarTransaction", "StarTransactions", "Sticker", @@ -300,6 +301,7 @@ "warnings", ) +from telegram._payment.stars.staramount import StarAmount from telegram._payment.stars.startransactions import StarTransaction, StarTransactions from telegram._payment.stars.transactionpartner import ( TransactionPartner, diff --git a/telegram/_bot.py b/telegram/_bot.py index b2eb6638316..7ba151357ec 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -82,6 +82,7 @@ from telegram._message import Message from telegram._messageid import MessageId from telegram._ownedgift import OwnedGifts +from telegram._payment.stars.staramount import StarAmount from telegram._payment.stars.startransactions import StarTransactions from telegram._poll import InputPollOption, Poll from telegram._reaction import ReactionType, ReactionTypeCustomEmoji, ReactionTypeEmoji @@ -9480,6 +9481,45 @@ async def get_business_account_gifts( ) ) + async def get_business_account_star_balance( + self, + business_connection_id: str, + *, + read_timeout: ODVInput[float] = DEFAULT_NONE, + write_timeout: ODVInput[float] = DEFAULT_NONE, + connect_timeout: ODVInput[float] = DEFAULT_NONE, + pool_timeout: ODVInput[float] = DEFAULT_NONE, + api_kwargs: Optional[JSONDict] = None, + ) -> StarAmount: + """ + Returns the amount of Telegram Stars owned by a managed business account. Requires the + :attr:`~telegram.BusinessBotRights.can_view_gifts_and_stars` business bot right. + + .. versionadded:: NEXT.VERSION + + Args: + business_connection_id (:obj:`str`): Unique identifier of the business connection. + + Returns: + :class:`telegram.StarAmount` + + Raises: + :class:`telegram.error.TelegramError` + """ + data: JSONDict = {"business_connection_id": business_connection_id} + return StarAmount.de_json( + await self._post( + "getBusinessAccountStarBalance", + data, + read_timeout=read_timeout, + write_timeout=write_timeout, + connect_timeout=connect_timeout, + pool_timeout=pool_timeout, + api_kwargs=api_kwargs, + ), + bot=self, + ) + async def read_business_message( self, business_connection_id: str, @@ -11154,6 +11194,8 @@ def to_dict(self, recursive: bool = True) -> JSONDict: # noqa: ARG002 """Alias for :meth:`set_message_reaction`""" getBusinessAccountGifts = get_business_account_gifts """Alias for :meth:`get_business_account_gifts`""" + getBusinessAccountStarBalance = get_business_account_star_balance + """Alias for :meth:`get_business_account_star_balance`""" getBusinessConnection = get_business_connection """Alias for :meth:`get_business_connection`""" readBusinessMessage = read_business_message diff --git a/telegram/_payment/stars/staramount.py b/telegram/_payment/stars/staramount.py new file mode 100644 index 00000000000..9543210c21d --- /dev/null +++ b/telegram/_payment/stars/staramount.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# +# A library that provides a Python interface to the Telegram Bot API +# Copyright (C) 2015-2025 +# Leandro Toledo de Souza +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser Public License for more details. +# +# You should have received a copy of the GNU Lesser Public License +# along with this program. If not, see [http://www.gnu.org/licenses/]. +# pylint: disable=redefined-builtin +"""This module contains an object that represents a Telegram StarAmount.""" + + +from typing import Optional + +from telegram._telegramobject import TelegramObject +from telegram._utils.types import JSONDict + + +class StarAmount(TelegramObject): + """Describes an amount of Telegram Stars. + + Objects of this class are comparable in terms of equality. Two objects of this class are + considered equal, if their :attr:`amount` and :attr:`nanostar_amount` are equal. + + Args: + amount (:obj:`int`): Integer amount of Telegram Stars, rounded to ``0``; can be negative. + nanostar_amount (:obj:`int`, optional): The number of + :tg-const:`telegram.constants.StarAmount.NANOSTAR_VALUE` shares of Telegram + Stars; from :tg-const:`telegram.constants.StarAmountLimit.NANOSTAR_MIN_AMOUNT` + to :tg-const:`telegram.constants.StarAmountLimit.NANOSTAR_MAX_AMOUNT`; can be negative + if and only if :attr:`amount` is non-positive. + + Attributes: + amount (:obj:`int`): Integer amount of Telegram Stars, rounded to ``0``; can be negative. + nanostar_amount (:obj:`int`): Optional. The number of + :tg-const:`telegram.constants.StarAmount.NANOSTAR_VALUE` shares of Telegram + Stars; from :tg-const:`telegram.constants.StarAmountLimit.NANOSTAR_MIN_AMOUNT` + to :tg-const:`telegram.constants.StarAmountLimit.NANOSTAR_MAX_AMOUNT`; can be negative + if and only if :attr:`amount` is non-positive. + + """ + + __slots__ = ("amount", "nanostar_amount") + + def __init__( + self, + amount: int, + nanostar_amount: Optional[int] = None, + *, + api_kwargs: Optional[JSONDict] = None, + ): + super().__init__(api_kwargs=api_kwargs) + self.amount: int = amount + self.nanostar_amount: Optional[int] = nanostar_amount + + self._id_attrs = (self.amount, self.nanostar_amount) + + self._freeze() diff --git a/telegram/constants.py b/telegram/constants.py index bee3d07deba..264959a7924 100644 --- a/telegram/constants.py +++ b/telegram/constants.py @@ -100,6 +100,8 @@ "ReactionType", "ReplyLimit", "RevenueWithdrawalStateType", + "StarAmount", + "StarAmountLimit", "StarTransactions", "StarTransactionsLimit", "StickerFormat", @@ -2614,6 +2616,41 @@ class RevenueWithdrawalStateType(StringEnum): """:obj:`str`: A withdrawal failed and the transaction was refunded.""" +class StarAmount(FloatEnum): + """This enum contains constants for :class:`telegram.StarAmount`. + The enum members of this enumeration are instances of :class:`float` and can be treated as + such. + + .. versionadded:: NEXT.VERSION + """ + + __slots__ = () + + NANOSTAR_VALUE = 1 / 1000000000 + """:obj:`float`: The value of one nanostar as used in + :attr:`telegram.StarAmount.nanostar_amount`. + """ + + +class StarAmountLimit(IntEnum): + """This enum contains limitations for :class:`telegram.StarAmount`. + The enum members of this enumeration are instances of :class:`int` and can be treated as such. + + .. versionadded:: NEXT.VERSION + """ + + __slots__ = () + + NANOSTAR_MIN_AMOUNT = -999999999 + """:obj:`int`: Minimum value allowed for :paramref:`~telegram.StarAmount.nanostar_amount` + parameter of :class:`telegram.StarAmount`. + """ + NANOSTAR_MAX_AMOUNT = 999999999 + """:obj:`int`: Maximum value allowed for :paramref:`~telegram.StarAmount.nanostar_amount` + parameter of :class:`telegram.StarAmount`. + """ + + class StarTransactions(FloatEnum): """This enum contains constants for :class:`telegram.StarTransaction`. The enum members of this enumeration are instances of :class:`float` and can be treated as diff --git a/telegram/ext/_extbot.py b/telegram/ext/_extbot.py index 8347a26080f..095cf5e86ec 100644 --- a/telegram/ext/_extbot.py +++ b/telegram/ext/_extbot.py @@ -79,6 +79,7 @@ ReactionType, ReplyParameters, SentWebAppMessage, + StarAmount, StarTransactions, Sticker, StickerSet, @@ -4308,6 +4309,26 @@ async def get_business_account_gifts( api_kwargs=self._merge_api_rl_kwargs(api_kwargs, rate_limit_args), ) + async def get_business_account_star_balance( + self, + business_connection_id: str, + *, + read_timeout: ODVInput[float] = DEFAULT_NONE, + write_timeout: ODVInput[float] = DEFAULT_NONE, + connect_timeout: ODVInput[float] = DEFAULT_NONE, + pool_timeout: ODVInput[float] = DEFAULT_NONE, + api_kwargs: Optional[JSONDict] = None, + rate_limit_args: Optional[RLARGS] = None, + ) -> StarAmount: + return await super().get_business_account_star_balance( + business_connection_id=business_connection_id, + read_timeout=read_timeout, + write_timeout=write_timeout, + connect_timeout=connect_timeout, + pool_timeout=pool_timeout, + api_kwargs=self._merge_api_rl_kwargs(api_kwargs, rate_limit_args), + ) + async def read_business_message( self, business_connection_id: str, @@ -5107,6 +5128,7 @@ async def remove_user_verification( setMessageReaction = set_message_reaction getBusinessConnection = get_business_connection getBusinessAccountGifts = get_business_account_gifts + getBusinessAccountStarBalance = get_business_account_star_balance readBusinessMessage = read_business_message deleteBusinessMessages = delete_business_messages postStory = post_story diff --git a/tests/_payment/stars/test_staramount.py b/tests/_payment/stars/test_staramount.py new file mode 100644 index 00000000000..f0438910b00 --- /dev/null +++ b/tests/_payment/stars/test_staramount.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +# +# A library that provides a Python interface to the Telegram Bot API +# Copyright (C) 2015-2025 +# Leandro Toledo de Souza +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser Public License for more details. +# +# You should have received a copy of the GNU Lesser Public License +# along with this program. If not, see [http://www.gnu.org/licenses/]. + +import pytest + +from telegram import StarAmount +from tests.auxil.slots import mro_slots + + +@pytest.fixture(scope="module") +def star_amount(): + return StarAmount( + amount=StarTransactionTestBase.amount, + nanostar_amount=StarTransactionTestBase.nanostar_amount, + ) + + +class StarTransactionTestBase: + amount = 100 + nanostar_amount = 356 + + +class TestStarAmountWithoutRequest(StarTransactionTestBase): + def test_slot_behaviour(self, star_amount): + inst = star_amount + for attr in inst.__slots__: + assert getattr(inst, attr, "err") != "err", f"got extra slot '{attr}'" + assert len(mro_slots(inst)) == len(set(mro_slots(inst))), "duplicate slot" + + def test_de_json(self, offline_bot): + json_dict = { + "amount": self.amount, + "nanostar_amount": self.nanostar_amount, + } + st = StarAmount.de_json(json_dict, offline_bot) + assert st.api_kwargs == {} + assert st.amount == self.amount + assert st.nanostar_amount == self.nanostar_amount + + def test_to_dict(self, star_amount): + expected_dict = { + "amount": self.amount, + "nanostar_amount": self.nanostar_amount, + } + assert star_amount.to_dict() == expected_dict + + def test_equality(self, star_amount): + a = star_amount + b = StarAmount(amount=self.amount, nanostar_amount=self.nanostar_amount) + c = StarAmount(amount=99, nanostar_amount=99) + + assert a == b + assert hash(a) == hash(b) + + assert a != c + assert hash(a) != hash(c) diff --git a/tests/auxil/dummy_objects.py b/tests/auxil/dummy_objects.py index 8d4be51b476..9abce52fa23 100644 --- a/tests/auxil/dummy_objects.py +++ b/tests/auxil/dummy_objects.py @@ -29,6 +29,7 @@ PollOption, PreparedInlineMessage, SentWebAppMessage, + StarAmount, StarTransaction, StarTransactions, Sticker, @@ -126,6 +127,7 @@ ), "PreparedInlineMessage": PreparedInlineMessage(id="dummy_id", expiration_date=_DUMMY_DATE), "SentWebAppMessage": SentWebAppMessage(inline_message_id="dummy_inline_message_id"), + "StarAmount": StarAmount(amount=100, nanostar_amount=356), "StarTransactions": StarTransactions( transactions=[StarTransaction(id="dummy_id", amount=1, date=_DUMMY_DATE)] ), diff --git a/tests/test_business_methods.py b/tests/test_business_methods.py index a4ee470dbb8..3ff2f82db14 100644 --- a/tests/test_business_methods.py +++ b/tests/test_business_methods.py @@ -26,6 +26,7 @@ InputProfilePhotoStatic, InputStoryContentPhoto, MessageEntity, + StarAmount, Story, StoryAreaTypeLink, StoryAreaTypeUniqueGift, @@ -115,6 +116,20 @@ async def do_request_and_make_assertions(*args, **kwargs): ) assert isinstance(obj, OwnedGifts) + async def test_get_business_account_star_balance(self, offline_bot, monkeypatch): + star_amount_json = StarAmount(amount=100, nanostar_amount=356).to_json() + + async def do_request(*args, **kwargs): + data = kwargs.get("request_data") + obj = data.parameters.get("business_connection_id") + if obj == self.bci: + return 200, f'{{"ok": true, "result": {star_amount_json}}}'.encode() + return 400, b'{"ok": false, "result": []}' + + monkeypatch.setattr(offline_bot.request, "do_request", do_request) + obj = await offline_bot.get_business_account_star_balance(business_connection_id=self.bci) + assert isinstance(obj, StarAmount) + async def test_read_business_message(self, offline_bot, monkeypatch): chat_id = 43 message_id = 44 From 7debcdc6f0557058fcc07e858d8f63f4c19af66c Mon Sep 17 00:00:00 2001 From: aelkheir <90580077+aelkheir@users.noreply.github.com> Date: Thu, 1 May 2025 09:54:19 +0300 Subject: [PATCH 2/6] Add method `transferBusinessAccountStars`. Business Accounts - Added the method transferBusinessAccountStars, allowing bots to transfer Telegram Stars from the balance of a managed business account to their own balance for withdrawal. --- docs/source/inclusions/bot_methods.rst | 2 ++ telegram/_bot.py | 46 ++++++++++++++++++++++++++ telegram/constants.py | 10 ++++++ telegram/ext/_extbot.py | 23 +++++++++++++ tests/test_business_methods.py | 16 +++++++++ 5 files changed, 97 insertions(+) diff --git a/docs/source/inclusions/bot_methods.rst b/docs/source/inclusions/bot_methods.rst index 32f85d5171b..eeb3d65955a 100644 --- a/docs/source/inclusions/bot_methods.rst +++ b/docs/source/inclusions/bot_methods.rst @@ -443,6 +443,8 @@ - Used for upgrading owned regular gifts to unique ones. * - :meth:`~telegram.Bot.transfer_gift` - Used for transferring owned unique gifts to another user. + * - :meth:`~telegram.Bot.transfer_business_account_stars` + - Used for transfering Stars from the business account balance to the bot's balance. .. raw:: html diff --git a/telegram/_bot.py b/telegram/_bot.py index 7ba151357ec..62a466cc4b7 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -10257,6 +10257,50 @@ async def transfer_gift( api_kwargs=api_kwargs, ) + async def transfer_business_account_stars( + self, + business_connection_id: str, + star_count: int, + *, + read_timeout: ODVInput[float] = DEFAULT_NONE, + write_timeout: ODVInput[float] = DEFAULT_NONE, + connect_timeout: ODVInput[float] = DEFAULT_NONE, + pool_timeout: ODVInput[float] = DEFAULT_NONE, + api_kwargs: Optional[JSONDict] = None, + ) -> bool: + """ + Transfers Telegram Stars from the business account balance to the bot's balance. Requires + the :attr:`~telegram.BusinessBotRights.can_transfer_stars` business bot right. + + .. versionadded:: NEXT.VERSION + + Args: + business_connection_id (:obj:`str`): Unique identifier of the business + connection + star_count (:obj:`int`): Number of Telegram Stars to transfer; + :tg-const:`~telegram.constants.BusinessLimit.MIN_STAR_COUNT`\ +-:tg-const:`~telegram.constants.BusinessLimit.MAX_STAR_COUNT` + + Returns: + :obj:`bool`: On success, :obj:`True` is returned. + + Raises: + :class:`telegram.error.TelegramError` + """ + data: JSONDict = { + "business_connection_id": business_connection_id, + "star_count": star_count, + } + return await self._post( + "transferBusinessAccountStars", + data, + read_timeout=read_timeout, + write_timeout=write_timeout, + connect_timeout=connect_timeout, + pool_timeout=pool_timeout, + api_kwargs=api_kwargs, + ) + async def replace_sticker_in_set( self, user_id: int, @@ -11226,6 +11270,8 @@ def to_dict(self, recursive: bool = True) -> JSONDict: # noqa: ARG002 """Alias for :meth:`upgrade_gift`""" transferGift = transfer_gift """Alias for :meth:`transfer_gift`""" + transferBusinessAccountStars = transfer_business_account_stars + """Alias for :meth:`transfer_business_account_stars`""" replaceStickerInSet = replace_sticker_in_set """Alias for :meth:`replace_sticker_in_set`""" refundStarPayment = refund_star_payment diff --git a/telegram/constants.py b/telegram/constants.py index 264959a7924..45009b1b38a 100644 --- a/telegram/constants.py +++ b/telegram/constants.py @@ -759,6 +759,16 @@ class BusinessLimit(IntEnum): :paramref:`~telegram.Bot.get_business_account_gifts.limit` of :meth:`telegram.Bot.get_business_account_gifts`. """ + MIN_STAR_COUNT = 1 + """:obj:`int`: Minimum number of Telegram Stars to be transfered. Relevant for + :paramref:`~telegram.Bot.transfer_business_account_stars.star_count` of + :meth:`telegram.Bot.transfer_business_account_stars`. + """ + MAX_STAR_COUNT = 10000 + """:obj:`int`: Maximum number of Telegram Stars to be transfered. Relevant for + :paramref:`~telegram.Bot.transfer_business_account_stars.star_count` of + :meth:`telegram.Bot.transfer_business_account_stars`. + """ class CallbackQueryLimit(IntEnum): diff --git a/telegram/ext/_extbot.py b/telegram/ext/_extbot.py index 095cf5e86ec..fd3eb41285b 100644 --- a/telegram/ext/_extbot.py +++ b/telegram/ext/_extbot.py @@ -4677,6 +4677,28 @@ async def transfer_gift( api_kwargs=self._merge_api_rl_kwargs(api_kwargs, rate_limit_args), ) + async def transfer_business_account_stars( + self, + business_connection_id: str, + star_count: int, + *, + read_timeout: ODVInput[float] = DEFAULT_NONE, + write_timeout: ODVInput[float] = DEFAULT_NONE, + connect_timeout: ODVInput[float] = DEFAULT_NONE, + pool_timeout: ODVInput[float] = DEFAULT_NONE, + api_kwargs: Optional[JSONDict] = None, + rate_limit_args: Optional[RLARGS] = None, + ) -> bool: + return await super().transfer_business_account_stars( + business_connection_id=business_connection_id, + star_count=star_count, + read_timeout=read_timeout, + write_timeout=write_timeout, + connect_timeout=connect_timeout, + pool_timeout=pool_timeout, + api_kwargs=self._merge_api_rl_kwargs(api_kwargs, rate_limit_args), + ) + async def replace_sticker_in_set( self, user_id: int, @@ -5143,6 +5165,7 @@ async def remove_user_verification( convertGiftToStars = convert_gift_to_stars upgradeGift = upgrade_gift transferGift = transfer_gift + transferBusinessAccountStars = transfer_business_account_stars replaceStickerInSet = replace_sticker_in_set refundStarPayment = refund_star_payment getStarTransactions = get_star_transactions diff --git a/tests/test_business_methods.py b/tests/test_business_methods.py index 3ff2f82db14..13017eca8e6 100644 --- a/tests/test_business_methods.py +++ b/tests/test_business_methods.py @@ -277,6 +277,22 @@ async def make_assertion(*args, **kwargs): star_count=star_count, ) + async def test_transfer_business_account_stars(self, offline_bot, monkeypatch): + star_count = 100 + + async def make_assertion(*args, **kwargs): + data = kwargs.get("request_data").parameters + assert data.get("business_connection_id") == self.bci + assert data.get("star_count") == star_count + + return True + + monkeypatch.setattr(offline_bot.request, "post", make_assertion) + assert await offline_bot.transfer_business_account_stars( + business_connection_id=self.bci, + star_count=star_count, + ) + @pytest.mark.parametrize("is_public", [True, False, None, DEFAULT_NONE]) async def test_set_business_account_profile_photo(self, offline_bot, monkeypatch, is_public): async def make_assertion(*args, **kwargs): From 116999fd02af04608420df0472b5fb1b568719c5 Mon Sep 17 00:00:00 2001 From: aelkheir <90580077+aelkheir@users.noreply.github.com> Date: Thu, 1 May 2025 07:05:24 +0000 Subject: [PATCH 3/6] Add chango fragment for PR #4773 --- changes/unreleased/4773.9KvDEBkqLc9MszBRTGoXbj.toml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changes/unreleased/4773.9KvDEBkqLc9MszBRTGoXbj.toml diff --git a/changes/unreleased/4773.9KvDEBkqLc9MszBRTGoXbj.toml b/changes/unreleased/4773.9KvDEBkqLc9MszBRTGoXbj.toml new file mode 100644 index 00000000000..1da75ad36e7 --- /dev/null +++ b/changes/unreleased/4773.9KvDEBkqLc9MszBRTGoXbj.toml @@ -0,0 +1,5 @@ +other = "Api 9.0 business stars" +[[pull_requests]] +uid = "4773" +author_uid = "aelkheir" +closes_threads = [] From 2905654f8e52d7871de96216ce9b33b2aaa599d7 Mon Sep 17 00:00:00 2001 From: aelkheir <90580077+aelkheir@users.noreply.github.com> Date: Thu, 1 May 2025 10:09:48 +0300 Subject: [PATCH 4/6] Update master chango fragment for PR and delete local. --- changes/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml | 4 ++++ changes/unreleased/4773.9KvDEBkqLc9MszBRTGoXbj.toml | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) delete mode 100644 changes/unreleased/4773.9KvDEBkqLc9MszBRTGoXbj.toml diff --git a/changes/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml b/changes/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml index 2e46ef55ae0..535509f081d 100644 --- a/changes/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml +++ b/changes/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml @@ -22,3 +22,7 @@ author_uid = "Bibo-Joshi" uid = "4769" author_uid = "aelkheir" closes_threads = [] +[[pull_requests]] +uid = "4773" +author_uid = "aelkheir" +closes_threads = [] diff --git a/changes/unreleased/4773.9KvDEBkqLc9MszBRTGoXbj.toml b/changes/unreleased/4773.9KvDEBkqLc9MszBRTGoXbj.toml deleted file mode 100644 index 1da75ad36e7..00000000000 --- a/changes/unreleased/4773.9KvDEBkqLc9MszBRTGoXbj.toml +++ /dev/null @@ -1,5 +0,0 @@ -other = "Api 9.0 business stars" -[[pull_requests]] -uid = "4773" -author_uid = "aelkheir" -closes_threads = [] From 5d9309ecab9294e8af6c7461320404fb373b9478 Mon Sep 17 00:00:00 2001 From: aelkheir <90580077+aelkheir@users.noreply.github.com> Date: Fri, 2 May 2025 07:43:51 +0300 Subject: [PATCH 5/6] Merge `nanostar_amuont` constants into one enum class. --- telegram/_payment/stars/affiliateinfo.py | 12 +-- telegram/_payment/stars/staramount.py | 16 +-- telegram/_payment/stars/startransactions.py | 8 +- telegram/constants.py | 109 +++++++++++++------- 4 files changed, 87 insertions(+), 58 deletions(-) diff --git a/telegram/_payment/stars/affiliateinfo.py b/telegram/_payment/stars/affiliateinfo.py index 80349290b44..86a5ad906a5 100644 --- a/telegram/_payment/stars/affiliateinfo.py +++ b/telegram/_payment/stars/affiliateinfo.py @@ -48,10 +48,10 @@ class AffiliateInfo(TelegramObject): amount (:obj:`int`): Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds nanostar_amount (:obj:`int`, optional): The number of - :tg-const:`~telegram.constants.StarTransactions.NANOSTAR_VALUE` shares of Telegram + :tg-const:`~telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram Stars received by the affiliate; from - :tg-const:`~telegram.constants.StarTransactionsLimit.NANOSTAR_MIN_AMOUNT` to - :tg-const:`~telegram.constants.StarTransactionsLimit.NANOSTAR_MAX_AMOUNT`; + :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MIN_AMOUNT` to + :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT`; can be negative for refunds Attributes: @@ -64,10 +64,10 @@ class AffiliateInfo(TelegramObject): amount (:obj:`int`): Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds nanostar_amount (:obj:`int`): Optional. The number of - :tg-const:`~telegram.constants.StarTransactions.NANOSTAR_VALUE` shares of Telegram + :tg-const:`~telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram Stars received by the affiliate; from - :tg-const:`~telegram.constants.StarTransactionsLimit.NANOSTAR_MIN_AMOUNT` to - :tg-const:`~telegram.constants.StarTransactionsLimit.NANOSTAR_MAX_AMOUNT`; + :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MIN_AMOUNT` to + :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT`; can be negative for refunds """ diff --git a/telegram/_payment/stars/staramount.py b/telegram/_payment/stars/staramount.py index 9543210c21d..9d320656ae1 100644 --- a/telegram/_payment/stars/staramount.py +++ b/telegram/_payment/stars/staramount.py @@ -35,18 +35,18 @@ class StarAmount(TelegramObject): Args: amount (:obj:`int`): Integer amount of Telegram Stars, rounded to ``0``; can be negative. nanostar_amount (:obj:`int`, optional): The number of - :tg-const:`telegram.constants.StarAmount.NANOSTAR_VALUE` shares of Telegram - Stars; from :tg-const:`telegram.constants.StarAmountLimit.NANOSTAR_MIN_AMOUNT` - to :tg-const:`telegram.constants.StarAmountLimit.NANOSTAR_MAX_AMOUNT`; can be negative - if and only if :attr:`amount` is non-positive. + :tg-const:`telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram + Stars; from :tg-const:`telegram.constants.NanostarAmountLimit.NANOSTAR_MIN_AMOUNT` + to :tg-const:`telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT`; can be + negative if and only if :attr:`amount` is non-positive. Attributes: amount (:obj:`int`): Integer amount of Telegram Stars, rounded to ``0``; can be negative. nanostar_amount (:obj:`int`): Optional. The number of - :tg-const:`telegram.constants.StarAmount.NANOSTAR_VALUE` shares of Telegram - Stars; from :tg-const:`telegram.constants.StarAmountLimit.NANOSTAR_MIN_AMOUNT` - to :tg-const:`telegram.constants.StarAmountLimit.NANOSTAR_MAX_AMOUNT`; can be negative - if and only if :attr:`amount` is non-positive. + :tg-const:`telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram + Stars; from :tg-const:`telegram.constants.NanostarAmountLimit.NANOSTAR_MIN_AMOUNT` + to :tg-const:`telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT`; can be + negative if and only if :attr:`amount` is non-positive. """ diff --git a/telegram/_payment/stars/startransactions.py b/telegram/_payment/stars/startransactions.py index 7ac1ef7e338..23a91a2df2d 100644 --- a/telegram/_payment/stars/startransactions.py +++ b/telegram/_payment/stars/startransactions.py @@ -52,9 +52,9 @@ class StarTransaction(TelegramObject): successful incoming payments from users. amount (:obj:`int`): Integer amount of Telegram Stars transferred by the transaction. nanostar_amount (:obj:`int`, optional): The number of - :tg-const:`~telegram.constants.StarTransactions.NANOSTAR_VALUE` shares of Telegram + :tg-const:`~telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram Stars transferred by the transaction; from 0 to - :tg-const:`~telegram.constants.StarTransactionsLimit.NANOSTAR_MAX_AMOUNT` + :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT` .. versionadded:: 21.9 date (:obj:`datetime.datetime`): Date the transaction was created as a datetime object. @@ -72,9 +72,9 @@ class StarTransaction(TelegramObject): successful incoming payments from users. amount (:obj:`int`): Integer amount of Telegram Stars transferred by the transaction. nanostar_amount (:obj:`int`): Optional. The number of - :tg-const:`~telegram.constants.StarTransactions.NANOSTAR_VALUE` shares of Telegram + :tg-const:`~telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram Stars transferred by the transaction; from 0 to - :tg-const:`~telegram.constants.StarTransactionsLimit.NANOSTAR_MAX_AMOUNT` + :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT` .. versionadded:: 21.9 date (:obj:`datetime.datetime`): Date the transaction was created as a datetime object. diff --git a/telegram/constants.py b/telegram/constants.py index 45009b1b38a..68d2c615706 100644 --- a/telegram/constants.py +++ b/telegram/constants.py @@ -89,6 +89,8 @@ "MessageLimit", "MessageOriginType", "MessageType", + "NanostarAmount", + "NanostarAmountLimit", "OwnedGiftType", "PaidMediaType", "ParseMode", @@ -100,8 +102,6 @@ "ReactionType", "ReplyLimit", "RevenueWithdrawalStateType", - "StarAmount", - "StarAmountLimit", "StarTransactions", "StarTransactionsLimit", "StickerFormat", @@ -2221,6 +2221,54 @@ class MessageType(StringEnum): """ +class NanostarAmount(FloatEnum): + """This enum contains constants for ``nanostar_amount`` parameter of + :class:`telegram.StarAmount`, :class:`telegram.StarTransaction` + and :class:`telegram.AffiliateInfo`. + The enum members of this enumeration are instances of :class:`float` and can be treated as + such. + + .. versionadded:: NEXT.VERSION + """ + + __slots__ = () + + NANOSTAR_VALUE = 1 / 1000000000 + """:obj:`float`: The value of one nanostar as used in + :paramref:`telegram.StarTransaction.nanostar_amount` + parameter of :class:`telegram.StarTransaction`, + :paramref:`telegram.StarAmount.nanostar_amount` parameter of :class:`telegram.StarAmount` + and :paramref:`telegram.AffiliateInfo.nanostar_amount` + parameter of :class:`telegram.AffiliateInfo` + """ + + +class NanostarAmountLimit(IntEnum): + """This enum contains limitations for ``nanostar_amount`` parameter of + :class:`telegram.AffiliateInfo`, :class:`telegram.StarTransaction` + and :class:`telegram.StarAmount`. + The enum members of this enumeration are instances of :class:`int` and can be treated as such. + + .. versionadded:: NEXT.VERSION + """ + + __slots__ = () + + NANOSTAR_MIN_AMOUNT = -999999999 + """:obj:`int`: Minimum value allowed for :paramref:`~telegram.AffiliateInfo.nanostar_amount` + parameter of :class:`telegram.AffiliateInfo` + and :paramref:`~telegram.StarAmount.nanostar_amount` + parameter of :class:`telegram.StarAmount`. + """ + NANOSTAR_MAX_AMOUNT = 999999999 + """:obj:`int`: Maximum value allowed for :paramref:`~telegram.StarTransaction.nanostar_amount` + parameter of :class:`telegram.StarTransaction`, + :paramref:`~telegram.AffiliateInfo.nanostar_amount` parameter of + :class:`telegram.AffiliateInfo` and :paramref:`~telegram.StarAmount.nanostar_amount` + parameter of :class:`telegram.StarAmount`. + """ + + class OwnedGiftType(StringEnum): """This enum contains the available types of :class:`telegram.OwnedGift`. The enum members of this enumeration are instances of :class:`str` and can be treated as such. @@ -2626,54 +2674,27 @@ class RevenueWithdrawalStateType(StringEnum): """:obj:`str`: A withdrawal failed and the transaction was refunded.""" -class StarAmount(FloatEnum): - """This enum contains constants for :class:`telegram.StarAmount`. - The enum members of this enumeration are instances of :class:`float` and can be treated as - such. - - .. versionadded:: NEXT.VERSION - """ - - __slots__ = () - - NANOSTAR_VALUE = 1 / 1000000000 - """:obj:`float`: The value of one nanostar as used in - :attr:`telegram.StarAmount.nanostar_amount`. - """ - - -class StarAmountLimit(IntEnum): - """This enum contains limitations for :class:`telegram.StarAmount`. - The enum members of this enumeration are instances of :class:`int` and can be treated as such. - - .. versionadded:: NEXT.VERSION - """ - - __slots__ = () - - NANOSTAR_MIN_AMOUNT = -999999999 - """:obj:`int`: Minimum value allowed for :paramref:`~telegram.StarAmount.nanostar_amount` - parameter of :class:`telegram.StarAmount`. - """ - NANOSTAR_MAX_AMOUNT = 999999999 - """:obj:`int`: Maximum value allowed for :paramref:`~telegram.StarAmount.nanostar_amount` - parameter of :class:`telegram.StarAmount`. - """ - - +# tags: deprecated NEXT.VERSION, bot api 9.0 class StarTransactions(FloatEnum): """This enum contains constants for :class:`telegram.StarTransaction`. The enum members of this enumeration are instances of :class:`float` and can be treated as such. .. versionadded:: 21.9 + + .. deprecated:: NEXT.VERSION + This class will be removed as its only member :attr:`NANOSTAR_VALUE` will be moved + to :class:`telegram.constants.NanostarAmount` """ __slots__ = () - NANOSTAR_VALUE = 1 / 1000000000 + NANOSTAR_VALUE = NanostarAmount.NANOSTAR_VALUE """:obj:`float`: The value of one nanostar as used in :attr:`telegram.StarTransaction.nanostar_amount`. + + .. deprecated:: NEXT.VERSION + This member will be moved to :class:`telegram.constants.NanostarAmount` """ @@ -2695,19 +2716,27 @@ class StarTransactionsLimit(IntEnum): """:obj:`int`: Maximum value allowed for the :paramref:`~telegram.Bot.get_star_transactions.limit` parameter of :meth:`telegram.Bot.get_star_transactions`.""" - NANOSTAR_MIN_AMOUNT = -999999999 + # tags: deprecated NEXT.VERSION, bot api 9.0 + NANOSTAR_MIN_AMOUNT = NanostarAmountLimit.NANOSTAR_MIN_AMOUNT """:obj:`int`: Minimum value allowed for :paramref:`~telegram.AffiliateInfo.nanostar_amount` parameter of :class:`telegram.AffiliateInfo`. .. versionadded:: 21.9 + + .. deprecated:: NEXT.VERSION + This member will be moved to :class:`telegram.constants.NanostarAmountLimit` """ - NANOSTAR_MAX_AMOUNT = 999999999 + # tags: deprecated NEXT.VERSION, bot api 9.0 + NANOSTAR_MAX_AMOUNT = NanostarAmountLimit.NANOSTAR_MAX_AMOUNT """:obj:`int`: Maximum value allowed for :paramref:`~telegram.StarTransaction.nanostar_amount` parameter of :class:`telegram.StarTransaction` and :paramref:`~telegram.AffiliateInfo.nanostar_amount` parameter of :class:`telegram.AffiliateInfo`. .. versionadded:: 21.9 + + .. deprecated:: NEXT.VERSION + This member will be moved to :class:`telegram.constants.NanostarAmountLimit` """ From cab81f8db1d8f8b9810278c85f1998496e61282b Mon Sep 17 00:00:00 2001 From: aelkheir <90580077+aelkheir@users.noreply.github.com> Date: Sat, 3 May 2025 23:09:36 +0300 Subject: [PATCH 6/6] Address code review comments. --- .../4756.JT5nmUmGRG6qDEh5ScMn5f.toml | 6 ++++ telegram/_payment/stars/affiliateinfo.py | 12 ++++---- telegram/_payment/stars/staramount.py | 12 ++++---- telegram/_payment/stars/startransactions.py | 8 ++--- telegram/constants.py | 30 +++++++++---------- 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/changes/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml b/changes/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml index 535509f081d..a0f3bc0eeac 100644 --- a/changes/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml +++ b/changes/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml @@ -1,4 +1,10 @@ features = "Full Support for Bot API 9.0" +deprecations = """This release comes with several deprecations, in line with our :ref:`stability policy `. +This includes the following: + +- Deprecated ``telegram.constants.StarTransactionsLimit.NANOSTAR_MIN_AMOUNT`` and ``telegram.constants.StarTransactionsLimit.NANOSTAR_MAX_AMOUNT``. These members will be replaced by ``telegram.constants.NanostarLimit.MIN_AMOUNT`` and ``telegram.constants.NanostarLimit.MAX_AMOUNT``. +- Deprecated the class ``telegram.constants.StarTransactions``. Its only member ``telegram.constants.StarTransactions.NANOSTAR_VALUE`` will be replaced by ``telegram.constants.Nanostar.VALUE``. +""" [[pull_requests]] uid = "4756" author_uid = "Bibo-Joshi" diff --git a/telegram/_payment/stars/affiliateinfo.py b/telegram/_payment/stars/affiliateinfo.py index 86a5ad906a5..64fd7224e23 100644 --- a/telegram/_payment/stars/affiliateinfo.py +++ b/telegram/_payment/stars/affiliateinfo.py @@ -48,10 +48,10 @@ class AffiliateInfo(TelegramObject): amount (:obj:`int`): Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds nanostar_amount (:obj:`int`, optional): The number of - :tg-const:`~telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram + :tg-const:`~telegram.constants.Nanostar.VALUE` shares of Telegram Stars received by the affiliate; from - :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MIN_AMOUNT` to - :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT`; + :tg-const:`~telegram.constants.NanostarLimit.MIN_AMOUNT` to + :tg-const:`~telegram.constants.NanostarLimit.MAX_AMOUNT`; can be negative for refunds Attributes: @@ -64,10 +64,10 @@ class AffiliateInfo(TelegramObject): amount (:obj:`int`): Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds nanostar_amount (:obj:`int`): Optional. The number of - :tg-const:`~telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram + :tg-const:`~telegram.constants.Nanostar.VALUE` shares of Telegram Stars received by the affiliate; from - :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MIN_AMOUNT` to - :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT`; + :tg-const:`~telegram.constants.NanostarLimit.MIN_AMOUNT` to + :tg-const:`~telegram.constants.NanostarLimit.MAX_AMOUNT`; can be negative for refunds """ diff --git a/telegram/_payment/stars/staramount.py b/telegram/_payment/stars/staramount.py index 9d320656ae1..a8d61b2a118 100644 --- a/telegram/_payment/stars/staramount.py +++ b/telegram/_payment/stars/staramount.py @@ -35,17 +35,17 @@ class StarAmount(TelegramObject): Args: amount (:obj:`int`): Integer amount of Telegram Stars, rounded to ``0``; can be negative. nanostar_amount (:obj:`int`, optional): The number of - :tg-const:`telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram - Stars; from :tg-const:`telegram.constants.NanostarAmountLimit.NANOSTAR_MIN_AMOUNT` - to :tg-const:`telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT`; can be + :tg-const:`telegram.constants.Nanostar.VALUE` shares of Telegram + Stars; from :tg-const:`telegram.constants.NanostarLimit.MIN_AMOUNT` + to :tg-const:`telegram.constants.NanostarLimit.MAX_AMOUNT`; can be negative if and only if :attr:`amount` is non-positive. Attributes: amount (:obj:`int`): Integer amount of Telegram Stars, rounded to ``0``; can be negative. nanostar_amount (:obj:`int`): Optional. The number of - :tg-const:`telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram - Stars; from :tg-const:`telegram.constants.NanostarAmountLimit.NANOSTAR_MIN_AMOUNT` - to :tg-const:`telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT`; can be + :tg-const:`telegram.constants.Nanostar.VALUE` shares of Telegram + Stars; from :tg-const:`telegram.constants.NanostarLimit.MIN_AMOUNT` + to :tg-const:`telegram.constants.NanostarLimit.MAX_AMOUNT`; can be negative if and only if :attr:`amount` is non-positive. """ diff --git a/telegram/_payment/stars/startransactions.py b/telegram/_payment/stars/startransactions.py index 23a91a2df2d..09f314985ff 100644 --- a/telegram/_payment/stars/startransactions.py +++ b/telegram/_payment/stars/startransactions.py @@ -52,9 +52,9 @@ class StarTransaction(TelegramObject): successful incoming payments from users. amount (:obj:`int`): Integer amount of Telegram Stars transferred by the transaction. nanostar_amount (:obj:`int`, optional): The number of - :tg-const:`~telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram + :tg-const:`~telegram.constants.Nanostar.VALUE` shares of Telegram Stars transferred by the transaction; from 0 to - :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT` + :tg-const:`~telegram.constants.NanostarLimit.MAX_AMOUNT` .. versionadded:: 21.9 date (:obj:`datetime.datetime`): Date the transaction was created as a datetime object. @@ -72,9 +72,9 @@ class StarTransaction(TelegramObject): successful incoming payments from users. amount (:obj:`int`): Integer amount of Telegram Stars transferred by the transaction. nanostar_amount (:obj:`int`): Optional. The number of - :tg-const:`~telegram.constants.NanostarAmount.NANOSTAR_VALUE` shares of Telegram + :tg-const:`~telegram.constants.Nanostar.VALUE` shares of Telegram Stars transferred by the transaction; from 0 to - :tg-const:`~telegram.constants.NanostarAmountLimit.NANOSTAR_MAX_AMOUNT` + :tg-const:`~telegram.constants.NanostarLimit.MAX_AMOUNT` .. versionadded:: 21.9 date (:obj:`datetime.datetime`): Date the transaction was created as a datetime object. diff --git a/telegram/constants.py b/telegram/constants.py index 68d2c615706..4e3ac0ab144 100644 --- a/telegram/constants.py +++ b/telegram/constants.py @@ -89,8 +89,8 @@ "MessageLimit", "MessageOriginType", "MessageType", - "NanostarAmount", - "NanostarAmountLimit", + "Nanostar", + "NanostarLimit", "OwnedGiftType", "PaidMediaType", "ParseMode", @@ -2221,7 +2221,7 @@ class MessageType(StringEnum): """ -class NanostarAmount(FloatEnum): +class Nanostar(FloatEnum): """This enum contains constants for ``nanostar_amount`` parameter of :class:`telegram.StarAmount`, :class:`telegram.StarTransaction` and :class:`telegram.AffiliateInfo`. @@ -2233,7 +2233,7 @@ class NanostarAmount(FloatEnum): __slots__ = () - NANOSTAR_VALUE = 1 / 1000000000 + VALUE = 1 / 1000000000 """:obj:`float`: The value of one nanostar as used in :paramref:`telegram.StarTransaction.nanostar_amount` parameter of :class:`telegram.StarTransaction`, @@ -2243,7 +2243,7 @@ class NanostarAmount(FloatEnum): """ -class NanostarAmountLimit(IntEnum): +class NanostarLimit(IntEnum): """This enum contains limitations for ``nanostar_amount`` parameter of :class:`telegram.AffiliateInfo`, :class:`telegram.StarTransaction` and :class:`telegram.StarAmount`. @@ -2254,13 +2254,13 @@ class NanostarAmountLimit(IntEnum): __slots__ = () - NANOSTAR_MIN_AMOUNT = -999999999 + MIN_AMOUNT = -999999999 """:obj:`int`: Minimum value allowed for :paramref:`~telegram.AffiliateInfo.nanostar_amount` parameter of :class:`telegram.AffiliateInfo` and :paramref:`~telegram.StarAmount.nanostar_amount` parameter of :class:`telegram.StarAmount`. """ - NANOSTAR_MAX_AMOUNT = 999999999 + MAX_AMOUNT = 999999999 """:obj:`int`: Maximum value allowed for :paramref:`~telegram.StarTransaction.nanostar_amount` parameter of :class:`telegram.StarTransaction`, :paramref:`~telegram.AffiliateInfo.nanostar_amount` parameter of @@ -2683,18 +2683,18 @@ class StarTransactions(FloatEnum): .. versionadded:: 21.9 .. deprecated:: NEXT.VERSION - This class will be removed as its only member :attr:`NANOSTAR_VALUE` will be moved - to :class:`telegram.constants.NanostarAmount` + This class will be removed as its only member :attr:`NANOSTAR_VALUE` will be replaced + by :attr:`telegram.constants.Nanostar.VALUE`. """ __slots__ = () - NANOSTAR_VALUE = NanostarAmount.NANOSTAR_VALUE + NANOSTAR_VALUE = Nanostar.VALUE """:obj:`float`: The value of one nanostar as used in :attr:`telegram.StarTransaction.nanostar_amount`. .. deprecated:: NEXT.VERSION - This member will be moved to :class:`telegram.constants.NanostarAmount` + This member will be replaced by :attr:`telegram.constants.Nanostar.VALUE`. """ @@ -2717,17 +2717,17 @@ class StarTransactionsLimit(IntEnum): :paramref:`~telegram.Bot.get_star_transactions.limit` parameter of :meth:`telegram.Bot.get_star_transactions`.""" # tags: deprecated NEXT.VERSION, bot api 9.0 - NANOSTAR_MIN_AMOUNT = NanostarAmountLimit.NANOSTAR_MIN_AMOUNT + NANOSTAR_MIN_AMOUNT = NanostarLimit.MIN_AMOUNT """:obj:`int`: Minimum value allowed for :paramref:`~telegram.AffiliateInfo.nanostar_amount` parameter of :class:`telegram.AffiliateInfo`. .. versionadded:: 21.9 .. deprecated:: NEXT.VERSION - This member will be moved to :class:`telegram.constants.NanostarAmountLimit` + This member will be replaced by :attr:`telegram.constants.NanostarLimit.MIN_AMOUNT`. """ # tags: deprecated NEXT.VERSION, bot api 9.0 - NANOSTAR_MAX_AMOUNT = NanostarAmountLimit.NANOSTAR_MAX_AMOUNT + NANOSTAR_MAX_AMOUNT = NanostarLimit.MAX_AMOUNT """:obj:`int`: Maximum value allowed for :paramref:`~telegram.StarTransaction.nanostar_amount` parameter of :class:`telegram.StarTransaction` and :paramref:`~telegram.AffiliateInfo.nanostar_amount` parameter of @@ -2736,7 +2736,7 @@ class StarTransactionsLimit(IntEnum): .. versionadded:: 21.9 .. deprecated:: NEXT.VERSION - This member will be moved to :class:`telegram.constants.NanostarAmountLimit` + This member will be replaced by :attr:`telegram.constants.NanostarLimit.MAX_AMOUNT`. """