Skip to content

Commit 5aa47f1

Browse files
committed
Update code to reflect latest changes to the Bot API documentation
1 parent 786ae78 commit 5aa47f1

6 files changed

Lines changed: 231 additions & 0 deletions

File tree

src/Layers/Generated.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use Telepath\Telegram\MessageId;
4545
use Telepath\Telegram\PassportElementError;
4646
use Telepath\Telegram\Poll;
47+
use Telepath\Telegram\PreparedInlineMessage;
4748
use Telepath\Telegram\ReactionType;
4849
use Telepath\Telegram\ReplyKeyboardMarkup;
4950
use Telepath\Telegram\ReplyKeyboardRemove;
@@ -940,6 +941,23 @@ public function getUserProfilePhotos(int $user_id, ?int $offset = null, ?int $li
940941
return $this->raw('getUserProfilePhotos', func_get_args());
941942
}
942943

944+
/**
945+
* Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method <a href="https://core.telegram.org/bots/webapps#initializing-mini-apps">requestEmojiStatusAccess</a>. Returns <em>True</em> on success.
946+
*
947+
* @param int $user_id Unique identifier of the target user
948+
* @param string $emoji_status_custom_emoji_id Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.
949+
* @param int $emoji_status_expiration_date Expiration date of the emoji status, if any
950+
*
951+
* @throws TelegramException
952+
*/
953+
public function setUserEmojiStatus(
954+
int $user_id,
955+
?string $emoji_status_custom_emoji_id = null,
956+
?int $emoji_status_expiration_date = null,
957+
): bool {
958+
return $this->raw('setUserEmojiStatus', func_get_args());
959+
}
960+
943961
/**
944962
* Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a <a href="https://core.telegram.org/bots/api#file">File</a> object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling <a href="https://core.telegram.org/bots/api#getfile">getFile</a> again.
945963
*
@@ -2263,6 +2281,27 @@ public function deleteStickerSet(string $name): bool
22632281
return $this->raw('deleteStickerSet', func_get_args());
22642282
}
22652283

2284+
/**
2285+
* Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns <em>True</em> on success.
2286+
*
2287+
* @param int $user_id Unique identifier of the target user that will receive the gift
2288+
* @param string $gift_id Identifier of the gift
2289+
* @param string $text Text that will be shown along with the gift; 0-255 characters
2290+
* @param string $text_parse_mode Mode for parsing entities in the text. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
2291+
* @param MessageEntity[] $text_entities A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of <em>text_parse_mode</em>. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
2292+
*
2293+
* @throws TelegramException
2294+
*/
2295+
public function sendGift(
2296+
int $user_id,
2297+
string $gift_id,
2298+
?string $text = null,
2299+
?string $text_parse_mode = null,
2300+
?array $text_entities = null,
2301+
): bool {
2302+
return $this->raw('sendGift', func_get_args());
2303+
}
2304+
22662305
/**
22672306
* Use this method to send answers to an inline query. On success, <em>True</em> is returned.No more than 50 results per query are allowed.
22682307
*
@@ -2299,6 +2338,29 @@ public function answerWebAppQuery(string $web_app_query_id, InlineQueryResult $r
22992338
return $this->raw('answerWebAppQuery', func_get_args());
23002339
}
23012340

2341+
/**
2342+
* Stores a message that can be sent by a user of a Mini App. Returns a <a href="https://core.telegram.org/bots/api#preparedinlinemessage">PreparedInlineMessage</a> object.
2343+
*
2344+
* @param int $user_id Unique identifier of the target user that can use the prepared message
2345+
* @param InlineQueryResult $result A JSON-serialized object describing the message to be sent
2346+
* @param bool $allow_user_chats Pass <em>True</em> if the message can be sent to private chats with users
2347+
* @param bool $allow_bot_chats Pass <em>True</em> if the message can be sent to private chats with bots
2348+
* @param bool $allow_group_chats Pass <em>True</em> if the message can be sent to group and supergroup chats
2349+
* @param bool $allow_channel_chats Pass <em>True</em> if the message can be sent to channel chats
2350+
*
2351+
* @throws TelegramException
2352+
*/
2353+
public function savePreparedInlineMessage(
2354+
int $user_id,
2355+
InlineQueryResult $result,
2356+
?bool $allow_user_chats = null,
2357+
?bool $allow_bot_chats = null,
2358+
?bool $allow_group_chats = null,
2359+
?bool $allow_channel_chats = null,
2360+
): PreparedInlineMessage {
2361+
return $this->raw('savePreparedInlineMessage', func_get_args());
2362+
}
2363+
23022364
/**
23032365
* Use this method to send invoices. On success, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned.
23042366
*
@@ -2376,7 +2438,9 @@ public function sendInvoice(
23762438
* @param string $payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
23772439
* @param string $currency Three-letter ISO 4217 currency code, see <a href="https://core.telegram.org/bots/payments#supported-currencies">more on currencies</a>. Pass “XTR” for payments in <a href="https://t.me/BotNews/90">Telegram Stars</a>.
23782440
* @param LabeledPrice[] $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 <a href="https://t.me/BotNews/90">Telegram Stars</a>.
2441+
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the link will be created. For payments in <a href="https://t.me/BotNews/90">Telegram Stars</a> only.
23792442
* @param string $provider_token Payment provider token, obtained via <a href="https://t.me/botfather">@BotFather</a>. Pass an empty string for payments in <a href="https://t.me/BotNews/90">Telegram Stars</a>.
2443+
* @param int $subscription_period The number of seconds the subscription will be active for before the next payment. The currency must be set to “XTR” (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent subscriptions from the same user.
23802444
* @param int $max_tip_amount The maximum accepted amount for tips in the <em>smallest units</em> of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the <em>exp</em> parameter in <a href="https://core.telegram.org/bots/payments/currencies.json">currencies.json</a>, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in <a href="https://t.me/BotNews/90">Telegram Stars</a>.
23812445
* @param int[] $suggested_tip_amounts A JSON-serialized array of suggested amounts of tips in the <em>smallest units</em> of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed <em>max_tip_amount</em>.
23822446
* @param string $provider_data JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.
@@ -2400,7 +2464,9 @@ public function createInvoiceLink(
24002464
string $payload,
24012465
string $currency,
24022466
array $prices,
2467+
?string $business_connection_id = null,
24032468
?string $provider_token = null,
2469+
?int $subscription_period = null,
24042470
?int $max_tip_amount = null,
24052471
?array $suggested_tip_amounts = null,
24062472
?string $provider_data = null,
@@ -2481,6 +2547,23 @@ public function refundStarPayment(int $user_id, string $telegram_payment_charge_
24812547
return $this->raw('refundStarPayment', func_get_args());
24822548
}
24832549

2550+
/**
2551+
* Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns <em>True</em> on success.
2552+
*
2553+
* @param int $user_id Identifier of the user whose subscription will be edited
2554+
* @param string $telegram_payment_charge_id Telegram payment identifier for the subscription
2555+
* @param bool $is_canceled Pass <em>True</em> to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass <em>False</em> to allow the user to re-enable a subscription that was previously canceled by the bot.
2556+
*
2557+
* @throws TelegramException
2558+
*/
2559+
public function editUserStarSubscription(
2560+
int $user_id,
2561+
string $telegram_payment_charge_id,
2562+
bool $is_canceled,
2563+
): bool {
2564+
return $this->raw('editUserStarSubscription', func_get_args());
2565+
}
2566+
24842567
/**
24852568
* Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns <em>True</em> on success.
24862569
*

src/Telegram/Gift.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 represents a gift that can be sent by the bot.
13+
*/
14+
class Gift extends Type
15+
{
16+
/** Unique identifier of the gift */
17+
public string $id;
18+
19+
/** The sticker that represents the gift */
20+
public Sticker $sticker;
21+
22+
/** The number of Telegram Stars that must be paid to send the sticker */
23+
public int $star_count;
24+
25+
/** <em>Optional</em>. The total number of the gifts of this type that can be sent; for limited gifts only */
26+
public ?int $total_count = null;
27+
28+
/** <em>Optional</em>. The number of remaining gifts of this type that can be sent; for limited gifts only */
29+
public ?int $remaining_count = null;
30+
31+
/**
32+
* @param string $id Unique identifier of the gift
33+
* @param Sticker $sticker The sticker that represents the gift
34+
* @param int $star_count The number of Telegram Stars that must be paid to send the sticker
35+
* @param int $total_count <em>Optional</em>. The total number of the gifts of this type that can be sent; for limited gifts only
36+
* @param int $remaining_count <em>Optional</em>. The number of remaining gifts of this type that can be sent; for limited gifts only
37+
*/
38+
public static function make(
39+
string $id,
40+
Sticker $sticker,
41+
int $star_count,
42+
?int $total_count = null,
43+
?int $remaining_count = null,
44+
): static {
45+
return new static([
46+
'id' => $id,
47+
'sticker' => $sticker,
48+
'star_count' => $star_count,
49+
'total_count' => $total_count,
50+
'remaining_count' => $remaining_count,
51+
]);
52+
}
53+
}

