Skip to content

Commit

Permalink
Bot API 7.9
Browse files Browse the repository at this point in the history
  • Loading branch information
luzrain committed Aug 26, 2024
1 parent ec75110 commit a4db74b
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PHP Wrapper for Telegram Bot API

[![Bot Api 7.8](https://img.shields.io/badge/Bot%20API-7.8-0088cc.svg?style=flat)](https://core.telegram.org/bots/api-changelog#july-31-2024)
[![Bot Api 7.9](https://img.shields.io/badge/Bot%20API-7.9-0088cc.svg?style=flat)](https://core.telegram.org/bots/api-changelog#august-14-2024)
[![PHP >=8.2](https://img.shields.io/badge/PHP->=8.2-777bb3.svg?style=flat)](https://www.php.net/releases/8.2/en.php)
[![Tests Status](https://img.shields.io/github/actions/workflow/status/luzrain/telegram-bot-api/tests.yaml?branch=master)](../../actions/workflows/tests.yaml)

Expand Down
47 changes: 47 additions & 0 deletions src/Method/CreateChatSubscriptionInviteLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace Luzrain\TelegramBotApi\Method;

use Luzrain\TelegramBotApi\Method;
use Luzrain\TelegramBotApi\Type\ChatInviteLink;

/**
* Use this method to create a subscription invite link for a channel chat.
* The bot must have the can_invite_users administrator rights.
* The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink.
* Returns the new invite link as a ChatInviteLink object.
*
* @see https://telegram.org/blog/superchannels-star-reactions-subscriptions#star-subscriptions
*
* @extends Method<ChatInviteLink>
*/
final class CreateChatSubscriptionInviteLink extends Method
{
protected static string $methodName = 'createChatSubscriptionInviteLink';
protected static string $responseClass = ChatInviteLink::class;

public function __construct(
/**
* Unique identifier for the target channel chat or username of the target channel (in the format @channelusername)
*/
protected int|string $chatId,

/**
* The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
*/
protected int $subscriptionPeriod,

/**
* 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
*/
protected int $subscriptionPrice,

/**
* Invite link name; 0-32 characters
*/
protected string|null $name = null,
) {
}
}
39 changes: 39 additions & 0 deletions src/Method/EditChatSubscriptionInviteLink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Luzrain\TelegramBotApi\Method;

use Luzrain\TelegramBotApi\Method;
use Luzrain\TelegramBotApi\Type\ChatInviteLink;

/**
* Use this method to edit a subscription invite link created by the bot.
* The bot must have the can_invite_users administrator rights.
* Returns the edited invite link as a ChatInviteLink object.
*
* @extends Method<ChatInviteLink>
*/
final class EditChatSubscriptionInviteLink extends Method
{
protected static string $methodName = 'editChatSubscriptionInviteLink';
protected static string $responseClass = ChatInviteLink::class;

public function __construct(
/**
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
protected int|string $chatId,

/**
* The invite link to edit
*/
protected string $inviteLink,

/**
* Invite link name; 0-32 characters
*/
protected string|null $name = null,
) {
}
}
5 changes: 5 additions & 0 deletions src/Method/SendPaidMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public function __construct(
*/
protected array $media,

/**
* Unique identifier of the business connection on behalf of which the message will be sent
*/
protected string|null $businessConnectionId = null,

/**
* Media caption, 0-1024 characters after entities parsing
*/
Expand Down
11 changes: 11 additions & 0 deletions src/Type/ChatInviteLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ protected function __construct(
* Optional. Number of pending join requests created using this link
*/
public int|null $pendingJoinRequestCount = null,

/**
* Optional. The number of seconds the subscription will be active for before the next payment
*/
public int|null $subscriptionPeriod = null,

/**
* Optional. The amount of Telegram Stars a user must pay initially and after each subsequent subscription period
* to be a member of the chat using the link
*/
public int|null $subscriptionPrice = null,
) {
}
}
5 changes: 5 additions & 0 deletions src/Type/ChatMemberMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ protected function __construct(
* Information about the user
*/
public User $user,

/**
* Optional. Date when the user's subscription will expire; Unix time
*/
public int|null $untilDate = null,
) {
parent::__construct(self::STATUS);
}
Expand Down
10 changes: 10 additions & 0 deletions src/Type/Payments/TransactionPartnerUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Luzrain\TelegramBotApi\Type\Payments;

use Luzrain\TelegramBotApi\Internal\ArrayType;
use Luzrain\TelegramBotApi\Type\PaidMedia;
use Luzrain\TelegramBotApi\Type\User;

/**
Expand All @@ -23,6 +25,14 @@ protected function __construct(
* Optional. Bot-specified invoice payload
*/
public string|null $invoicePayload = null,

/**
* Optional. Information about the paid media bought by the user
*
* @var list<PaidMedia>|null
*/
#[ArrayType(PaidMedia::class)]
public array|null $paidMedia = null,
) {
parent::__construct(self::TYPE);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Type/ReactionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*
* @see ReactionTypeEmoji
* @see ReactionTypeCustomEmoji
* @see ReactionTypePaid
*/
readonly class ReactionType extends Type
{
Expand All @@ -34,6 +35,7 @@ public static function fromArray(array $data): static
return self::class !== static::class ? $instance : match ($instance->type) {
ReactionTypeEmoji::TYPE => ReactionTypeEmoji::fromArray($data),
ReactionTypeCustomEmoji::TYPE => ReactionTypeCustomEmoji::fromArray($data),
ReactionTypePaid::TYPE => ReactionTypePaid::fromArray($data),
};
}
}
18 changes: 18 additions & 0 deletions src/Type/ReactionTypePaid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Luzrain\TelegramBotApi\Type;

/**
* The reaction is paid.
*/
final readonly class ReactionTypePaid extends ReactionType
{
public const TYPE = 'paid';

public function __construct()
{
parent::__construct(self::TYPE);
}
}

0 comments on commit a4db74b

Please sign in to comment.