Bot API 7.10 (#1570)

* Bump to the latest schema

* Added full support ob Bot API 7.10

* Add support for purchased paid media events

Enhanced the router to include `purchased_paid_media` handling. Added corresponding test cases to verify the new functionality and updated middleware to return the appropriate `EventContext`.

* Added changelog
This commit is contained in:
Alex Root Junior 2024-09-08 04:01:18 +03:00 committed by GitHub
parent fb1e5cad59
commit e8fc890809
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 487 additions and 106 deletions

View file

@ -1000,7 +1000,7 @@ class Bot:
:param title: Product name, 1-32 characters
:param description: Product description, 1-255 characters
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
:param currency: Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_. Pass 'XTR' for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param prices: Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param provider_token: Payment provider token, obtained via `@BotFather <https://t.me/botfather>`_. Pass an empty string for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
@ -2669,7 +2669,7 @@ class Bot:
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)
:param title: Product name, 1-32 characters
:param description: Product description, 1-255 characters
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
:param currency: Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_. Pass 'XTR' for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param prices: Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@ -4658,6 +4658,7 @@ class Bot:
star_count: int,
media: List[Union[InputPaidMediaPhoto, InputPaidMediaVideo]],
business_connection_id: Optional[str] = None,
payload: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = None,
caption_entities: Optional[List[MessageEntity]] = None,
@ -4676,9 +4677,10 @@ class Bot:
Source: https://core.telegram.org/bots/api#sendpaidmedia
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.
:param star_count: The number of Telegram Stars that must be paid to buy access to the media
:param star_count: The number of Telegram Stars that must be paid to buy access to the media; 1-2500
:param media: A JSON-serialized array describing the media to be sent; up to 10 items
:param business_connection_id: Unique identifier of the business connection on behalf of which the message will be sent
:param payload: Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
:param caption: Media caption, 0-1024 characters after entities parsing
:param parse_mode: Mode for parsing entities in the media caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*
@ -4696,6 +4698,7 @@ class Bot:
star_count=star_count,
media=media,
business_connection_id=business_connection_id,
payload=payload,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,

View file

@ -175,4 +175,8 @@ class UserContextMiddleware(BaseMiddleware):
),
business_connection_id=event.edited_business_message.business_connection_id,
)
if event.purchased_paid_media:
return EventContext(
user=event.purchased_paid_media.from_user,
)
return EventContext()

View file

@ -70,6 +70,9 @@ class Router:
router=self, event_name="edited_business_message"
)
self.business_message = TelegramEventObserver(router=self, event_name="business_message")
self.purchased_paid_media = TelegramEventObserver(
router=self, event_name="purchased_paid_media"
)
self.errors = self.error = TelegramEventObserver(router=self, event_name="error")
@ -99,6 +102,7 @@ class Router:
"business_connection": self.business_connection,
"edited_business_message": self.edited_business_message,
"business_message": self.business_message,
"purchased_paid_media": self.purchased_paid_media,
"error": self.errors,
}

View file

@ -23,6 +23,7 @@ class UpdateType(str, Enum):
CALLBACK_QUERY = "callback_query"
SHIPPING_QUERY = "shipping_query"
PRE_CHECKOUT_QUERY = "pre_checkout_query"
PURCHASED_PAID_MEDIA = "purchased_paid_media"
POLL = "poll"
POLL_ANSWER = "poll_answer"
MY_CHAT_MEMBER = "my_chat_member"

View file

@ -21,7 +21,7 @@ class CreateInvoiceLink(TelegramMethod[str]):
description: str
"""Product description, 1-255 characters"""
payload: str
"""Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes."""
"""Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes."""
currency: str
"""Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_. Pass 'XTR' for payments in `Telegram Stars <https://t.me/BotNews/90>`_."""
prices: List[LabeledPrice]

View file

@ -26,7 +26,7 @@ class SendInvoice(TelegramMethod[Message]):
description: str
"""Product description, 1-255 characters"""
payload: str
"""Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes."""
"""Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes."""
currency: str
"""Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_. Pass 'XTR' for payments in `Telegram Stars <https://t.me/BotNews/90>`_."""
prices: List[LabeledPrice]

