Added full support ob Bot API 7.10

This commit is contained in:
JRoot Junior 2024-09-06 20:06:18 +03:00
parent a2fa4c50ba
commit c79da13d8e
No known key found for this signature in database
GPG key ID: 738964250D5FF6E2
27 changed files with 386 additions and 78 deletions

View file

@ -30,9 +30,9 @@
{
"type": "Integer",
"required": true,
"description": "The number of Telegram Stars that must be paid to buy access to the media",
"html_description": "<td>The number of Telegram Stars that must be paid to buy access to the media</td>",
"rst_description": "The number of Telegram Stars that must be paid to buy access to the media\n",
"description": "The number of Telegram Stars that must be paid to buy access to the media; 1-2500",
"html_description": "<td>The number of Telegram Stars that must be paid to buy access to the media; 1-2500</td>",
"rst_description": "The number of Telegram Stars that must be paid to buy access to the media; 1-2500\n",
"name": "star_count"
},
{
@ -43,6 +43,14 @@
"rst_description": "A JSON-serialized array describing the media to be sent; up to 10 items\n",
"name": "media"
},
{
"type": "String",
"required": false,
"description": "Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.",
"html_description": "<td>Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.</td>",
"rst_description": "Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.\n",
"name": "payload"
},
{
"type": "String",
"required": false,

View file

@ -1,7 +1,7 @@
{
"api": {
"version": "7.9",
"release_date": "2024-08-14"
"version": "7.10",
"release_date": "2024-09-06"
},
"items": [
{
@ -143,6 +143,14 @@
"name": "pre_checkout_query",
"required": false
},
{
"type": "PaidMediaPurchased",
"description": "A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat",
"html_description": "<td><em>Optional</em>. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat</td>",
"rst_description": "*Optional*. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat\n",
"name": "purchased_paid_media",
"required": false
},
{
"type": "Poll",
"description": "New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot",
@ -4029,10 +4037,19 @@
{
"anchor": "giveawaycreated",
"name": "GiveawayCreated",
"description": "This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.",
"html_description": "<p>This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.</p>",
"rst_description": "This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.",
"annotations": [],
"description": "This object represents a service message about the creation of a scheduled giveaway.",
"html_description": "<p>This object represents a service message about the creation of a scheduled giveaway.</p>",
"rst_description": "This object represents a service message about the creation of a scheduled giveaway.",
"annotations": [
{
"type": "Integer",
"description": "The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only",
"html_description": "<td><em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only</td>",
"rst_description": "*Optional*. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only\n",
"name": "prize_star_count",
"required": false
}
],
"category": "types"
},
{
@ -4100,9 +4117,17 @@
},
{
"type": "Integer",
"description": "The number of months the Telegram Premium subscription won from the giveaway will be active for",
"html_description": "<td><em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for</td>",
"rst_description": "*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for\n",
"description": "The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only",
"html_description": "<td><em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only</td>",
"rst_description": "*Optional*. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only\n",
"name": "prize_star_count",
"required": false
},
{
"type": "Integer",
"description": "The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only",
"html_description": "<td><em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only</td>",
"rst_description": "*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only\n",
"name": "premium_subscription_month_count",
"required": false
}
@ -4166,9 +4191,17 @@
},
{
"type": "Integer",
"description": "The number of months the Telegram Premium subscription won from the giveaway will be active for",
"html_description": "<td><em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for</td>",
"rst_description": "*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for\n",
"description": "The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only",
"html_description": "<td><em>Optional</em>. The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only</td>",
"rst_description": "*Optional*. The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only\n",
"name": "prize_star_count",
"required": false
},
{
"type": "Integer",
"description": "The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only",
"html_description": "<td><em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only</td>",
"rst_description": "*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only\n",
"name": "premium_subscription_month_count",
"required": false
},
@ -4237,6 +4270,14 @@
"rst_description": "*Optional*. Message with the giveaway that was completed, if it wasn't deleted\n",
"name": "giveaway_message",
"required": false
},
{
"type": "True",
"description": "True, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.",
"html_description": "<td><em>Optional</em>. <em>True</em>, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.</td>",
"rst_description": "*Optional*. :code:`True`, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.\n",
"name": "is_star_giveaway",
"required": false
}
],
"category": "types"
@ -6811,9 +6852,9 @@
{
"anchor": "chatboostsourcegiveaway",
"name": "ChatBoostSourceGiveaway",
"description": "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.",
"html_description": "<p>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.</p>",
"rst_description": "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.",
"description": "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.",
"html_description": "<p>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 <em>prize_star_count</em> / 500 times for one year for Telegram Star giveaways.</p>",
"rst_description": "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.",
"annotations": [
{
"type": "String",
@ -6833,12 +6874,20 @@
},
{
"type": "User",
"description": "User that won the prize in the giveaway if any",
"html_description": "<td><em>Optional</em>. User that won the prize in the giveaway if any</td>",
"rst_description": "*Optional*. User that won the prize in the giveaway if any\n",
"description": "User that won the prize in the giveaway if any; for Telegram Premium giveaways only",
"html_description": "<td><em>Optional</em>. User that won the prize in the giveaway if any; for Telegram Premium giveaways only</td>",
"rst_description": "*Optional*. User that won the prize in the giveaway if any; for Telegram Premium giveaways only\n",
"name": "user",
"required": false
},
{
"type": "Integer",
"description": "The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only",
"html_description": "<td><em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only</td>",
"rst_description": "*Optional*. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only\n",
"name": "prize_star_count",
"required": false
},
{
"type": "True",
"description": "True, if the giveaway was completed, but there was no user to win the prize",
@ -9005,9 +9054,9 @@
{
"type": "Integer",
"required": true,
"description": "The number of Telegram Stars that must be paid to buy access to the media",
"html_description": "<td>The number of Telegram Stars that must be paid to buy access to the media</td>",
"rst_description": "The number of Telegram Stars that must be paid to buy access to the media\n",
"description": "The number of Telegram Stars that must be paid to buy access to the media; 1-2500",
"html_description": "<td>The number of Telegram Stars that must be paid to buy access to the media; 1-2500</td>",
"rst_description": "The number of Telegram Stars that must be paid to buy access to the media; 1-2500\n",
"name": "star_count"
},
{
@ -9018,6 +9067,14 @@
"rst_description": "A JSON-serialized array describing the media to be sent; up to 10 items\n",
"name": "media"
},
{
"type": "String",
"required": false,
"description": "Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.",
"html_description": "<td>Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.</td>",
"rst_description": "Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.\n",
"name": "payload"
},
{
"type": "String",
"required": false,
@ -16594,6 +16651,32 @@
],
"category": "types"
},
{
"anchor": "paidmediapurchased",
"name": "PaidMediaPurchased",
"description": "This object contains information about a paid media purchase.",
"html_description": "<p>This object contains information about a paid media purchase.</p>",
"rst_description": "This object contains information about a paid media purchase.",
"annotations": [
{
"type": "User",
"description": "User who purchased the media",
"html_description": "<td>User who purchased the media</td>",
"rst_description": "User who purchased the media\n",
"name": "from",
"required": true
},
{
"type": "String",
"description": "Bot-specified paid media payload",
"html_description": "<td>Bot-specified paid media payload</td>",
"rst_description": "Bot-specified paid media payload\n",
"name": "paid_media_payload",
"required": true
}
],
"category": "types"
},
{
"anchor": "revenuewithdrawalstate",
"name": "RevenueWithdrawalState",
@ -16720,6 +16803,14 @@
"rst_description": "*Optional*. Information about the paid media bought by the user\n",
"name": "paid_media",
"required": false
},
{
"type": "String",
"description": "Bot-specified paid media payload",
"html_description": "<td><em>Optional</em>. Bot-specified paid media payload</td>",
"rst_description": "*Optional*. Bot-specified paid media payload\n",
"name": "paid_media_payload",
"required": false
}
],
"category": "types"

View file

@ -7,9 +7,9 @@
"object": {
"anchor": "chatboostsourcegiveaway",
"name": "ChatBoostSourceGiveaway",
"description": "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.",
"html_description": "<p>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.</p>",
"rst_description": "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.",
"description": "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.",
"html_description": "<p>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 <em>prize_star_count</em> / 500 times for one year for Telegram Star giveaways.</p>",
"rst_description": "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.",
"annotations": [
{
"type": "String",
@ -29,12 +29,20 @@
},
{
"type": "User",
"description": "User that won the prize in the giveaway if any",
"html_description": "<td><em>Optional</em>. User that won the prize in the giveaway if any</td>",
"rst_description": "*Optional*. User that won the prize in the giveaway if any\n",
"description": "User that won the prize in the giveaway if any; for Telegram Premium giveaways only",
"html_description": "<td><em>Optional</em>. User that won the prize in the giveaway if any; for Telegram Premium giveaways only</td>",
"rst_description": "*Optional*. User that won the prize in the giveaway if any; for Telegram Premium giveaways only\n",
"name": "user",
"required": false
},
{
"type": "Integer",
"description": "The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only",
"html_description": "<td><em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only</td>",
"rst_description": "*Optional*. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only\n",
"name": "prize_star_count",
"required": false
},
{
"type": "True",
"description": "True, if the giveaway was completed, but there was no user to win the prize",

View file

@ -69,9 +69,17 @@
},
{
"type": "Integer",
"description": "The number of months the Telegram Premium subscription won from the giveaway will be active for",
"html_description": "<td><em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for</td>",
"rst_description": "*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for\n",
"description": "The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only",
"html_description": "<td><em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only</td>",
"rst_description": "*Optional*. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only\n",
"name": "prize_star_count",
"required": false
},
{
"type": "Integer",
"description": "The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only",
"html_description": "<td><em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only</td>",
"rst_description": "*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only\n",
"name": "premium_subscription_month_count",
"required": false
}

View file

@ -34,6 +34,14 @@
"rst_description": "*Optional*. Message with the giveaway that was completed, if it wasn't deleted\n",
"name": "giveaway_message",
"required": false
},
{
"type": "True",
"description": "True, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.",
"html_description": "<td><em>Optional</em>. <em>True</em>, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.</td>",
"rst_description": "*Optional*. :code:`True`, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.\n",
"name": "is_star_giveaway",
"required": false
}
],
"category": "types"

View file

@ -7,10 +7,19 @@
"object": {
"anchor": "giveawaycreated",
"name": "GiveawayCreated",
"description": "This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.",
"html_description": "<p>This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.</p>",
"rst_description": "This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.",
"annotations": [],
"description": "This object represents a service message about the creation of a scheduled giveaway.",
"html_description": "<p>This object represents a service message about the creation of a scheduled giveaway.</p>",
"rst_description": "This object represents a service message about the creation of a scheduled giveaway.",
"annotations": [
{
"type": "Integer",
"description": "The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only",
"html_description": "<td><em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only</td>",
"rst_description": "*Optional*. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only\n",
"name": "prize_star_count",
"required": false
}
],
"category": "types"
}
}

View file

@ -61,9 +61,17 @@
},
{
"type": "Integer",
"description": "The number of months the Telegram Premium subscription won from the giveaway will be active for",
"html_description": "<td><em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for</td>",
"rst_description": "*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for\n",
"description": "The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only",
"html_description": "<td><em>Optional</em>. The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only</td>",
"rst_description": "*Optional*. The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only\n",
"name": "prize_star_count",
"required": false
},
{
"type": "Integer",
"description": "The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only",
"html_description": "<td><em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only</td>",
"rst_description": "*Optional*. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only\n",
"name": "premium_subscription_month_count",
"required": false
},

