-
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
51 changed files
with
1,881 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method; | ||
|
||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
use Vjik\TelegramBot\Api\Type\BotCommandScope; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#deletemycommands | ||
*/ | ||
final readonly class DeleteMyCommands implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private ?BotCommandScope $scope = null, | ||
private ?string $languageCode = null, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'deleteMyCommands'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return array_filter([ | ||
'scope' => $this->scope?->toRequestArray(), | ||
'language_code' => $this->languageCode, | ||
]); | ||
} | ||
|
||
public function prepareResult(mixed $result): true | ||
{ | ||
return true; | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method; | ||
|
||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
use Vjik\TelegramBot\Api\Type\MenuButton; | ||
use Vjik\TelegramBot\Api\Type\MenuButtonFactory; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#getchatmenubutton | ||
*/ | ||
final readonly class GetChatMenuButton implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private ?int $chatId = null, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::GET; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'getChatMenuButton'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return array_filter([ | ||
'chat_id' => $this->chatId, | ||
]); | ||
} | ||
|
||
public function prepareResult(mixed $result): MenuButton | ||
{ | ||
return MenuButtonFactory::fromTelegramResult($result); | ||
} | ||
} |
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,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method; | ||
|
||
use Vjik\TelegramBot\Api\ParseResult\ValueHelper; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
use Vjik\TelegramBot\Api\Type\BotCommand; | ||
use Vjik\TelegramBot\Api\Type\BotCommandScope; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#getmycommands | ||
*/ | ||
final readonly class GetMyCommands implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private ?BotCommandScope $scope = null, | ||
private ?string $languageCode = null, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::GET; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'getMyCommands'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return array_filter([ | ||
'scope' => $this->scope?->toRequestArray(), | ||
'language_code' => $this->languageCode, | ||
]); | ||
} | ||
|
||
/** | ||
* @return BotCommand[] | ||
*/ | ||
public function prepareResult(mixed $result): array | ||
{ | ||
ValueHelper::assertArrayResult($result); | ||
return array_map( | ||
static fn($item) => BotCommand::fromTelegramResult($item), | ||
$result | ||
); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method; | ||
|
||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
use Vjik\TelegramBot\Api\Type\BotDescription; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#getmydescription | ||
*/ | ||
final readonly class GetMyDescription implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private ?string $languageCode = null, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::GET; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'getMyDescription'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return array_filter([ | ||
'language_code' => $this->languageCode, | ||
]); | ||
} | ||
|
||
public function prepareResult(mixed $result): BotDescription | ||
{ | ||
return BotDescription::fromTelegramResult($result); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method; | ||
|
||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
use Vjik\TelegramBot\Api\Type\BotName; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#getmyname | ||
*/ | ||
final readonly class GetMyName implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private ?string $languageCode = null, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::GET; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'getMyName'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return array_filter([ | ||
'language_code' => $this->languageCode, | ||
]); | ||
} | ||
|
||
public function prepareResult(mixed $result): BotName | ||
{ | ||
return BotName::fromTelegramResult($result); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method; | ||
|
||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
use Vjik\TelegramBot\Api\Type\BotShortDescription; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#getmyshortdescription | ||
*/ | ||
final readonly class GetMyShortDescription implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private ?string $languageCode = null, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::GET; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'getMyShortDescription'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return array_filter([ | ||
'language_code' => $this->languageCode, | ||
]); | ||
} | ||
|
||
public function prepareResult(mixed $result): BotShortDescription | ||
{ | ||
return BotShortDescription::fromTelegramResult($result); | ||
} | ||
} |
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,73 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method; | ||
|
||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
use Vjik\TelegramBot\Api\Type\ForceReply; | ||
use Vjik\TelegramBot\Api\Type\InlineKeyboardMarkup; | ||
use Vjik\TelegramBot\Api\Type\Message; | ||
use Vjik\TelegramBot\Api\Type\ReplyKeyboardMarkup; | ||
use Vjik\TelegramBot\Api\Type\ReplyKeyboardRemove; | ||
use Vjik\TelegramBot\Api\Type\ReplyParameters; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#sendlocation | ||
*/ | ||
final readonly class SendLocation implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private int|string $chatId, | ||
private float $latitude, | ||
private float $longitude, | ||
private ?string $businessConnectionId = null, | ||
private ?int $messageThreadId = null, | ||
private ?float $horizontalAccuracy = null, | ||
private ?int $livePeriod = null, | ||
private ?int $heading = null, | ||
private ?int $proximityAlertRadius = null, | ||
private ?bool $disableNotification = null, | ||
private ?bool $protectContent = null, | ||
private ?string $messageEffectId = null, | ||
private ?ReplyParameters $replyParameters = null, | ||
private InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup = null, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'sendLocation'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return array_filter([ | ||
'business_connection_id' => $this->businessConnectionId, | ||
'chat_id' => $this->chatId, | ||
'message_thread_id' => $this->messageThreadId, | ||
'latitude' => $this->latitude, | ||
'longitude' => $this->longitude, | ||
'horizontal_accuracy' => $this->horizontalAccuracy, | ||
'live_period' => $this->livePeriod, | ||
'heading' => $this->heading, | ||
'proximity_alert_radius' => $this->proximityAlertRadius, | ||
'disable_notification' => $this->disableNotification, | ||
'protect_content' => $this->protectContent, | ||
'message_effect_id' => $this->messageEffectId, | ||
'reply_parameters' => $this->replyParameters?->toRequestArray(), | ||
'reply_markup' => $this->replyMarkup?->toRequestArray(), | ||
]); | ||
} | ||
|
||
public function prepareResult(mixed $result): Message | ||
{ | ||
return Message::fromTelegramResult($result); | ||
} | ||
} |
Oops, something went wrong.