View file

@ -29,11 +29,13 @@ class SendPaidMedia(TelegramMethod[Message]):
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`). If the chat is a channel, all 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: int
"""The number of Telegram Stars that must be paid to buy access to the media"""
"""The number of Telegram Stars that must be paid to buy access to the media; 1-2500"""
media: List[Union[InputPaidMediaPhoto, InputPaidMediaVideo]]
"""A JSON-serialized array describing the media to be sent; up to 10 items"""
business_connection_id: Optional[str] = None
"""Unique identifier of the business connection on behalf of which the message will be sent"""
payload: Optional[str] = None
"""Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes."""
caption: Optional[str] = None
"""Media caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
@ -64,6 +66,7 @@ class SendPaidMedia(TelegramMethod[Message]):
star_count: int,
media: List[Union[InputPaidMediaPhoto, InputPaidMediaVideo]],
business_connection_id: Optional[str] = None,
payload: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = None,
caption_entities: Optional[List[MessageEntity]] = None,
@ -85,6 +88,7 @@ class SendPaidMedia(TelegramMethod[Message]):
star_count=star_count,
media=media,
business_connection_id=business_connection_id,
payload=payload,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,

View file

@ -233,6 +233,7 @@ from .web_app_data import WebAppData
from .web_app_info import WebAppInfo
from .webhook_info import WebhookInfo
from .write_access_allowed import WriteAccessAllowed
from .paid_media_purchased import PaidMediaPurchased
__all__ = (
"Animation",
@ -397,6 +398,7 @@ __all__ = (
"PaidMediaInfo",
"PaidMediaPhoto",
"PaidMediaPreview",
"PaidMediaPurchased",
"PaidMediaVideo",
"PassportData",
"PassportElementError",

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class ChatBoostSourceGiveaway(ChatBoostSource):
"""
The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription.
The boost was obtained by the creation of a Telegram Premium or a Telegram Star giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription for Telegram Premium giveaways and *prize_star_count* / 500 times for one year for Telegram Star giveaways.
Source: https://core.telegram.org/bots/api#chatboostsourcegiveaway
"""
@ -21,7 +21,9 @@ class ChatBoostSourceGiveaway(ChatBoostSource):
giveaway_message_id: int
"""Identifier of a message in the chat with the giveaway; the message could have been deleted already. May be 0 if the message isn't sent yet."""
user: Optional[User] = None
"""*Optional*. User that won the prize in the giveaway if any"""
"""*Optional*. User that won the prize in the giveaway if any; for Telegram Premium giveaways only"""
prize_star_count: Optional[int] = None
"""*Optional*. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only"""
is_unclaimed: Optional[bool] = None
"""*Optional*. True, if the giveaway was completed, but there was no user to win the prize"""
@ -35,6 +37,7 @@ class ChatBoostSourceGiveaway(ChatBoostSource):
source: Literal[ChatBoostSourceType.GIVEAWAY] = ChatBoostSourceType.GIVEAWAY,
giveaway_message_id: int,
user: Optional[User] = None,
prize_star_count: Optional[int] = None,
is_unclaimed: Optional[bool] = None,
**__pydantic_kwargs: Any,
) -> None:
@ -46,6 +49,7 @@ class ChatBoostSourceGiveaway(ChatBoostSource):
source=source,
giveaway_message_id=giveaway_message_id,
user=user,
prize_star_count=prize_star_count,
is_unclaimed=is_unclaimed,
**__pydantic_kwargs,
)

View file

@ -34,6 +34,10 @@ class ChatInviteLink(TelegramObject):
"""*Optional*. The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
pending_join_request_count: Optional[int] = None
"""*Optional*. Number of pending join requests created using this link"""
subscription_period: Optional[int] = None
"""*Optional*. The number of seconds the subscription will be active for before the next payment"""
subscription_price: Optional[int] = None
"""*Optional*. The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat using the link"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
@ -51,6 +55,8 @@ class ChatInviteLink(TelegramObject):
expire_date: Optional[DateTime] = None,
member_limit: Optional[int] = None,
pending_join_request_count: Optional[int] = None,
subscription_period: Optional[int] = None,
subscription_price: Optional[int] = None,
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!
@ -67,5 +73,7 @@ class ChatInviteLink(TelegramObject):
expire_date=expire_date,
member_limit=member_limit,
pending_join_request_count=pending_join_request_count,
subscription_period=subscription_period,
subscription_price=subscription_price,
**__pydantic_kwargs,
)

View file

@ -1074,7 +1074,7 @@ class ChatJoinRequest(TelegramObject):
:param title: Product name, 1-32 characters
:param description: Product description, 1-255 characters
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
:param currency: Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_. Pass 'XTR' for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param prices: Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@ -1187,7 +1187,7 @@ class ChatJoinRequest(TelegramObject):
:param title: Product name, 1-32 characters
:param description: Product description, 1-255 characters
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
:param currency: Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_. Pass 'XTR' for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param prices: Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only

View file

@ -621,7 +621,7 @@ class ChatMemberUpdated(TelegramObject):
:param title: Product name, 1-32 characters
:param description: Product description, 1-255 characters
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
:param currency: Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_. Pass 'XTR' for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param prices: Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only

View file

@ -30,8 +30,10 @@ class Giveaway(TelegramObject):
"""*Optional*. Description of additional giveaway prize"""
country_codes: Optional[List[str]] = None
"""*Optional*. A list of two-letter `ISO 3166-1 alpha-2 <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>`_ country codes indicating the countries from which eligible users for the giveaway must 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."""
prize_star_count: Optional[int] = None
"""*Optional*. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only"""
premium_subscription_month_count: Optional[int] = None
"""*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for"""
"""*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
@ -47,6 +49,7 @@ class Giveaway(TelegramObject):
has_public_winners: Optional[bool] = None,
prize_description: Optional[str] = None,
country_codes: Optional[List[str]] = None,
prize_star_count: Optional[int] = None,
premium_subscription_month_count: Optional[int] = None,
**__pydantic_kwargs: Any,
) -> None:
@ -62,6 +65,7 @@ class Giveaway(TelegramObject):
has_public_winners=has_public_winners,
prize_description=prize_description,
country_codes=country_codes,
prize_star_count=prize_star_count,
premium_subscription_month_count=premium_subscription_month_count,
**__pydantic_kwargs,
)

View file

@ -21,6 +21,8 @@ class GiveawayCompleted(TelegramObject):
"""*Optional*. Number of undistributed prizes"""
giveaway_message: Optional[Message] = None
"""*Optional*. Message with the giveaway that was completed, if it wasn't deleted"""
is_star_giveaway: Optional[bool] = None
"""*Optional*. :code:`True`, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway."""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
@ -32,6 +34,7 @@ class GiveawayCompleted(TelegramObject):
winner_count: int,
unclaimed_prize_count: Optional[int] = None,
giveaway_message: Optional[Message] = None,
is_star_giveaway: Optional[bool] = None,
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!
@ -42,5 +45,6 @@ class GiveawayCompleted(TelegramObject):
winner_count=winner_count,
unclaimed_prize_count=unclaimed_prize_count,
giveaway_message=giveaway_message,
is_star_giveaway=is_star_giveaway,
**__pydantic_kwargs,
)

View file

@ -1,9 +1,29 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional
from .base import TelegramObject
class GiveawayCreated(TelegramObject):
"""
This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.
This object represents a service message about the creation of a scheduled giveaway.
Source: https://core.telegram.org/bots/api#giveawaycreated
"""
prize_star_count: Optional[int] = None
"""*Optional*. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__, *, prize_star_count: Optional[int] = None, **__pydantic_kwargs: Any
) -> None:
# DO NOT EDIT MANUALLY!!!
# This method was auto-generated via `butcher`
# Is needed only for type checking and IDE support without any additional plugins
super().__init__(prize_star_count=prize_star_count, **__pydantic_kwargs)

View file

@ -29,8 +29,10 @@ class GiveawayWinners(TelegramObject):
"""List of up to 100 winners of the giveaway"""
additional_chat_count: Optional[int] = None
"""*Optional*. The number of other chats the user had to join in order to be eligible for the giveaway"""
prize_star_count: Optional[int] = None
"""*Optional*. The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only"""
premium_subscription_month_count: Optional[int] = None
"""*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for"""
"""*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only"""
unclaimed_prize_count: Optional[int] = None
"""*Optional*. Number of undistributed prizes"""
only_new_members: Optional[bool] = None
@ -53,6 +55,7 @@ class GiveawayWinners(TelegramObject):
winner_count: int,
winners: List[User],
additional_chat_count: Optional[int] = None,
prize_star_count: Optional[int] = None,
premium_subscription_month_count: Optional[int] = None,
unclaimed_prize_count: Optional[int] = None,
only_new_members: Optional[bool] = None,
@ -71,6 +74,7 @@ class GiveawayWinners(TelegramObject):
winner_count=winner_count,
winners=winners,
additional_chat_count=additional_chat_count,
prize_star_count=prize_star_count,
premium_subscription_month_count=premium_subscription_month_count,
unclaimed_prize_count=unclaimed_prize_count,
only_new_members=only_new_members,

View file

@ -20,7 +20,7 @@ class InputInvoiceMessageContent(InputMessageContent):
description: str
"""Product description, 1-255 characters"""
payload: str
"""Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes."""
"""Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes."""
currency: str
"""Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_. Pass 'XTR' for payments in `Telegram Stars <https://t.me/BotNews/90>`_."""
prices: List[LabeledPrice]

