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 12, 2024
1 parent 573a3b9 commit 786ae78
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 7 deletions.
40 changes: 39 additions & 1 deletion src/Layers/Generated.php

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions src/Telegram/CopyTextButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

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

namespace Telepath\Telegram;

use Telepath\Types\Type;

/**
* This object represents an inline keyboard button that copies specified text to the clipboard.
*/
class CopyTextButton extends Type
{
/** The text to be copied to the clipboard; 1-256 characters */
public string $text;

/**
* @param string $text The text to be copied to the clipboard; 1-256 characters
*/
public static function make(string $text): static
{
return new static([
'text' => $text,
]);
}
}
6 changes: 6 additions & 0 deletions src/Telegram/InlineKeyboardButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class InlineKeyboardButton extends Type
/** <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. */
public ?SwitchInlineQueryChosenChat $switch_inline_query_chosen_chat = null;

/** <em>Optional</em>. Description of the button that copies the specified text to the clipboard. */
public ?CopyTextButton $copy_text = null;

/** <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. */
public ?CallbackGame $callback_game = null;

Expand All @@ -52,6 +55,7 @@ class InlineKeyboardButton extends Type
* @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.
* @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.
* @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.
* @param CopyTextButton $copy_text <em>Optional</em>. Description of the button that copies the specified text to the clipboard.
* @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.
* @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.
*/
Expand All @@ -64,6 +68,7 @@ public static function make(
?string $switch_inline_query = null,
?string $switch_inline_query_current_chat = null,
?SwitchInlineQueryChosenChat $switch_inline_query_chosen_chat = null,
?CopyTextButton $copy_text = null,
?CallbackGame $callback_game = null,
?bool $pay = null,
): static {
Expand All @@ -76,6 +81,7 @@ public static function make(
'switch_inline_query' => $switch_inline_query,
'switch_inline_query_current_chat' => $switch_inline_query_current_chat,
'switch_inline_query_chosen_chat' => $switch_inline_query_chosen_chat,
'copy_text' => $copy_text,
'callback_game' => $callback_game,
'pay' => $pay,
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Telegram/MaybeInaccessibleMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
abstract class MaybeInaccessibleMessage extends Type implements Factory
{
/** Unique message identifier inside this chat */
/** 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 */
public int $message_id;

/** Date the message was sent in Unix time. It is always a positive number, representing a valid date. */
Expand Down
2 changes: 1 addition & 1 deletion src/Telegram/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class Message extends MaybeInaccessibleMessage
public ?InlineKeyboardMarkup $reply_markup = null;

/**
* @param int $message_id Unique message identifier inside this chat
* @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
* @param int $date Date the message was sent in Unix time. It is always a positive number, representing a valid date.
* @param Chat $chat Chat the message belongs to
* @param int $message_thread_id <em>Optional</em>. Unique identifier of a message thread to which the message belongs; for supergroups only
Expand Down
4 changes: 2 additions & 2 deletions src/Telegram/MessageEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class MessageEntity extends Type
{
/** Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” ([email protected]), “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) */
/** 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” ([email protected]), “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) */
public string $type;

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

/**
* @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” ([email protected]), “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)
* @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” ([email protected]), “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)
* @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
* @param int $length Length of the entity in <a href="https://core.telegram.org/api/entities#entity-length">UTF-16 code units</a>
* @param string $url <em>Optional</em>. For “text_link” only, URL that will be opened after user taps on the text
Expand Down
4 changes: 2 additions & 2 deletions src/Telegram/MessageId.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
*/
class MessageId extends Type
{
/** Unique message identifier */
/** 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 */
public int $message_id;

/**
* @param int $message_id Unique message identifier
* @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
*/
public static function make(int $message_id): static
{
Expand Down
1 change: 1 addition & 0 deletions src/Telegram/TransactionPartner.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static function factory(array $data, ?Bot $bot = null): self
'user' => new TransactionPartnerUser($data, $bot),
'fragment' => new TransactionPartnerFragment($data, $bot),
'telegram_ads' => new TransactionPartnerTelegramAds($data, $bot),
'telegram_api' => new TransactionPartnerTelegramApi($data, $bot),
'other' => new TransactionPartnerOther($data, $bot),
};
}
Expand Down
29 changes: 29 additions & 0 deletions src/Telegram/TransactionPartnerTelegramApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

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

namespace Telepath\Telegram;

/**
* Describes a transaction with payment for paid broadcasting.
*/
class TransactionPartnerTelegramApi extends TransactionPartner
{
/** Type of the transaction partner, always “telegram_api” */
public string $type = 'telegram_api';

/** The number of successful requests that exceeded regular limits and were therefore billed */
public int $request_count;

/**
* @param int $request_count The number of successful requests that exceeded regular limits and were therefore billed
*/
public static function make(int $request_count): static
{
return new static([
'request_count' => $request_count,
]);
}
}
3 changes: 3 additions & 0 deletions src/Types/Extensions/RepliesToMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ trait RepliesToMessage
* @param LinkPreviewOptions $link_preview_options Link preview generation options for the message
* @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.
* @param bool $protect_content Protects the contents of the sent message from forwarding and saving
* @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
* @param string $message_effect_id Unique identifier of the message effect to be added to the message; for private chats only
* @param ReplyParameters $reply_parameters Description of the message to reply to
* @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
Expand All @@ -39,6 +40,7 @@ public function replyToUser(
?LinkPreviewOptions $link_preview_options = null,
?bool $disable_notification = null,
?bool $protect_content = null,
?bool $allow_paid_broadcast = null,
?string $message_effect_id = null,
?ReplyParameters $reply_parameters = null,
InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null,
Expand All @@ -53,6 +55,7 @@ public function replyToUser(
link_preview_options: $link_preview_options,
disable_notification: $disable_notification,
protect_content: $protect_content,
allow_paid_broadcast: $allow_paid_broadcast,
message_effect_id: $message_effect_id,
reply_parameters: $reply_parameters,
reply_markup: $reply_markup,
Expand Down

0 comments on commit 786ae78

Please sign in to comment.