Skip to content

Commit 786ae78

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

10 files changed

Lines changed: 112 additions & 7 deletions

src/Layers/Generated.php

Lines changed: 39 additions & 1 deletion
Large diffs are not rendered by default.

src/Telegram/CopyTextButton.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 an inline keyboard button that copies specified text to the clipboard.
13+
*/
14+
class CopyTextButton extends Type
15+
{
16+
/** The text to be copied to the clipboard; 1-256 characters */
17+
public string $text;
18+
19+
/**
20+
* @param string $text The text to be copied to the clipboard; 1-256 characters
21+
*/
22+
public static function make(string $text): static
23+
{
24+
return new static([
25+
'text' => $text,
26+
]);
27+
}
28+
}

src/Telegram/InlineKeyboardButton.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class InlineKeyboardButton extends Type
3737
/** <em>Optional</em>. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. Not supported for messages sent on behalf of a Telegram Business account. */
3838
public ?SwitchInlineQueryChosenChat $switch_inline_query_chosen_chat = null;
3939

40+
/** <em>Optional</em>. Description of the button that copies the specified text to the clipboard. */
41+
public ?CopyTextButton $copy_text = null;
42+
4043
/** <em>Optional</em>. Description of the game that will be launched when the user presses the button.NOTE: This type of button must always be the first button in the first row. */
4144
public ?CallbackGame $callback_game = null;
4245

@@ -52,6 +55,7 @@ class InlineKeyboardButton extends Type
5255
* @param string $switch_inline_query <em>Optional</em>. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted. Not supported for messages sent on behalf of a Telegram Business account.
5356
* @param string $switch_inline_query_current_chat <em>Optional</em>. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted.This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options. Not supported in channels and for messages sent on behalf of a Telegram Business account.
5457
* @param SwitchInlineQueryChosenChat $switch_inline_query_chosen_chat <em>Optional</em>. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. Not supported for messages sent on behalf of a Telegram Business account.
58+
* @param CopyTextButton $copy_text <em>Optional</em>. Description of the button that copies the specified text to the clipboard.
5559
* @param CallbackGame $callback_game <em>Optional</em>. Description of the game that will be launched when the user presses the button.NOTE: This type of button must always be the first button in the first row.
5660
* @param bool $pay <em>Optional</em>. Specify <em>True</em>, to send a <a href="https://core.telegram.org/bots/api#payments">Pay button</a>. Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon.NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages.
5761
*/
@@ -64,6 +68,7 @@ public static function make(
6468
?string $switch_inline_query = null,
6569
?string $switch_inline_query_current_chat = null,
6670
?SwitchInlineQueryChosenChat $switch_inline_query_chosen_chat = null,
71+
?CopyTextButton $copy_text = null,
6772
?CallbackGame $callback_game = null,
6873
?bool $pay = null,
6974
): static {
@@ -76,6 +81,7 @@ public static function make(
7681
'switch_inline_query' => $switch_inline_query,
7782
'switch_inline_query_current_chat' => $switch_inline_query_current_chat,
7883
'switch_inline_query_chosen_chat' => $switch_inline_query_chosen_chat,
84+
'copy_text' => $copy_text,
7985
'callback_game' => $callback_game,
8086
'pay' => $pay,
8187
]);