View file

@ -1467,7 +1467,7 @@ class Message(MaybeInaccessibleMessage):
:param title: Product name, 1-32 characters
:param description: Product description, 1-255 characters
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
:param currency: Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_. Pass 'XTR' for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param prices: Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param provider_token: Payment provider token, obtained via `@BotFather <https://t.me/botfather>`_. Pass an empty string for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
@ -1582,7 +1582,7 @@ class Message(MaybeInaccessibleMessage):
:param title: Product name, 1-32 characters
:param description: Product description, 1-255 characters
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
:param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
:param currency: Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_. Pass 'XTR' for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param prices: Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param provider_token: Payment provider token, obtained via `@BotFather <https://t.me/botfather>`_. Pass an empty string for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
@ -4103,6 +4103,7 @@ class Message(MaybeInaccessibleMessage):
self,
star_count: int,
media: List[Union[InputPaidMediaPhoto, InputPaidMediaVideo]],
payload: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = None,
caption_entities: Optional[List[MessageEntity]] = None,
@ -4127,8 +4128,9 @@ class Message(MaybeInaccessibleMessage):
Source: https://core.telegram.org/bots/api#sendpaidmedia
:param star_count: The number of Telegram Stars that must be paid to buy access to the media
:param star_count: The number of Telegram Stars that must be paid to buy access to the media; 1-2500
:param media: A JSON-serialized array describing the media to be sent; up to 10 items
:param payload: Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
:param caption: Media caption, 0-1024 characters after entities parsing
:param parse_mode: Mode for parsing entities in the media caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*
@ -4154,6 +4156,7 @@ class Message(MaybeInaccessibleMessage):
business_connection_id=self.business_connection_id,
star_count=star_count,
media=media,
payload=payload,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,
@ -4169,6 +4172,7 @@ class Message(MaybeInaccessibleMessage):
self,
star_count: int,
media: List[Union[InputPaidMediaPhoto, InputPaidMediaVideo]],
payload: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = None,
caption_entities: Optional[List[MessageEntity]] = None,
@ -4193,8 +4197,9 @@ class Message(MaybeInaccessibleMessage):
Source: https://core.telegram.org/bots/api#sendpaidmedia
:param star_count: The number of Telegram Stars that must be paid to buy access to the media
:param star_count: The number of Telegram Stars that must be paid to buy access to the media; 1-2500
:param media: A JSON-serialized array describing the media to be sent; up to 10 items
:param payload: Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
:param caption: Media caption, 0-1024 characters after entities parsing
:param parse_mode: Mode for parsing entities in the media caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*
@ -4220,6 +4225,7 @@ class Message(MaybeInaccessibleMessage):
reply_parameters=self.as_reply_parameters(),
star_count=star_count,
media=media,
payload=payload,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,

