Skip to content

Commit 7e25039

Browse files
committed
Update code to reflect latest changes to the Bot API documentation
1 parent a33f44b commit 7e25039

6 files changed

Lines changed: 87 additions & 12 deletions

File tree

src/Layers/Generated.php

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,12 @@ public function sendVideoNote(
591591
}
592592

593593
/**
594-
* Use this method to send paid media to channel chats. On success, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned.
594+
* Use this method to send paid media. On success, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned.
595595
*
596-
* @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
596+
* @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.
597597
* @param int $star_count The number of Telegram Stars that must be paid to buy access to the media
598598
* @param InputPaidMedia[] $media A JSON-serialized array describing the media to be sent; up to 10 items
599+
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the message will be sent
599600
* @param string $caption Media caption, 0-1024 characters after entities parsing
600601
* @param ParseMode|string $parse_mode Mode for parsing entities in the media caption. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details.
601602
* @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>
@@ -611,6 +612,7 @@ public function sendPaidMedia(
611612
int|string $chat_id,
612613
int $star_count,
613614
array $media,
615+
?string $business_connection_id = null,
614616
?string $caption = null,
615617
ParseMode|string|null $parse_mode = null,
616618
?array $caption_entities = null,
@@ -872,11 +874,11 @@ public function sendChatAction(
872874
}
873875

874876
/**
875-
* 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. Returns <em>True</em> on success.
877+
* 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.
876878
*
877879
* @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
878880
* @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.
879-
* @param ReactionType[] $reaction A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
881+
* @param ReactionType[] $reaction A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
880882
* @param bool $is_big Pass <em>True</em> to set the reaction with a big animation
881883
*
882884
* @throws TelegramException
@@ -1128,6 +1130,42 @@ public function editChatInviteLink(
11281130
return $this->raw('editChatInviteLink', func_get_args());
11291131
}
11301132

1133+
/**
1134+
* Use this method to create a <a href="https://telegram.org/blog/superchannels-star-reactions-subscriptions#star-subscriptions">subscription invite link</a> for a channel chat. The bot must have the <em>can_invite_users</em> administrator rights. The link can be edited using the method <a href="https://core.telegram.org/bots/api#editchatsubscriptioninvitelink">editChatSubscriptionInviteLink</a> or revoked using the method <a href="https://core.telegram.org/bots/api#revokechatinvitelink">revokeChatInviteLink</a>. Returns the new invite link as a <a href="https://core.telegram.org/bots/api#chatinvitelink">ChatInviteLink</a> object.
1135+
*
1136+
* @param int|string $chat_id Unique identifier for the target channel chat or username of the target channel (in the format @channelusername)
1137+
* @param int $subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
1138+
* @param int $subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
1139+
* @param string $name Invite link name; 0-32 characters
1140+
*
1141+
* @throws TelegramException
1142+
*/
1143+
public function createChatSubscriptionInviteLink(
1144+
int|string $chat_id,
1145+
int $subscription_period,
1146+
int $subscription_price,
1147+
?string $name = null,
1148+
): ChatInviteLink {
1149+
return $this->raw('createChatSubscriptionInviteLink', func_get_args());
1150+
}
1151+
1152+
/**
1153+
* Use this method to edit a subscription invite link created by the bot. The bot must have the <em>can_invite_users</em> administrator rights. Returns the edited invite link as a <a href="https://core.telegram.org/bots/api#chatinvitelink">ChatInviteLink</a> object.
1154+
*
1155+
* @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1156+
* @param string $invite_link The invite link to edit
1157+
* @param string $name Invite link name; 0-32 characters
1158+
*
1159+
* @throws TelegramException
1160+
*/
1161+
public function editChatSubscriptionInviteLink(
1162+
int|string $chat_id,
1163+
string $invite_link,
1164+
?string $name = null,
1165+
): ChatInviteLink {
1166+
return $this->raw('editChatSubscriptionInviteLink', func_get_args());
1167+
}
1168+
11311169
/**
11321170
* Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as <a href="https://core.telegram.org/bots/api#chatinvitelink">ChatInviteLink</a> object.
11331171
*
@@ -1385,7 +1423,7 @@ public function createForumTopic(
13851423
}
13861424

13871425
/**
1388-
* Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have <em>can_manage_topics</em> administrator rights, unless it is the creator of the topic. Returns <em>True</em> on success.
1426+
* Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the <em>can_manage_topics</em> administrator rights, unless it is the creator of the topic. Returns <em>True</em> on success.
13891427
*
13901428
* @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
13911429
* @param int $message_thread_id Unique identifier for the target message thread of the forum topic
@@ -1456,7 +1494,7 @@ public function unpinAllForumTopicMessages(int|string $chat_id, int $message_thr
14561494
}
14571495

14581496
/**
1459-
* Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have <em>can_manage_topics</em> administrator rights. Returns <em>True</em> on success.
1497+
* Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the <em>can_manage_topics</em> administrator rights. Returns <em>True</em> on success.
14601498
*
14611499
* @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
14621500
* @param string $name New topic name, 1-128 characters

src/Telegram/ChatMemberMember.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@ class ChatMemberMember extends ChatMember
1414
/** The member's status in the chat, always “member” */
1515
public string $status = 'member';
1616

17+
/** <em>Optional</em>. Date when the user's subscription will expire; Unix time */
18+
public ?int $until_date = null;
19+
1720
/**
1821
* @param User $user Information about the user
22+
* @param int $until_date <em>Optional</em>. Date when the user's subscription will expire; Unix time
1923
*/
20-
public static function make(User $user): static
24+
public static function make(User $user, ?int $until_date = null): static
2125
{
2226
return new static([
2327
'user' => $user,
28+
'until_date' => $until_date,
2429
]);
2530
}
2631
}

src/Telegram/Message.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class Message extends MaybeInaccessibleMessage
1818
/** <em>Optional</em>. Unique identifier of a message thread to which the message belongs; for supergroups only */
1919
public ?int $message_thread_id = null;
2020

21-
/** <em>Optional</em>. Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. */
21+
/** <em>Optional</em>. Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats */
2222
public ?User $from = null;
2323

24-
/** <em>Optional</em>. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field <em>from</em> contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. */
24+
/** <em>Optional</em>. Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel's discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field <em>from</em> contains a fake sender user in non-channel chats. */
2525
public ?Chat $sender_chat = null;
2626

2727
/** <em>Optional</em>. If the sender of the message boosted the chat, the number of boosts added by the user */
@@ -286,8 +286,8 @@ class Message extends MaybeInaccessibleMessage
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
289-
* @param User $from <em>Optional</em>. Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
290-
* @param Chat $sender_chat <em>Optional</em>. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field <em>from</em> contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
289+
* @param User $from <em>Optional</em>. Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats
290+
* @param Chat $sender_chat <em>Optional</em>. Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel's discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field <em>from</em> contains a fake sender user in non-channel chats.
291291
* @param int $sender_boost_count <em>Optional</em>. If the sender of the message boosted the chat, the number of boosts added by the user
292292
* @param User $sender_business_bot <em>Optional</em>. The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account.
293293
* @param string $business_connection_id <em>Optional</em>. Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.

src/Telegram/ReactionType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static function factory(array $data, ?Bot $bot = null): self
2323
return match ($data['type']) {
2424
'emoji' => new ReactionTypeEmoji($data, $bot),
2525
'custom_emoji' => new ReactionTypeCustomEmoji($data, $bot),
26+
'paid' => new ReactionTypePaid($data, $bot),
2627
};
2728
}
2829
}

src/Telegram/ReactionTypePaid.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/**
4+
* This file is auto-generated.
5+
*/
6+
7+
namespace Telepath\Telegram;
8+
9+
/**
10+
* The reaction is paid.
11+
*/
12+
class ReactionTypePaid extends ReactionType
13+
{
14+
/** Type of the reaction, always “paid” */
15+
public string $type = 'paid';
16+
17+
public static function make(): static
18+
{
19+
return new static([
20+
]);
21+
}
22+
}

src/Telegram/TransactionPartnerUser.php

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

23+
/**
24+
* <em>Optional</em>. Information about the paid media bought by the user
25+
*
26+
* @var PaidMedia[]
27+
*/
28+
public ?array $paid_media = null;
29+
2330
/**
2431
* @param User $user Information about the user
2532
* @param string $invoice_payload <em>Optional</em>. Bot-specified invoice payload
33+
* @param PaidMedia[] $paid_media <em>Optional</em>. Information about the paid media bought by the user
2634
*/
27-
public static function make(User $user, ?string $invoice_payload = null): static
35+
public static function make(User $user, ?string $invoice_payload = null, ?array $paid_media = null): static
2836
{
2937
return new static([
3038
'user' => $user,
3139
'invoice_payload' => $invoice_payload,
40+
'paid_media' => $paid_media,
3241
]);
3342
}
3443
}

0 commit comments

Comments
 (0)