src/Telegram/MaybeInaccessibleMessage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
abstract class MaybeInaccessibleMessage extends Type implements Factory
1717
{
18-
/** Unique message identifier inside this chat */
18+
/** Unique message identifier inside this chat. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent */
1919
public int $message_id;
2020

2121
/** Date the message was sent in Unix time. It is always a positive number, representing a valid date. */

src/Telegram/Message.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class Message extends MaybeInaccessibleMessage
282282
public ?InlineKeyboardMarkup $reply_markup = null;
283283

284284
/**
285-
* @param int $message_id Unique message identifier inside this chat
285+
* @param int $message_id Unique message identifier inside this chat. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent
286286
* @param int $date Date the message was sent in Unix time. It is always a positive number, representing a valid date.
287287
* @param Chat $chat Chat the message belongs to
288288
* @param int $message_thread_id <em>Optional</em>. Unique identifier of a message thread to which the message belongs; for supergroups only

src/Telegram/MessageEntity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
class MessageEntity extends Type
1515
{
16-
/** Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (<em>italic text</em>), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “expandable_blockquote” (collapsed-by-default block quotation), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users <a href="https://telegram.org/blog/edit#new-mentions">without usernames</a>), “custom_emoji” (for inline custom emoji stickers) */
16+
/** Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag or #hashtag@chatusername), “cashtag” ($USD or $USD@chatusername), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (<em>italic text</em>), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “expandable_blockquote” (collapsed-by-default block quotation), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users <a href="https://telegram.org/blog/edit#new-mentions">without usernames</a>), “custom_emoji” (for inline custom emoji stickers) */
1717
public string $type;
1818

1919
/** Offset in <a href="https://core.telegram.org/api/entities#entity-length">UTF-16 code units</a> to the start of the entity */
@@ -35,7 +35,7 @@ class MessageEntity extends Type
3535
public ?string $custom_emoji_id = null;
3636

3737
/**
38-
* @param string $type Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (<em>italic text</em>), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “expandable_blockquote” (collapsed-by-default block quotation), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users <a href="https://telegram.org/blog/edit#new-mentions">without usernames</a>), “custom_emoji” (for inline custom emoji stickers)
38+
* @param string $type Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag or #hashtag@chatusername), “cashtag” ($USD or $USD@chatusername), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (<em>italic text</em>), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “expandable_blockquote” (collapsed-by-default block quotation), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users <a href="https://telegram.org/blog/edit#new-mentions">without usernames</a>), “custom_emoji” (for inline custom emoji stickers)
3939
* @param int $offset Offset in <a href="https://core.telegram.org/api/entities#entity-length">UTF-16 code units</a> to the start of the entity
4040
* @param int $length Length of the entity in <a href="https://core.telegram.org/api/entities#entity-length">UTF-16 code units</a>
4141
* @param string $url <em>Optional</em>. For “text_link” only, URL that will be opened after user taps on the text

src/Telegram/MessageId.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
*/
1414
class MessageId extends Type
1515
{
16-
/** Unique message identifier */
16+
/** Unique message identifier. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent */
1717
public int $message_id;
1818

1919
/**
20-
* @param int $message_id Unique message identifier
20+
* @param int $message_id Unique message identifier. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent
2121
*/
2222
public static function make(int $message_id): static
2323
{

src/Telegram/TransactionPartner.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public static function factory(array $data, ?Bot $bot = null): self
2424
'user' => new TransactionPartnerUser($data, $bot),
2525
'fragment' => new TransactionPartnerFragment($data, $bot),
2626
'telegram_ads' => new TransactionPartnerTelegramAds($data, $bot),
27+
'telegram_api' => new TransactionPartnerTelegramApi($data, $bot),
2728
'other' => new TransactionPartnerOther($data, $bot),
2829
};
2930
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated.
5+
*/
6+
7+
namespace Telepath\Telegram;
8+
9+
/**
10+
* Describes a transaction with payment for paid broadcasting.
11+
*/
12+
class TransactionPartnerTelegramApi extends TransactionPartner
13+
{
14+
/** Type of the transaction partner, always “telegram_api” */
15+
public string $type = 'telegram_api';
16+
17+
/** The number of successful requests that exceeded regular limits and were therefore billed */
18+
public int $request_count;
19+
20+
/**
21+
* @param int $request_count The number of successful requests that exceeded regular limits and were therefore billed
22+
*/
23+
public static function make(int $request_count): static
24+
{
25+
return new static([
26+
'request_count' => $request_count,
27+
]);
28+
}
29+
}

src/Types/Extensions/RepliesToMessage.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ trait RepliesToMessage
2626
* @param LinkPreviewOptions $link_preview_options Link preview generation options for the message
2727
* @param bool $disable_notification Sends the message <a href="https://telegram.org/blog/channels-2-0#silent-messages">silently</a>. Users will receive a notification with no sound.
2828
* @param bool $protect_content Protects the contents of the sent message from forwarding and saving
29+
* @param bool $allow_paid_broadcast Pass <em>True</em> to allow up to 1000 messages per second, ignoring <a href="https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once">broadcasting limits</a> for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
2930
* @param string $message_effect_id Unique identifier of the message effect to be added to the message; for private chats only
3031
* @param ReplyParameters $reply_parameters Description of the message to reply to
3132
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup Additional interface options. A JSON-serialized object for an <a href="https://core.telegram.org/bots/features#inline-keyboards">inline keyboard</a>, <a href="https://core.telegram.org/bots/features#keyboards">custom reply keyboard</a>, instructions to remove a reply keyboard or to force a reply from the user
@@ -39,6 +40,7 @@ public function replyToUser(
3940
?LinkPreviewOptions $link_preview_options = null,
4041
?bool $disable_notification = null,
4142
?bool $protect_content = null,
43+
?bool $allow_paid_broadcast = null,
4244
?string $message_effect_id = null,
4345
?ReplyParameters $reply_parameters = null,
4446
InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null,
@@ -53,6 +55,7 @@ public function replyToUser(
5355
link_preview_options: $link_preview_options,
5456
disable_notification: $disable_notification,
5557
protect_content: $protect_content,
58+
allow_paid_broadcast: $allow_paid_broadcast,
5659
message_effect_id: $message_effect_id,
5760
reply_parameters: $reply_parameters,
5861
reply_markup: $reply_markup,

0 commit comments

Comments
 (0)