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 Feb 20, 2025
1 parent 375309e commit 4fada31
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 20 deletions.
20 changes: 15 additions & 5 deletions src/Layers/Generated.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public function sendMessage(
* @param int|string $from_chat_id Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
* @param int $message_id Message identifier in the chat specified in <em>from_chat_id</em>
* @param int $message_thread_id Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
* @param int $video_start_timestamp New start timestamp for the forwarded video in 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 forwarded message from forwarding and saving
*
Expand All @@ -215,6 +216,7 @@ public function forwardMessage(
int|string $from_chat_id,
int $message_id,
?int $message_thread_id = null,
?int $video_start_timestamp = null,
?bool $disable_notification = null,
?bool $protect_content = null,
): Message {
Expand Down Expand Up @@ -251,6 +253,7 @@ public function forwardMessages(
* @param int|string $from_chat_id Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
* @param int $message_id Message identifier in the chat specified in <em>from_chat_id</em>
* @param int $message_thread_id Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
* @param int $video_start_timestamp New start timestamp for the copied video in the message
* @param string $caption New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
* @param ParseMode|string $parse_mode Mode for parsing entities in the new caption. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details.
* @param MessageEntity[] $caption_entities A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of <em>parse_mode</em>
Expand All @@ -268,6 +271,7 @@ public function copyMessage(
int|string $from_chat_id,
int $message_id,
?int $message_thread_id = null,
?int $video_start_timestamp = null,
?string $caption = null,
ParseMode|string|null $parse_mode = null,
?array $caption_entities = null,
Expand Down Expand Up @@ -444,6 +448,8 @@ public function sendDocument(
* @param int $width Video width
* @param int $height Video height
* @param InputFile|string $thumbnail Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. <a href="https://core.telegram.org/bots/api#sending-files">More information on Sending Files &#xBB;</a>
* @param InputFile|string $cover Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. <a href="https://core.telegram.org/bots/api#sending-files">More information on Sending Files &#xBB;</a>
* @param int $start_timestamp Start timestamp for the video in the message
* @param string $caption Video caption (may also be used when resending videos by <em>file_id</em>), 0-1024 characters after entities parsing
* @param ParseMode|string $parse_mode Mode for parsing entities in the video caption. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details.
* @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>
Expand All @@ -468,6 +474,8 @@ public function sendVideo(
?int $width = null,
?int $height = null,
InputFile|string|null $thumbnail = null,
InputFile|string|null $cover = null,
?int $start_timestamp = null,
?string $caption = null,
ParseMode|string|null $parse_mode = null,
?array $caption_entities = null,
Expand Down Expand Up @@ -909,7 +917,7 @@ public function sendChatAction(
}

/**
* Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns <em>True</em> on success.
* Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns <em>True</em> on success.
*
* @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param int $message_id Identifier of the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead.
Expand Down Expand Up @@ -2282,20 +2290,22 @@ public function deleteStickerSet(string $name): bool
}

/**
* 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.
* Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receiver. 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 int $user_id Required if <em>chat_id</em> is not specified. Unique identifier of the target user who will receive the gift.
* @param int|string $chat_id Required if <em>user_id</em> is not specified. Unique identifier for the chat or username of the channel (in the format @channelusername) that will receive the gift.
* @param bool $pay_for_upgrade Pass <em>True</em> to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver
* @param string $text Text that will be shown along with the gift; 0-255 characters
* @param string $text Text that will be shown along with the gift; 0-128 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,
?int $user_id = null,
int|string|null $chat_id = null,
?bool $pay_for_upgrade = null,
?string $text = null,
?string $text_parse_mode = null,
Expand Down
6 changes: 6 additions & 0 deletions src/Telegram/ChatFullInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class ChatFullInfo extends Type
/** <em>Optional</em>. Default chat member permissions, for groups and supergroups */
public ?ChatPermissions $permissions = null;

/** <em>Optional</em>. <em>True</em>, if gifts can be sent to the chat */
public ?bool $can_send_gift = null;

/** <em>Optional</em>. <em>True</em>, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. */
public ?bool $can_send_paid_media = null;

Expand Down Expand Up @@ -185,6 +188,7 @@ class ChatFullInfo extends Type
* @param string $invite_link <em>Optional</em>. Primary invite link, for groups, supergroups and channel chats
* @param Message $pinned_message <em>Optional</em>. The most recent pinned message (by sending date)
* @param ChatPermissions $permissions <em>Optional</em>. Default chat member permissions, for groups and supergroups
* @param bool $can_send_gift <em>Optional</em>. <em>True</em>, if gifts can be sent to the chat
* @param bool $can_send_paid_media <em>Optional</em>. <em>True</em>, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats.
* @param int $slow_mode_delay <em>Optional</em>. For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds
* @param int $unrestrict_boost_count <em>Optional</em>. For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions
Expand Down Expand Up @@ -231,6 +235,7 @@ public static function make(
?string $invite_link = null,
?Message $pinned_message = null,
?ChatPermissions $permissions = null,
?bool $can_send_gift = null,
?bool $can_send_paid_media = null,
?int $slow_mode_delay = null,
?int $unrestrict_boost_count = null,
Expand Down Expand Up @@ -277,6 +282,7 @@ public static function make(
'invite_link' => $invite_link,
'pinned_message' => $pinned_message,
'permissions' => $permissions,
'can_send_gift' => $can_send_gift,
'can_send_paid_media' => $can_send_paid_media,
'slow_mode_delay' => $slow_mode_delay,
'unrestrict_boost_count' => $unrestrict_boost_count,
Expand Down
6 changes: 3 additions & 3 deletions src/Telegram/InputMediaAnimation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InputMediaAnimation extends InputMedia
public string $type = 'animation';

/** <em>Optional</em>. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. <a href="https://core.telegram.org/bots/api#sending-files">More information on Sending Files &#xBB;</a> */
public InputFile|string|null $thumbnail = null;
public string|InputFile|null $thumbnail = null;

/** <em>Optional</em>. Pass <em>True</em>, if the caption must be shown above the message media */
public ?bool $show_caption_above_media = null;
Expand All @@ -36,7 +36,7 @@ class InputMediaAnimation extends InputMedia

/**
* @param string|InputFile $media File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. <a href="https://core.telegram.org/bots/api#sending-files">More information on Sending Files &#xBB;</a>
* @param InputFile|string $thumbnail <em>Optional</em>. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. <a href="https://core.telegram.org/bots/api#sending-files">More information on Sending Files &#xBB;</a>
* @param string|InputFile $thumbnail <em>Optional</em>. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. <a href="https://core.telegram.org/bots/api#sending-files">More information on Sending Files &#xBB;</a>
* @param string $caption <em>Optional</em>. Caption of the animation to be sent, 0-1024 characters after entities parsing
* @param string $parse_mode <em>Optional</em>. Mode for parsing entities in the animation caption. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details.
* @param MessageEntity[] $caption_entities <em>Optional</em>. List of special entities that appear in the caption, which can be specified instead of <em>parse_mode</em>
Expand All @@ -48,7 +48,7 @@ class InputMediaAnimation extends InputMedia
*/
public static function make(
string|InputFile $media,
InputFile|string|null $thumbnail = null,
string|InputFile|null $thumbnail = null,
?string $caption = null,
?string $parse_mode = null,
?array $caption_entities = null,
Expand Down
6 changes: 3 additions & 3 deletions src/Telegram/InputMediaAudio.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InputMediaAudio extends InputMedia
public string $type = 'audio';

/** <em>Optional</em>. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. <a href="https://core.telegram.org/bots/api#sending-files">More information on Sending Files &#xBB;</a> */
public InputFile|string|null $thumbnail = null;
public string|InputFile|null $thumbnail = null;

/** <em>Optional</em>. Duration of the audio in seconds */
public ?int $duration = null;
Expand All @@ -30,7 +30,7 @@ class InputMediaAudio extends InputMedia

/**
* @param string|InputFile $media File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. <a href="https://core.telegram.org/bots/api#sending-files">More information on Sending Files &#xBB;</a>
* @param InputFile|string $thumbnail <em>Optional</em>. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. <a href="https://core.telegram.org/bots/api#sending-files">More information on Sending Files &#xBB;</a>
* @param string|InputFile $thumbnail <em>Optional</em>. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. <a href="https://core.telegram.org/bots/api#sending-files">More information on Sending Files &#xBB;</a>
* @param string $caption <em>Optional</em>. Caption of the audio to be sent, 0-1024 characters after entities parsing
* @param string $parse_mode <em>Optional</em>. Mode for parsing entities in the audio caption. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details.
* @param MessageEntity[] $caption_entities <em>Optional</em>. List of special entities that appear in the caption, which can be specified instead of <em>parse_mode</em>
Expand All @@ -40,7 +40,7 @@ class InputMediaAudio extends InputMedia
*/
public static function make(
string|InputFile $media,
InputFile|string|null $thumbnail = null,
string|InputFile|null $thumbnail = null,
?string $caption = null,
?string $parse_mode = null,
?array $caption_entities = null,
Expand Down
Loading

0 comments on commit 4fada31

Please sign in to comment.