From b1cc59e8a2262a5af92fda9445c9a2fccad3c2d5 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Sun, 8 Sep 2024 15:14:20 +0200 Subject: [PATCH 1/2] Add changes from core.telegram.org/bots/api --- telegram/_bot.py | 3 +- telegram/_giveaway.py | 6 +- telegram/constants.py | 124 +++++++++++++++++++++++------------------- 3 files changed, 75 insertions(+), 58 deletions(-) diff --git a/telegram/_bot.py b/telegram/_bot.py index b79df08ff17..8e4e87a6ac5 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -9211,7 +9211,8 @@ async def send_paid_media( Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance. star_count (:obj:`int`): The number of Telegram Stars that must be paid to buy access - to the media. + to the media; :tg-const:`telegram.constants.InvoiceLimit.MIN_STAR_COUNT` - + :tg-const:`telegram.constants.InvoiceLimit.MAX_STAR_COUNT`. media (Sequence[:class:`telegram.InputPaidMedia`]): A list describing the media to be sent; up to :tg-const:`telegram.constants.MediaGroupLimit.MAX_MEDIA_LENGTH` items. caption (:obj:`str`, optional): Caption of the media to be sent, diff --git a/telegram/_giveaway.py b/telegram/_giveaway.py index b287433fe0b..5085ff9d68c 100644 --- a/telegram/_giveaway.py +++ b/telegram/_giveaway.py @@ -57,7 +57,8 @@ class Giveaway(TelegramObject): come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways. premium_subscription_month_count (:obj:`int`, optional): The number of months the Telegram - Premium subscription won from the giveaway will be active for. + Premium subscription won from the giveaway will be active for; for Telegram Premium + giveaways only. Attributes: chats (Sequence[:class:`telegram.Chat`]): The list of chats which the user must join to @@ -76,7 +77,8 @@ class Giveaway(TelegramObject): come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways. premium_subscription_month_count (:obj:`int`): Optional. The number of months the Telegram - Premium subscription won from the giveaway will be active for. + Premium subscription won from the giveaway will be active for; for Telegram Premium + giveaways only. """ __slots__ = ( diff --git a/telegram/constants.py b/telegram/constants.py index 0f179b1a34d..4cef3b1c862 100644 --- a/telegram/constants.py +++ b/telegram/constants.py @@ -552,6 +552,42 @@ class AccentColor(Enum): """ +class BackgroundTypeType(StringEnum): + """This enum contains the available types of :class:`telegram.BackgroundType`. The enum + members of this enumeration are instances of :class:`str` and can be treated as such. + + .. versionadded:: 21.2 + """ + + __slots__ = () + + FILL = "fill" + """:obj:`str`: A :class:`telegram.BackgroundType` with fill background.""" + WALLPAPER = "wallpaper" + """:obj:`str`: A :class:`telegram.BackgroundType` with wallpaper background.""" + PATTERN = "pattern" + """:obj:`str`: A :class:`telegram.BackgroundType` with pattern background.""" + CHAT_THEME = "chat_theme" + """:obj:`str`: A :class:`telegram.BackgroundType` with chat_theme background.""" + + +class BackgroundFillType(StringEnum): + """This enum contains the available types of :class:`telegram.BackgroundFill`. The enum + members of this enumeration are instances of :class:`str` and can be treated as such. + + .. versionadded:: 21.2 + """ + + __slots__ = () + + SOLID = "solid" + """:obj:`str`: A :class:`telegram.BackgroundFill` with solid fill.""" + GRADIENT = "gradient" + """:obj:`str`: A :class:`telegram.BackgroundFill` with gradient fill.""" + FREEFORM_GRADIENT = "freeform_gradient" + """:obj:`str`: A :class:`telegram.BackgroundFill` with freeform_gradient fill.""" + + class BotCommandLimit(IntEnum): """This enum contains limitations for :class:`telegram.BotCommand` and :meth:`telegram.Bot.set_my_commands`. @@ -833,6 +869,25 @@ class ChatLimit(IntEnum): """ +class ChatSubscriptionLimit(IntEnum): + """This enum contains limitations for + :paramref:`telegram.Bot.create_chat_subscription_invite_link.subscription_period` and + :paramref:`telegram.Bot.create_chat_subscription_invite_link.subscription_price`. + The enum members of this enumeration are instances of :class:`int` and can be treated as such. + + .. versionadded:: 21.5 + """ + + __slots__ = () + + SUBSCRIPTION_PERIOD = 2592000 + """:obj:`int`: The number of seconds the subscription will be active.""" + MIN_PRICE = 1 + """:obj:`int`: Amount of stars a user pays, minimum amount the subscription can be set to.""" + MAX_PRICE = 2500 + """:obj:`int`: Amount of stars a user pays, maximum amount the subscription can be set to.""" + + class BackgroundTypeLimit(IntEnum): """This enum contains limitations for :class:`telegram.BackgroundTypeFill`, :class:`telegram.BackgroundTypeWallpaper` and :class:`telegram.BackgroundTypePattern`. @@ -2804,6 +2859,20 @@ class InvoiceLimit(IntEnum): * :paramref:`~telegram.Bot.create_invoice_link.suggested_tip_amounts` parameter of :meth:`telegram.Bot.create_invoice_link`. """ + MIN_STAR_COUNT = 1 + """:obj:`int`: Minimum amount of starts that must be paid to buy access to a paid media + passed as :paramref:`~telegram.Bot.send_paid_media.star_count` parameter of + :meth:`telegram.Bot.send_paid_media`. + + .. versionadded:: NEXT.VERSION + """ + MAX_STAR_COUNT = 2500 + """:obj:`int`: Maximum amount of starts that must be paid to buy access to a paid media + passed as :paramref:`~telegram.Bot.send_paid_media.star_count` parameter of + :meth:`telegram.Bot.send_paid_media`. + + .. versionadded:: NEXT.VERSION + """ class UserProfilePhotosLimit(IntEnum): @@ -3066,58 +3135,3 @@ class ReactionEmoji(StringEnum): """:obj:`str`: Woman Shrugging""" POUTING_FACE = "😡" """:obj:`str`: Pouting face""" - - -class BackgroundTypeType(StringEnum): - """This enum contains the available types of :class:`telegram.BackgroundType`. The enum - members of this enumeration are instances of :class:`str` and can be treated as such. - - .. versionadded:: 21.2 - """ - - __slots__ = () - - FILL = "fill" - """:obj:`str`: A :class:`telegram.BackgroundType` with fill background.""" - WALLPAPER = "wallpaper" - """:obj:`str`: A :class:`telegram.BackgroundType` with wallpaper background.""" - PATTERN = "pattern" - """:obj:`str`: A :class:`telegram.BackgroundType` with pattern background.""" - CHAT_THEME = "chat_theme" - """:obj:`str`: A :class:`telegram.BackgroundType` with chat_theme background.""" - - -class BackgroundFillType(StringEnum): - """This enum contains the available types of :class:`telegram.BackgroundFill`. The enum - members of this enumeration are instances of :class:`str` and can be treated as such. - - .. versionadded:: 21.2 - """ - - __slots__ = () - - SOLID = "solid" - """:obj:`str`: A :class:`telegram.BackgroundFill` with solid fill.""" - GRADIENT = "gradient" - """:obj:`str`: A :class:`telegram.BackgroundFill` with gradient fill.""" - FREEFORM_GRADIENT = "freeform_gradient" - """:obj:`str`: A :class:`telegram.BackgroundFill` with freeform_gradient fill.""" - - -class ChatSubscriptionLimit(IntEnum): - """This enum contains limitations for - :paramref:`telegram.Bot.create_chat_subscription_invite_link.subscription_period` and - :paramref:`telegram.Bot.create_chat_subscription_invite_link.subscription_price`. - The enum members of this enumeration are instances of :class:`int` and can be treated as such. - - .. versionadded:: 21.5 - """ - - __slots__ = () - - SUBSCRIPTION_PERIOD = 2592000 - """:obj:`int`: The number of seconds the subscription will be active.""" - MIN_PRICE = 1 - """:obj:`int`: Amount of stars a user pays, minimum amount the subscription can be set to.""" - MAX_PRICE = 2500 - """:obj:`int`: Amount of stars a user pays, maximum amount the subscription can be set to.""" From cf5438fd42ed5536a3bc7358edb598c8b57bebc7 Mon Sep 17 00:00:00 2001 From: Abdelrahman Elkheir <90580077+aelkheir@users.noreply.github.com> Date: Mon, 9 Sep 2024 08:12:48 +0300 Subject: [PATCH 2/2] Correct typo in tests directory README (#4467) --- tests/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/README.rst b/tests/README.rst index 69591953bc3..c9f3cac63be 100644 --- a/tests/README.rst +++ b/tests/README.rst @@ -72,7 +72,7 @@ complete and correct. To run it, export an environment variable first: $ export TEST_OFFICIAL=true -and then run ``pytest tests/test_official.py``. Note: You need py 3.10+ to run this test. +and then run ``pytest tests/test_official/test_official.py``. Note: You need py 3.10+ to run this test. We also have another marker, ``@pytest.mark.dev``, which you can add to tests that you want to run selectively. Use as follows:
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: