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 Aug 16, 2024
1 parent a33f44b commit 7e25039
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 12 deletions.
50 changes: 44 additions & 6 deletions src/Layers/Generated.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,12 @@ public function sendVideoNote(
}

/**
* 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.
* Use this method to send paid media. On success, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned.
*
* @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @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.
* @param int $star_count The number of Telegram Stars that must be paid to buy access to the media
* @param InputPaidMedia[] $media A JSON-serialized array describing the media to be sent; up to 10 items
* @param string $business_connection_id Unique identifier of the business connection on behalf of which the message will be sent
* @param string $caption Media caption, 0-1024 characters after entities parsing
* @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.
* @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 @@ -611,6 +612,7 @@ public function sendPaidMedia(
int|string $chat_id,
int $star_count,
array $media,
?string $business_connection_id = null,
?string $caption = null,
ParseMode|string|null $parse_mode = null,
?array $caption_entities = null,
Expand Down Expand Up @@ -872,11 +874,11 @@ 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. Returns <em>True</em> on success.
* 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.
*
* @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.
* @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.
* @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.
* @param bool $is_big Pass <em>True</em> to set the reaction with a big animation
*
* @throws TelegramException
Expand Down Expand Up @@ -1128,6 +1130,42 @@ public function editChatInviteLink(
return $this->raw('editChatInviteLink', func_get_args());
}

/**
* 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.
*
* @param int|string $chat_id Unique identifier for the target channel chat or username of the target channel (in the format @channelusername)
* @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).
* @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
* @param string $name Invite link name; 0-32 characters
*
* @throws TelegramException
*/
public function createChatSubscriptionInviteLink(
int|string $chat_id,
int $subscription_period,
int $subscription_price,
?string $name = null,
): ChatInviteLink {
return $this->raw('createChatSubscriptionInviteLink', func_get_args());
}

/**
* 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.
*
* @param int|string $chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param string $invite_link The invite link to edit
* @param string $name Invite link name; 0-32 characters
*
* @throws TelegramException
*/
public function editChatSubscriptionInviteLink(
int|string $chat_id,
string $invite_link,
?string $name = null,
): ChatInviteLink {
return $this->raw('editChatSubscriptionInviteLink', func_get_args());
}

/**
* 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.
*
Expand Down Expand Up @@ -1385,7 +1423,7 @@ public function createForumTopic(
}

/**
* 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.
* 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.
*
* @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
* @param int $message_thread_id Unique identifier for the target message thread of the forum topic
Expand Down Expand Up @@ -1456,7 +1494,7 @@ public function unpinAllForumTopicMessages(int|string $chat_id, int $message_thr
}

/**
* 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.
* 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.
*
* @param int|string $chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
* @param string $name New topic name, 1-128 characters
Expand Down
7 changes: 6 additions & 1 deletion src/Telegram/ChatMemberMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ class ChatMemberMember extends ChatMember
/** The member's status in the chat, always “member” */
public string $status = 'member';

/** <em>Optional</em>. Date when the user's subscription will expire; Unix time */
public ?int $until_date = null;

/**
* @param User $user Information about the user
* @param int $until_date <em>Optional</em>. Date when the user's subscription will expire; Unix time
*/
public static function make(User $user): static
public static function make(User $user, ?int $until_date = null): static
{
return new static([
'user' => $user,
'until_date' => $until_date,
]);
}
}
8 changes: 4 additions & 4 deletions src/Telegram/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class Message extends MaybeInaccessibleMessage
/** <em>Optional</em>. Unique identifier of a message thread to which the message belongs; for supergroups only */
public ?int $message_thread_id = null;

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

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

/** <em>Optional</em>. If the sender of the message boosted the chat, the number of boosts added by the user */
Expand Down Expand Up @@ -286,8 +286,8 @@ class Message extends MaybeInaccessibleMessage
* @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
* @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.
* @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.
* @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
* @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.
* @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
* @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.
* @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.
Expand Down
1 change: 1 addition & 0 deletions src/Telegram/ReactionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static function factory(array $data, ?Bot $bot = null): self
return match ($data['type']) {
'emoji' => new ReactionTypeEmoji($data, $bot),
'custom_emoji' => new ReactionTypeCustomEmoji($data, $bot),
'paid' => new ReactionTypePaid($data, $bot),
};
}
}
22 changes: 22 additions & 0 deletions src/Telegram/ReactionTypePaid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

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

namespace Telepath\Telegram;

/**
* The reaction is paid.
*/
class ReactionTypePaid extends ReactionType
{
/** Type of the reaction, always “paid” */
public string $type = 'paid';

public static function make(): static
{
return new static([
]);
}
}
11 changes: 10 additions & 1 deletion src/Telegram/TransactionPartnerUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,24 @@ class TransactionPartnerUser extends TransactionPartner
/** <em>Optional</em>. Bot-specified invoice payload */
public ?string $invoice_payload = null;

/**
* <em>Optional</em>. Information about the paid media bought by the user
*
* @var PaidMedia[]
*/
public ?array $paid_media = null;

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

0 comments on commit 7e25039

Please sign in to comment.