View file

@ -0,0 +1,42 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from pydantic import Field
from .base import TelegramObject
if TYPE_CHECKING:
from .user import User
class PaidMediaPurchased(TelegramObject):
"""
This object contains information about a paid media purchase.
Source: https://core.telegram.org/bots/api#paidmediapurchased
"""
from_user: User = Field(..., alias="from")
"""User who purchased the media"""
paid_media_payload: str
"""Bot-specified paid media payload"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
from_user: User,
paid_media_payload: str,
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!
# This method was auto-generated via `butcher`
# Is needed only for type checking and IDE support without any additional plugins
super().__init__(
from_user=from_user, paid_media_payload=paid_media_payload, **__pydantic_kwargs
)

View file

@ -27,6 +27,8 @@ class TransactionPartnerUser(TransactionPartner):
"""*Optional*. Bot-specified invoice payload"""
paid_media: Optional[List[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]]] = None
"""*Optional*. Information about the paid media bought by the user"""
paid_media_payload: Optional[str] = None
"""*Optional*. Bot-specified paid media payload"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
@ -41,6 +43,7 @@ class TransactionPartnerUser(TransactionPartner):
paid_media: Optional[
List[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]]
] = None,
paid_media_payload: Optional[str] = None,
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!
@ -52,5 +55,6 @@ class TransactionPartnerUser(TransactionPartner):
user=user,
invoice_payload=invoice_payload,
paid_media=paid_media,
paid_media_payload=paid_media_payload,
**__pydantic_kwargs,
)

