Add GetMyCommands method to TgBotLib
This commit is contained in:
parent
c48dbda47b
commit
c1d515de0c
2 changed files with 52 additions and 0 deletions
49
src/TgBotLib/Methods/GetMyCommands.php
Normal file
49
src/TgBotLib/Methods/GetMyCommands.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\BotCommand;
|
||||
use TgBotLib\Objects\ChatMember;
|
||||
|
||||
class GetMyCommands extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): array
|
||||
{
|
||||
if(isset($parameters['scope']) && $parameters['scope'] instanceof ObjectTypeInterface)
|
||||
{
|
||||
$parameters['scope'] = json_encode($parameters['scope']->toArray());
|
||||
}
|
||||
|
||||
return array_map(
|
||||
fn($update) => BotCommand::fromArray($update),
|
||||
self::executeCurl(self::buildPost($bot, Methods::GET_MY_COMMANDS->value, $parameters))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'scope',
|
||||
'language_code'
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue