Skip to content

Commit

Permalink
Update code to reflect latest changes to the Bot API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TiiFuchs committed Nov 20, 2024
1 parent 786ae78 commit 5aa47f1
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 0 deletions.
83 changes: 83 additions & 0 deletions src/Layers/Generated.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use Telepath\Telegram\MessageId;
use Telepath\Telegram\PassportElementError;
use Telepath\Telegram\Poll;
use Telepath\Telegram\PreparedInlineMessage;
use Telepath\Telegram\ReactionType;
use Telepath\Telegram\ReplyKeyboardMarkup;
use Telepath\Telegram\ReplyKeyboardRemove;
Expand Down Expand Up @@ -940,6 +941,23 @@ public function getUserProfilePhotos(int $user_id, ?int $offset = null, ?int $li
return $this->raw('getUserProfilePhotos', func_get_args());
}

/**
* 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.
*
* @param int $user_id Unique identifier of the target user
* @param string $emoji_status_custom_emoji_id Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.
* @param int $emoji_status_expiration_date Expiration date of the emoji status, if any
*
* @throws TelegramException
*/
public function setUserEmojiStatus(
int $user_id,
?string $emoji_status_custom_emoji_id = null,
?int $emoji_status_expiration_date = null,
): bool {
return $this->raw('setUserEmojiStatus', func_get_args());
}

/**
* 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.
*
Expand Down Expand Up @@ -2263,6 +2281,27 @@ public function deleteStickerSet(string $name): bool
return $this->raw('deleteStickerSet', func_get_args());
}

/**
* 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.
*
* @param int $user_id Unique identifier of the target user that will receive the gift
* @param string $gift_id Identifier of the gift
* @param string $text Text that will be shown along with the gift; 0-255 characters
* @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.
* @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.
*
* @throws TelegramException
*/
public function sendGift(
int $user_id,
string $gift_id,
?string $text = null,
?string $text_parse_mode = null,
?array $text_entities = null,
): bool {
return $this->raw('sendGift', func_get_args());
}

/**
* 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.
*
Expand Down Expand Up @@ -2299,6 +2338,29 @@ public function answerWebAppQuery(string $web_app_query_id, InlineQueryResult $r
return $this->raw('answerWebAppQuery', func_get_args());
}

/**
* 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.
*
* @param int $user_id Unique identifier of the target user that can use the prepared message
* @param InlineQueryResult $result A JSON-serialized object describing the message to be sent
* @param bool $allow_user_chats Pass <em>True</em> if the message can be sent to private chats with users
* @param bool $allow_bot_chats Pass <em>True</em> if the message can be sent to private chats with bots
* @param bool $allow_group_chats Pass <em>True</em> if the message can be sent to group and supergroup chats
* @param bool $allow_channel_chats Pass <em>True</em> if the message can be sent to channel chats
*
* @throws TelegramException
*/
public function savePreparedInlineMessage(
int $user_id,
InlineQueryResult $result,
?bool $allow_user_chats = null,
?bool $allow_bot_chats = null,
?bool $allow_group_chats = null,
?bool $allow_channel_chats = null,
): PreparedInlineMessage {
return $this->raw('savePreparedInlineMessage', func_get_args());
}

/**
* Use this method to send invoices. On success, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned.
*
Expand Down Expand Up @@ -2376,7 +2438,9 @@ public function sendInvoice(
* @param string $payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.
* @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>.
* @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>.
* @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.
* @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>.
* @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.
* @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>.
* @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>.
* @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.
Expand All @@ -2400,7 +2464,9 @@ public function createInvoiceLink(
string $payload,
string $currency,
array $prices,
?string $business_connection_id = null,
?string $provider_token = null,
?int $subscription_period = null,
?int $max_tip_amount = null,
?array $suggested_tip_amounts = null,
?string $provider_data = null,
Expand Down Expand Up @@ -2481,6 +2547,23 @@ public function refundStarPayment(int $user_id, string $telegram_payment_charge_
return $this->raw('refundStarPayment', func_get_args());
}

/**
* Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns <em>True</em> on success.
*
* @param int $user_id Identifier of the user whose subscription will be edited
* @param string $telegram_payment_charge_id Telegram payment identifier for the subscription
* @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.
*
* @throws TelegramException
*/
public function editUserStarSubscription(
int $user_id,
string $telegram_payment_charge_id,
bool $is_canceled,
): bool {
return $this->raw('editUserStarSubscription', func_get_args());
}

/**
* 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.
*
Expand Down
53 changes: 53 additions & 0 deletions src/Telegram/Gift.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/**
* This file is auto-generated.
*/

namespace Telepath\Telegram;

use Telepath\Types\Type;

/**
* This object represents a gift that can be sent by the bot.
*/
class Gift extends Type
{
/** Unique identifier of the gift */
public string $id;

/** The sticker that represents the gift */
public Sticker $sticker;

/** The number of Telegram Stars that must be paid to send the sticker */
public int $star_count;

/** <em>Optional</em>. The total number of the gifts of this type that can be sent; for limited gifts only */
public ?int $total_count = null;

/** <em>Optional</em>. The number of remaining gifts of this type that can be sent; for limited gifts only */
public ?int $remaining_count = null;

/**
* @param string $id Unique identifier of the gift
* @param Sticker $sticker The sticker that represents the gift
* @param int $star_count The number of Telegram Stars that must be paid to send the sticker
* @param int $total_count <em>Optional</em>. The total number of the gifts of this type that can be sent; for limited gifts only
* @param int $remaining_count <em>Optional</em>. The number of remaining gifts of this type that can be sent; for limited gifts only
*/
public static function make(
string $id,
Sticker $sticker,
int $star_count,
?int $total_count = null,
?int $remaining_count = null,
): static {
return new static([
'id' => $id,
'sticker' => $sticker,
'star_count' => $star_count,
'total_count' => $total_count,
'remaining_count' => $remaining_count,
]);
}
}
32 changes: 32 additions & 0 deletions src/Telegram/Gifts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/**
* This file is auto-generated.
*/