src/Telegram/Gifts.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 represent a list of gifts.
13+
*/
14+
class Gifts extends Type
15+
{
16+
/**
17+
* The list of gifts
18+
*
19+
* @var Gift[]
20+
*/
21+
public array $gifts;
22+
23+
/**
24+
* @param Gift[] $gifts The list of gifts
25+
*/
26+
public static function make(array $gifts): static
27+
{
28+
return new static([
29+
'gifts' => $gifts,
30+
]);
31+
}
32+
}
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+
* Describes an inline message to be sent by a user of a Mini App.
13+
*/
14+
class PreparedInlineMessage extends Type
15+
{
16+
/** Unique identifier of the prepared message */
17+
public string $id;
18+
19+
/** Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used */
20+
public int $expiration_date;
21+
22+
/**
23+
* @param string $id Unique identifier of the prepared message
24+
* @param int $expiration_date Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used
25+
*/
26+
public static function make(string $id, int $expiration_date): static
27+
{
28+
return new static([
29+
'id' => $id,
30+
'expiration_date' => $expiration_date,
31+
]);
32+
}
33+
}

src/Telegram/SuccessfulPayment.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ class SuccessfulPayment extends Type
2828
/** Provider payment identifier */
2929
public string $provider_payment_charge_id;
3030

31+
/** <em>Optional</em>. Expiration date of the subscription, in Unix time; for recurring payments only */
32+
public ?int $subscription_expiration_date = null;
33+
34+
/** <em>Optional</em>. True, if the payment is a recurring payment for a subscription */
35+
public ?bool $is_recurring = null;
36+
37+
/** <em>Optional</em>. True, if the payment is the first payment for a subscription */
38+
public ?bool $is_first_recurring = null;
39+
3140
/** <em>Optional</em>. Identifier of the shipping option chosen by the user */
3241
public ?string $shipping_option_id = null;
3342

