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

@ -30,9 +30,9 @@
{
"type": "String",
"required": true,
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.\n",
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.\n",
"name": "payload"
},
{

View file

@ -46,9 +46,9 @@
{
"type": "String",
"required": true,
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.\n",
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.\n",
"name": "payload"
},
{

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"
@ -5129,6 +5170,22 @@
"rst_description": "*Optional*. Number of pending join requests created using this link\n",
"name": "pending_join_request_count",
"required": false
},
{
"type": "Integer",
"description": "The number of seconds the subscription will be active for before the next payment",
"html_description": "<td><em>Optional</em>. The number of seconds the subscription will be active for before the next payment</td>",
"rst_description": "*Optional*. The number of seconds the subscription will be active for before the next payment\n",
"name": "subscription_period",
"required": false
},
{
"type": "Integer",
"description": "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",
"html_description": "<td><em>Optional</em>. 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</td>",
"rst_description": "*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\n",
"name": "subscription_price",
"required": false
}
],
"category": "types"
@ -6795,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",
@ -6817,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",
@ -8989,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"
},
{
@ -9002,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,
@ -15366,9 +15439,9 @@
},
{
"type": "String",
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.\n",
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.\n",
"name": "payload",
"required": true
},
@ -15654,9 +15727,9 @@
{
"type": "String",
"required": true,
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.\n",
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.\n",
"name": "payload"
},
{
@ -15872,9 +15945,9 @@
{
"type": "String",
"required": true,
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.\n",
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.\n",
"name": "payload"
},
{
@ -16578,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",
@ -16704,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

@ -82,6 +82,22 @@
"rst_description": "*Optional*. Number of pending join requests created using this link\n",
"name": "pending_join_request_count",
"required": false
},
{
"type": "Integer",
"description": "The number of seconds the subscription will be active for before the next payment",
"html_description": "<td><em>Optional</em>. The number of seconds the subscription will be active for before the next payment</td>",
"rst_description": "*Optional*. The number of seconds the subscription will be active for before the next payment\n",
"name": "subscription_period",
"required": false
},
{
"type": "Integer",
"description": "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",
"html_description": "<td><em>Optional</em>. 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</td>",
"rst_description": "*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\n",
"name": "subscription_price",
"required": false
}
],
"category": "types"

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

@ -29,9 +29,9 @@
},
{
"type": "String",
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.\n",
"description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.",
"html_description": "<td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.</td>",
"rst_description": "Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.\n",
"name": "payload",
"required": true
},

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",

15
CHANGES/1510.feature.rst Normal file
View file

@ -0,0 +1,15 @@
- Added updates about purchased paid media, represented by the class
:class:`aiogram.types.paid_media_purchased.PaidMediaPurchased`
and the field :code:`purchased_paid_media` in the class
:class:`aiogram.types.update.Update`.
- Added the ability to specify a payload in
:class:`aiogram.methods.send_paid_media.SendPaidMedia` that is received back by the bot in
:class:`aiogram.types.transaction_partner_user.TransactionPartnerUser`
and :code:`purchased_paid_media` updates.
- Added the field :code:`prize_star_count` to the classes
:class:`aiogram.types.giveaway_created.GiveawayCreated`,
:class:`aiogram.types.giveaway.Giveaway`,
:class:`aiogram.types.giveaway_winners.GiveawayWinners`
and :class:`aiogram.types.chat_boost_source_giveaway.ChatBoostSourceGiveaway`.
- Added the field :code:`is_star_giveaway` to the class
:class:`aiogram.types.giveaway_completed.GiveawayCompleted`.

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

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,

View file

@ -42,6 +42,7 @@ from aiogram.types import (
ShippingQuery,
Update,
User,
PaidMediaPurchased,
)
from aiogram.types.error_event import ErrorEvent
from tests.mocked_bot import MockedBot
@ -586,6 +587,18 @@ class TestDispatcher:
True,
True,
),
pytest.param(
"purchased_paid_media",
Update(
update_id=42,
purchased_paid_media=PaidMediaPurchased(
paid_media_payload="payload",
from_user=User(id=42, is_bot=False, first_name="Test"),
),
),
False,
True,
),
],
)
async def test_listen_update(