View file

@ -0,0 +1,33 @@
{
"meta": {},
"group": {
"title": "Payments",
"anchor": "payments"
},
"object": {
"anchor": "paidmediapurchased",
"name": "PaidMediaPurchased",
"description": "This object contains information about a paid media purchase.",
"html_description": "<p>This object contains information about a paid media purchase.</p>",
"rst_description": "This object contains information about a paid media purchase.",
"annotations": [
{
"type": "User",
"description": "User who purchased the media",
"html_description": "<td>User who purchased the media</td>",
"rst_description": "User who purchased the media\n",
"name": "from",
"required": true
},
{
"type": "String",
"description": "Bot-specified paid media payload",
"html_description": "<td>Bot-specified paid media payload</td>",
"rst_description": "Bot-specified paid media payload\n",
"name": "paid_media_payload",
"required": true
}
],
"category": "types"
}
}

View file

@ -42,6 +42,14 @@
"rst_description": "*Optional*. Information about the paid media bought by the user\n",
"name": "paid_media",
"required": false
},
{
"type": "String",
"description": "Bot-specified paid media payload",
"html_description": "<td><em>Optional</em>. Bot-specified paid media payload</td>",
"rst_description": "*Optional*. Bot-specified paid media payload\n",
"name": "paid_media_payload",
"required": false
}
],
"category": "types"