@@ -40,6 +49,9 @@ class SuccessfulPayment extends Type
4049
* @param string $invoice_payload Bot-specified invoice payload
4150
* @param string $telegram_payment_charge_id Telegram payment identifier
4251
* @param string $provider_payment_charge_id Provider payment identifier
52+
* @param int $subscription_expiration_date <em>Optional</em>. Expiration date of the subscription, in Unix time; for recurring payments only
53+
* @param bool $is_recurring <em>Optional</em>. True, if the payment is a recurring payment for a subscription
54+
* @param bool $is_first_recurring <em>Optional</em>. True, if the payment is the first payment for a subscription
4355
* @param string $shipping_option_id <em>Optional</em>. Identifier of the shipping option chosen by the user
4456
* @param OrderInfo $order_info <em>Optional</em>. Order information provided by the user
4557
*/
@@ -49,6 +61,9 @@ public static function make(
4961
string $invoice_payload,
5062
string $telegram_payment_charge_id,
5163
string $provider_payment_charge_id,
64+
?int $subscription_expiration_date = null,
65+
?bool $is_recurring = null,
66+
?bool $is_first_recurring = null,
5267
?string $shipping_option_id = null,
5368
?OrderInfo $order_info = null,
5469
): static {
@@ -58,6 +73,9 @@ public static function make(
5873
'invoice_payload' => $invoice_payload,
5974
'telegram_payment_charge_id' => $telegram_payment_charge_id,
6075
'provider_payment_charge_id' => $provider_payment_charge_id,
76+
'subscription_expiration_date' => $subscription_expiration_date,
77+
'is_recurring' => $is_recurring,
78+
'is_first_recurring' => $is_first_recurring,
6179
'shipping_option_id' => $shipping_option_id,
6280
'order_info' => $order_info,
6381
]);

src/Telegram/TransactionPartnerUser.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class TransactionPartnerUser extends TransactionPartner
2020
/** <em>Optional</em>. Bot-specified invoice payload */
2121
public ?string $invoice_payload = null;
2222

23+
/** <em>Optional</em>. The duration of the paid subscription */
24+
public ?int $subscription_period = null;
25+
2326
/**
2427
* <em>Optional</em>. Information about the paid media bought by the user
2528
*
@@ -30,23 +33,32 @@ class TransactionPartnerUser extends TransactionPartner
3033
/** <em>Optional</em>. Bot-specified paid media payload */
3134
public ?string $paid_media_payload = null;
3235

36+
/** <em>Optional</em>. The gift sent to the user by the bot */
37+
public ?string $gift = null;
38+
3339
/**
3440
* @param User $user Information about the user
3541
* @param string $invoice_payload <em>Optional</em>. Bot-specified invoice payload
42+
* @param int $subscription_period <em>Optional</em>. The duration of the paid subscription
3643
* @param PaidMedia[] $paid_media <em>Optional</em>. Information about the paid media bought by the user
3744
* @param string $paid_media_payload <em>Optional</em>. Bot-specified paid media payload
45+
* @param string $gift <em>Optional</em>. The gift sent to the user by the bot
3846
*/
3947
public static function make(
4048
User $user,
4149
?string $invoice_payload = null,
50+
?int $subscription_period = null,
4251
?array $paid_media = null,
4352
?string $paid_media_payload = null,
53+
?string $gift = null,
4454
): static {
4555
return new static([
4656
'user' => $user,
4757
'invoice_payload' => $invoice_payload,
58+
'subscription_period' => $subscription_period,
4859
'paid_media' => $paid_media,
4960
'paid_media_payload' => $paid_media_payload,
61+
'gift' => $gift,
5062
]);
5163
}
5264
}

0 commit comments

Comments
 (0)