namespace Telepath\Telegram;

use Telepath\Types\Type;

/**
* This object represent a list of gifts.
*/
class Gifts extends Type
{
/**
* The list of gifts
*
* @var Gift[]
*/
public array $gifts;

/**
* @param Gift[] $gifts The list of gifts
*/
public static function make(array $gifts): static
{
return new static([
'gifts' => $gifts,
]);
}
}
33 changes: 33 additions & 0 deletions src/Telegram/PreparedInlineMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* This file is auto-generated.
*/

namespace Telepath\Telegram;

use Telepath\Types\Type;

/**
* Describes an inline message to be sent by a user of a Mini App.
*/
class PreparedInlineMessage extends Type
{
/** Unique identifier of the prepared message */
public string $id;

/** Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used */
public int $expiration_date;

/**
* @param string $id Unique identifier of the prepared message
* @param int $expiration_date Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used
*/
public static function make(string $id, int $expiration_date): static
{
return new static([
'id' => $id,
'expiration_date' => $expiration_date,
]);
}
}
18 changes: 18 additions & 0 deletions src/Telegram/SuccessfulPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ class SuccessfulPayment extends Type
/** Provider payment identifier */
public string $provider_payment_charge_id;

/** <em>Optional</em>. Expiration date of the subscription, in Unix time; for recurring payments only */
public ?int $subscription_expiration_date = null;

/** <em>Optional</em>. True, if the payment is a recurring payment for a subscription */
public ?bool $is_recurring = null;

/** <em>Optional</em>. True, if the payment is the first payment for a subscription */
public ?bool $is_first_recurring = null;

/** <em>Optional</em>. Identifier of the shipping option chosen by the user */
public ?string $shipping_option_id = null;

Expand All @@ -40,6 +49,9 @@ class SuccessfulPayment extends Type
* @param string $invoice_payload Bot-specified invoice payload
* @param string $telegram_payment_charge_id Telegram payment identifier
* @param string $provider_payment_charge_id Provider payment identifier
* @param int $subscription_expiration_date <em>Optional</em>. Expiration date of the subscription, in Unix time; for recurring payments only
* @param bool $is_recurring <em>Optional</em>. True, if the payment is a recurring payment for a subscription
* @param bool $is_first_recurring <em>Optional</em>. True, if the payment is the first payment for a subscription
* @param string $shipping_option_id <em>Optional</em>. Identifier of the shipping option chosen by the user
* @param OrderInfo $order_info <em>Optional</em>. Order information provided by the user
*/
Expand All @@ -49,6 +61,9 @@ public static function make(
string $invoice_payload,
string $telegram_payment_charge_id,
string $provider_payment_charge_id,
?int $subscription_expiration_date = null,
?bool $is_recurring = null,
?bool $is_first_recurring = null,
?string $shipping_option_id = null,
?OrderInfo $order_info = null,
): static {
Expand All @@ -58,6 +73,9 @@ public static function make(
'invoice_payload' => $invoice_payload,
'telegram_payment_charge_id' => $telegram_payment_charge_id,
'provider_payment_charge_id' => $provider_payment_charge_id,
'subscription_expiration_date' => $subscription_expiration_date,
'is_recurring' => $is_recurring,
'is_first_recurring' => $is_first_recurring,
'shipping_option_id' => $shipping_option_id,
'order_info' => $order_info,
]);
Expand Down
12 changes: 12 additions & 0 deletions src/Telegram/TransactionPartnerUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class TransactionPartnerUser extends TransactionPartner
/** <em>Optional</em>. Bot-specified invoice payload */
public ?string $invoice_payload = null;

/** <em>Optional</em>. The duration of the paid subscription */
public ?int $subscription_period = null;

/**
* <em>Optional</em>. Information about the paid media bought by the user
*
Expand All @@ -30,23 +33,32 @@ class TransactionPartnerUser extends TransactionPartner
/** <em>Optional</em>. Bot-specified paid media payload */
public ?string $paid_media_payload = null;

/** <em>Optional</em>. The gift sent to the user by the bot */
public ?string $gift = null;

/**
* @param User $user Information about the user
* @param string $invoice_payload <em>Optional</em>. Bot-specified invoice payload
* @param int $subscription_period <em>Optional</em>. The duration of the paid subscription
* @param PaidMedia[] $paid_media <em>Optional</em>. Information about the paid media bought by the user
* @param string $paid_media_payload <em>Optional</em>. Bot-specified paid media payload
* @param string $gift <em>Optional</em>. The gift sent to the user by the bot
*/
public static function make(
User $user,
?string $invoice_payload = null,
?int $subscription_period = null,
?array $paid_media = null,
?string $paid_media_payload = null,
?string $gift = null,
): static {
return new static([
'user' => $user,
'invoice_payload' => $invoice_payload,
'subscription_period' => $subscription_period,
'paid_media' => $paid_media,
'paid_media_payload' => $paid_media_payload,
'gift' => $gift,
]);
}
}

0 comments on commit 5aa47f1

Please sign in to comment.