View file

@ -139,6 +139,14 @@
"name": "pre_checkout_query",
"required": false
},
{
"type": "PaidMediaPurchased",
"description": "A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat",
"html_description": "<td><em>Optional</em>. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat</td>",
"rst_description": "*Optional*. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat\n",
"name": "purchased_paid_media",
"required": false
},
{
"type": "Poll",
"description": "New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot",

View file

@ -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

@ -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")

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

@ -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

@ -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

@ -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.")

View file

@ -212,6 +212,34 @@ Stickers
sticker
sticker_set
Payments
========
.. toctree::
:maxdepth: 1
invoice
labeled_price
order_info
paid_media_purchased
pre_checkout_query
refunded_payment
revenue_withdrawal_state
revenue_withdrawal_state_failed
revenue_withdrawal_state_pending
revenue_withdrawal_state_succeeded
shipping_address
shipping_option
shipping_query
star_transaction
star_transactions
successful_payment
transaction_partner
transaction_partner_fragment
transaction_partner_other
transaction_partner_telegram_ads
transaction_partner_user
Telegram Passport
=================
@ -233,33 +261,6 @@ Telegram Passport
passport_element_error_unspecified
passport_file
Payments
========
.. toctree::
:maxdepth: 1
invoice
labeled_price
order_info
pre_checkout_query
refunded_payment
revenue_withdrawal_state
revenue_withdrawal_state_failed
revenue_withdrawal_state_pending
revenue_withdrawal_state_succeeded
shipping_address
shipping_option
shipping_query
star_transaction
star_transactions
successful_payment
transaction_partner
transaction_partner_fragment
transaction_partner_other
transaction_partner_telegram_ads
transaction_partner_user
Getting updates
===============

View file

@ -0,0 +1,10 @@
##################
PaidMediaPurchased
##################
.. automodule:: aiogram.types.paid_media_purchased
:members:
:member-order: bysource
:undoc-members: True
:exclude-members: model_config,model_fields

View file

@ -527,7 +527,7 @@ TEST_MESSAGE_GIVEAWAY_CREATED = Message(
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=None,
giveaway_created=GiveawayCreated(),
giveaway_created=GiveawayCreated(prize_star_count=42),
)
TEST_MESSAGE_GIVEAWAY_WINNERS = Message(
message_id=42,