Skip to content

Commit 2de61ee

Browse files
committed
Update code to reflect latest changes to the Bot API documentation
1 parent e407bfd commit 2de61ee

9 files changed

Lines changed: 97 additions & 13 deletions

src/Layers/Generated.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,10 @@ public function sendVideoNote(
594594
* Use this method to send paid media. On success, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned.
595595
*
596596
* @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @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.
597-
* @param int $star_count The number of Telegram Stars that must be paid to buy access to the media
597+
* @param int $star_count The number of Telegram Stars that must be paid to buy access to the media; 1-2500
598598
* @param InputPaidMedia[] $media A JSON-serialized array describing the media to be sent; up to 10 items
599599
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the message will be sent
600+
* @param string $payload Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
600601
* @param string $caption Media caption, 0-1024 characters after entities parsing
601602
* @param ParseMode|string $parse_mode Mode for parsing entities in the media caption. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details.
602603
* @param MessageEntity[] $caption_entities A JSON-serialized list of special entities that appear in the caption, which can be specified instead of <em>parse_mode</em>
@@ -613,6 +614,7 @@ public function sendPaidMedia(
613614
int $star_count,
614615
array $media,
615616
?string $business_connection_id = null,
617+
?string $payload = null,
616618
?string $caption = null,
617619
ParseMode|string|null $parse_mode = null,
618620
?array $caption_entities = null,

src/Telegram/ChatBoostSourceGiveaway.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Telepath\Telegram;
88

99
/**
10-
* 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.
10+
* 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.
1111
*/
1212
class ChatBoostSourceGiveaway extends ChatBoostSource
1313
{
@@ -17,19 +17,28 @@ class ChatBoostSourceGiveaway extends ChatBoostSource
1717
/** 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. */
1818
public int $giveaway_message_id;
1919

20+
/** <em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only */
21+
public ?int $prize_star_count = null;
22+
2023
/** <em>Optional</em>. True, if the giveaway was completed, but there was no user to win the prize */
2124
public ?bool $is_unclaimed = null;
2225

2326
/**
2427
* @param int $giveaway_message_id 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.
25-
* @param User $user <em>Optional</em>. User that won the prize in the giveaway if any
28+
* @param User $user <em>Optional</em>. User that won the prize in the giveaway if any; for Telegram Premium giveaways only
29+
* @param int $prize_star_count <em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
2630
* @param bool $is_unclaimed <em>Optional</em>. True, if the giveaway was completed, but there was no user to win the prize
2731
*/
28-
public static function make(int $giveaway_message_id, ?User $user = null, ?bool $is_unclaimed = null): static
29-
{
32+
public static function make(
33+
int $giveaway_message_id,
34+
?User $user = null,
35+
?int $prize_star_count = null,
36+
?bool $is_unclaimed = null,
37+
): static {
3038
return new static([
3139
'giveaway_message_id' => $giveaway_message_id,
3240
'user' => $user,
41+
'prize_star_count' => $prize_star_count,
3342
'is_unclaimed' => $is_unclaimed,
3443
]);
3544
}

src/Telegram/Giveaway.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ class Giveaway extends Type
4242
*/
4343
public ?array $country_codes = null;
4444

45-
/** <em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for */
45+
/** <em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only */
46+
public ?int $prize_star_count = null;
47+
48+
/** <em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only */
4649
public ?int $premium_subscription_month_count = null;
4750

4851
/**
@@ -53,7 +56,8 @@ class Giveaway extends Type
5356
* @param bool $has_public_winners <em>Optional</em>. <em>True</em>, if the list of giveaway winners will be visible to everyone
5457
* @param string $prize_description <em>Optional</em>. Description of additional giveaway prize
5558
* @param string[] $country_codes <em>Optional</em>. A list of two-letter <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2</a> 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.
56-
* @param int $premium_subscription_month_count <em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for
59+
* @param int $prize_star_count <em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
60+
* @param int $premium_subscription_month_count <em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only
5761
*/
5862
public static function make(
5963
array $chats,
@@ -63,6 +67,7 @@ public static function make(
6367
?bool $has_public_winners = null,
6468
?string $prize_description = null,
6569
?array $country_codes = null,
70+
?int $prize_star_count = null,
6671
?int $premium_subscription_month_count = null,
6772
): static {
6873
return new static([
@@ -73,6 +78,7 @@ public static function make(
7378
'has_public_winners' => $has_public_winners,
7479
'prize_description' => $prize_description,
7580
'country_codes' => $country_codes,
81+
'prize_star_count' => $prize_star_count,
7682
'premium_subscription_month_count' => $premium_subscription_month_count,
7783
]);
7884
}

src/Telegram/GiveawayCompleted.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,26 @@ class GiveawayCompleted extends Type
2222
/** <em>Optional</em>. Message with the giveaway that was completed, if it wasn't deleted */
2323
public ?Message $giveaway_message = null;
2424

25+
/** <em>Optional</em>. <em>True</em>, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway. */
26+
public ?bool $is_star_giveaway = null;
27+
2528
/**
2629
* @param int $winner_count Number of winners in the giveaway
2730
* @param int $unclaimed_prize_count <em>Optional</em>. Number of undistributed prizes
2831
* @param Message $giveaway_message <em>Optional</em>. Message with the giveaway that was completed, if it wasn't deleted
32+
* @param bool $is_star_giveaway <em>Optional</em>. <em>True</em>, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.
2933
*/
3034
public static function make(
3135
int $winner_count,
3236
?int $unclaimed_prize_count = null,
3337
?Message $giveaway_message = null,
38+
?bool $is_star_giveaway = null,
3439
): static {
3540
return new static([
3641
'winner_count' => $winner_count,
3742
'unclaimed_prize_count' => $unclaimed_prize_count,
3843
'giveaway_message' => $giveaway_message,
44+
'is_star_giveaway' => $is_star_giveaway,
3945
]);
4046
}
4147
}

src/Telegram/GiveawayCreated.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@
99
use Telepath\Types\Type;
1010

1111
/**
12-
* This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.
12+
* This object represents a service message about the creation of a scheduled giveaway.
1313
*/
1414
class GiveawayCreated extends Type
1515
{
16-
public static function make(): static
16+
/** <em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only */
17+
public ?int $prize_star_count = null;
18+
19+
/**
20+
* @param int $prize_star_count <em>Optional</em>. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
21+
*/
22+
public static function make(?int $prize_star_count = null): static
1723
{
1824
return new static([
25+
'prize_star_count' => $prize_star_count,
1926
]);
2027
}
2128
}

src/Telegram/GiveawayWinners.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ class GiveawayWinners extends Type
3535
/** <em>Optional</em>. The number of other chats the user had to join in order to be eligible for the giveaway */
3636
public ?int $additional_chat_count = null;
3737

38-
/** <em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for */
38+
/** <em>Optional</em>. The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only */
39+
public ?int $prize_star_count = null;
40+
41+
/** <em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only */
3942
public ?int $premium_subscription_month_count = null;
4043

4144
/** <em>Optional</em>. Number of undistributed prizes */
@@ -57,7 +60,8 @@ class GiveawayWinners extends Type
5760
* @param int $winner_count Total number of winners in the giveaway
5861
* @param User[] $winners List of up to 100 winners of the giveaway
5962
* @param int $additional_chat_count <em>Optional</em>. The number of other chats the user had to join in order to be eligible for the giveaway
60-
* @param int $premium_subscription_month_count <em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for
63+
* @param int $prize_star_count <em>Optional</em>. The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only
64+
* @param int $premium_subscription_month_count <em>Optional</em>. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only
6165
* @param int $unclaimed_prize_count <em>Optional</em>. Number of undistributed prizes
6266
* @param bool $only_new_members <em>Optional</em>. <em>True</em>, if only users who had joined the chats after the giveaway started were eligible to win
6367
* @param bool $was_refunded <em>Optional</em>. <em>True</em>, if the giveaway was canceled because the payment for it was refunded
@@ -70,6 +74,7 @@ public static function make(
7074
int $winner_count,
7175
array $winners,
7276
?int $additional_chat_count = null,
77+
?int $prize_star_count = null,
7378
?int $premium_subscription_month_count = null,
7479
?int $unclaimed_prize_count = null,
7580
?bool $only_new_members = null,
@@ -83,6 +88,7 @@ public static function make(
8388
'winner_count' => $winner_count,
8489
'winners' => $winners,
8590
'additional_chat_count' => $additional_chat_count,
91+
'prize_star_count' => $prize_star_count,
8692
'premium_subscription_month_count' => $premium_subscription_month_count,
8793
'unclaimed_prize_count' => $unclaimed_prize_count,
8894
'only_new_members' => $only_new_members,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated.
5+
*/
6+
7+
namespace Telepath\Telegram;
8+
9+
use Telepath\Types\Type;
10+
11+
/**
12+
* This object contains information about a paid media purchase.
13+
*/
14+
class PaidMediaPurchased extends Type
15+
{
16+
/** User who purchased the media */
17+
public User $from;
18+
19+
/** Bot-specified paid media payload */
20+
public string $paid_media_payload;
21+
22+
/**
23+
* @param User $from User who purchased the media
24+
* @param string $paid_media_payload Bot-specified paid media payload
25+
*/
26+
public static function make(User $from, string $paid_media_payload): static
27+
{
28+
return new static([
29+
'from' => $from,
30+
'paid_media_payload' => $paid_media_payload,
31+
]);
32+
}
33+
}

src/Telegram/TransactionPartnerUser.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,26 @@ class TransactionPartnerUser extends TransactionPartner
2727
*/
2828
public ?array $paid_media = null;
2929

30+
/** <em>Optional</em>. Bot-specified paid media payload */
31+
public ?string $paid_media_payload = null;
32+
3033
/**
3134
* @param User $user Information about the user
3235
* @param string $invoice_payload <em>Optional</em>. Bot-specified invoice payload
3336
* @param PaidMedia[] $paid_media <em>Optional</em>. Information about the paid media bought by the user
37+
* @param string $paid_media_payload <em>Optional</em>. Bot-specified paid media payload
3438
*/
35-
public static function make(User $user, ?string $invoice_payload = null, ?array $paid_media = null): static
36-
{
39+
public static function make(
40+
User $user,
41+
?string $invoice_payload = null,
42+
?array $paid_media = null,
43+
?string $paid_media_payload = null,
44+
): static {
3745
return new static([
3846
'user' => $user,
3947
'invoice_payload' => $invoice_payload,
4048
'paid_media' => $paid_media,
49+
'paid_media_payload' => $paid_media_payload,
4150
]);
4251
}
4352
}

src/Telegram/Update.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class Update extends Type
6464
/** <em>Optional</em>. New incoming pre-checkout query. Contains full information about checkout */
6565
public ?PreCheckoutQuery $pre_checkout_query = null;
6666

67+
/** <em>Optional</em>. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat */
68+
public ?PaidMediaPurchased $purchased_paid_media = null;
69+
6770
/** <em>Optional</em>. New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot */
6871
public ?Poll $poll = null;
6972

@@ -102,6 +105,7 @@ class Update extends Type
102105
* @param CallbackQuery $callback_query <em>Optional</em>. New incoming callback query
103106
* @param ShippingQuery $shipping_query <em>Optional</em>. New incoming shipping query. Only for invoices with flexible price
104107
* @param PreCheckoutQuery $pre_checkout_query <em>Optional</em>. New incoming pre-checkout query. Contains full information about checkout
108+
* @param PaidMediaPurchased $purchased_paid_media <em>Optional</em>. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat
105109
* @param Poll $poll <em>Optional</em>. New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot
106110
* @param PollAnswer $poll_answer <em>Optional</em>. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.
107111
* @param ChatMemberUpdated $my_chat_member <em>Optional</em>. The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.
@@ -127,6 +131,7 @@ public static function make(
127131
?CallbackQuery $callback_query = null,
128132
?ShippingQuery $shipping_query = null,
129133
?PreCheckoutQuery $pre_checkout_query = null,
134+
?PaidMediaPurchased $purchased_paid_media = null,
130135
?Poll $poll = null,
131136
?PollAnswer $poll_answer = null,
132137
?ChatMemberUpdated $my_chat_member = null,
@@ -152,6 +157,7 @@ public static function make(
152157
'callback_query' => $callback_query,
153158
'shipping_query' => $shipping_query,
154159
'pre_checkout_query' => $pre_checkout_query,
160+
'purchased_paid_media' => $purchased_paid_media,
155161
'poll' => $poll,
156162
'poll_answer' => $poll_answer,
157163
'my_chat_member' => $my_chat_member,

0 commit comments

Comments
 (0)