-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
966 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method\Inline; | ||
|
||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
use Vjik\TelegramBot\Api\Type\Inline\InlineQueryResult; | ||
use Vjik\TelegramBot\Api\Type\Inline\PreparedInlineMessage; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#savepreparedinlinemessage | ||
* | ||
* @template-implements TelegramRequestWithResultPreparingInterface<class-string<PreparedInlineMessage>> | ||
*/ | ||
final readonly class SavePreparedInlineMessage implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private int $userId, | ||
private InlineQueryResult $result, | ||
private ?bool $allowUserChats = null, | ||
private ?bool $allowBotChats = null, | ||
private ?bool $allowGroupChats = null, | ||
private ?bool $allowChannelChats = null, | ||
) {} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'savePreparedInlineMessage'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return array_filter( | ||
[ | ||
'user_id' => $this->userId, | ||
'result' => $this->result->toRequestArray(), | ||
'allow_user_chats' => $this->allowUserChats, | ||
'allow_bot_chats' => $this->allowBotChats, | ||
'allow_group_chats' => $this->allowGroupChats, | ||
'allow_channel_chats' => $this->allowChannelChats, | ||
], | ||
static fn(mixed $value): bool => $value !== null, | ||
); | ||
} | ||
|
||
public function getResultType(): string | ||
{ | ||
return PreparedInlineMessage::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method\Payment; | ||
|
||
use Vjik\TelegramBot\Api\ParseResult\ValueProcessor\TrueValue; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#edituserstarsubscription | ||
* | ||
* @template-implements TelegramRequestWithResultPreparingInterface<TrueValue> | ||
*/ | ||
final readonly class EditUserStarSubscription implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private int $userId, | ||
private string $telegramPaymentChargeId, | ||
private bool $isCanceled, | ||
) {} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'editUserStarSubscription'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return [ | ||
'user_id' => $this->userId, | ||
'telegram_payment_charge_id' => $this->telegramPaymentChargeId, | ||
'is_canceled' => $this->isCanceled, | ||
]; | ||
} | ||
|
||
public function getResultType(): TrueValue | ||
{ | ||
return new TrueValue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method; | ||
|
||
use DateTimeImmutable; | ||
use Vjik\TelegramBot\Api\ParseResult\ValueProcessor\TrueValue; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#setuseremojistatus | ||
* | ||
* @template-implements TelegramRequestWithResultPreparingInterface<TrueValue> | ||
*/ | ||
final readonly class SetUserEmojiStatus implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private int $userId, | ||
private ?string $emojiStatusCustomEmojiId = null, | ||
private ?DateTimeImmutable $emojiStatusExpirationDate = null, | ||
) {} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'setUserEmojiStatus'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return array_filter( | ||
[ | ||
'user_id' => $this->userId, | ||
'emoji_status_custom_emoji_id' => $this->emojiStatusCustomEmojiId, | ||
'emoji_status_expiration_date' => $this->emojiStatusExpirationDate?->getTimestamp(), | ||
], | ||
static fn(mixed $value): bool => $value !== null, | ||
); | ||
} | ||
|
||
public function getResultType(): TrueValue | ||
{ | ||
return new TrueValue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method\Sticker; | ||
|
||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
use Vjik\TelegramBot\Api\Type\Sticker\Gifts; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#getavailablegifts | ||
* | ||
* @template-implements TelegramRequestWithResultPreparingInterface<class-string<Gifts>> | ||
*/ | ||
final readonly class GetAvailableGifts implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::GET; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'getAvailableGifts'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function getResultType(): string | ||
{ | ||
return Gifts::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method\Sticker; | ||
|
||
use Vjik\TelegramBot\Api\ParseResult\ValueProcessor\TrueValue; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
use Vjik\TelegramBot\Api\Type\MessageEntity; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#sendgift | ||
* | ||
* @template-implements TelegramRequestWithResultPreparingInterface<TrueValue> | ||
*/ | ||
final readonly class SendGift implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
/** | ||
* @param MessageEntity[]|null $textEntities | ||
*/ | ||
public function __construct( | ||
private int $userId, | ||
private string $giftId, | ||
private ?string $text = null, | ||
private ?string $textParseMode = null, | ||
private ?array $textEntities = null, | ||
) {} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'sendGift'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return array_filter( | ||
[ | ||
'user_id' => $this->userId, | ||
'gift_id' => $this->giftId, | ||
'text' => $this->text, | ||
'text_parse_mode' => $this->textParseMode, | ||
'text_entities' => $this->textEntities === null | ||
? null | ||
: array_map( | ||
static fn(MessageEntity $entity) => $entity->toRequestArray(), | ||
$this->textEntities, | ||
), | ||
], | ||
static fn(mixed $value): bool => $value !== null, | ||
); | ||
} | ||
|
||
public function getResultType(): TrueValue | ||
{ | ||
return new TrueValue(); | ||
} | ||
} |
Oops, something went wrong.