View file

@ -2,8 +2,8 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional, cast
from ..utils.mypy_hacks import lru_cache
from .base import TelegramObject
from ..utils.mypy_hacks import lru_cache
if TYPE_CHECKING:
from .business_connection import BusinessConnection
@ -22,6 +22,7 @@ if TYPE_CHECKING:
from .poll_answer import PollAnswer
from .pre_checkout_query import PreCheckoutQuery
from .shipping_query import ShippingQuery
from .paid_media_purchased import PaidMediaPurchased
class Update(TelegramObject):
@ -65,6 +66,8 @@ class Update(TelegramObject):
"""*Optional*. New incoming shipping query. Only for invoices with flexible price"""
pre_checkout_query: Optional[PreCheckoutQuery] = None
"""*Optional*. New incoming pre-checkout query. Contains full information about checkout"""
purchased_paid_media: Optional[PaidMediaPurchased] = None
"""*Optional*. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat"""
poll: Optional[Poll] = None
"""*Optional*. New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot"""
poll_answer: Optional[PollAnswer] = None
@ -103,6 +106,7 @@ class Update(TelegramObject):
callback_query: Optional[CallbackQuery] = None,
shipping_query: Optional[ShippingQuery] = None,
pre_checkout_query: Optional[PreCheckoutQuery] = None,
purchased_paid_media: Optional[PaidMediaPurchased] = None,
poll: Optional[Poll] = None,
poll_answer: Optional[PollAnswer] = None,
my_chat_member: Optional[ChatMemberUpdated] = None,
@ -133,6 +137,7 @@ class Update(TelegramObject):
callback_query=callback_query,
shipping_query=shipping_query,
pre_checkout_query=pre_checkout_query,
purchased_paid_media=purchased_paid_media,
poll=poll,
poll_answer=poll_answer,
my_chat_member=my_chat_member,
@ -199,6 +204,8 @@ class Update(TelegramObject):
return "edited_business_message"
if self.business_message:
return "business_message"
if self.purchased_paid_media:
return "purchased_paid_media"
raise UpdateTypeLookupError("Update does not contain any known event type.")