Add SetMyCommands method
This commit is contained in:
parent
527d546a78
commit
b9a46da443
2 changed files with 54 additions and 0 deletions
|
@ -73,6 +73,7 @@
|
||||||
use TgBotLib\Methods\SetChatStickerSet;
|
use TgBotLib\Methods\SetChatStickerSet;
|
||||||
use TgBotLib\Methods\SetChatTitle;
|
use TgBotLib\Methods\SetChatTitle;
|
||||||
use TgBotLib\Methods\SetMessageReaction;
|
use TgBotLib\Methods\SetMessageReaction;
|
||||||
|
use TgBotLib\Methods\SetMyCommands;
|
||||||
use TgBotLib\Methods\SetWebhook;
|
use TgBotLib\Methods\SetWebhook;
|
||||||
use TgBotLib\Methods\UnbanChatMember;
|
use TgBotLib\Methods\UnbanChatMember;
|
||||||
use TgBotLib\Methods\UnbanChatSenderChat;
|
use TgBotLib\Methods\UnbanChatSenderChat;
|
||||||
|
@ -160,6 +161,7 @@
|
||||||
case ANSWER_CALLBACK_QUERY = 'answerCallbackQuery';
|
case ANSWER_CALLBACK_QUERY = 'answerCallbackQuery';
|
||||||
case GET_USER_CHAT_BOOSTS = 'getUserChatBoosts';
|
case GET_USER_CHAT_BOOSTS = 'getUserChatBoosts';
|
||||||
case GET_BUSINESS_CONNECTION = 'getBusinessConnection';
|
case GET_BUSINESS_CONNECTION = 'getBusinessConnection';
|
||||||
|
case SET_MY_COMMANDS = 'setMyCommands';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a command on the provided bot with the given parameters.
|
* Executes a command on the provided bot with the given parameters.
|
||||||
|
@ -249,6 +251,7 @@
|
||||||
self::ANSWER_CALLBACK_QUERY => AnswerCallbackQuery::execute($bot, $parameters),
|
self::ANSWER_CALLBACK_QUERY => AnswerCallbackQuery::execute($bot, $parameters),
|
||||||
self::GET_USER_CHAT_BOOSTS => GetUserChatBoosts::execute($bot, $parameters),
|
self::GET_USER_CHAT_BOOSTS => GetUserChatBoosts::execute($bot, $parameters),
|
||||||
self::GET_BUSINESS_CONNECTION => GetBusinessConnection::execute($bot, $parameters),
|
self::GET_BUSINESS_CONNECTION => GetBusinessConnection::execute($bot, $parameters),
|
||||||
|
self::SET_MY_COMMANDS => SetMyCommands::execute($bot, $parameters),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
51
src/TgBotLib/Methods/SetMyCommands.php
Normal file
51
src/TgBotLib/Methods/SetMyCommands.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TgBotLib\Methods;
|
||||||
|
|
||||||
|
use TgBotLib\Abstracts\Method;
|
||||||
|
use TgBotLib\Bot;
|
||||||
|
use TgBotLib\Enums\Methods;
|
||||||
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||||
|
|
||||||
|
class SetMyCommands extends Method
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function execute(Bot $bot, array $parameters = []): true
|
||||||
|
{
|
||||||
|
if(isset($parameters['commands']))
|
||||||
|
{
|
||||||
|
$parameters['commands'] = json_encode(array_map(function ($option) {return $option->toArray();}, $parameters['commands']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($parameters['scope']) && $parameters['scope'] instanceof ObjectTypeInterface)
|
||||||
|
{
|
||||||
|
$parameters['scope'] = $parameters['scope']->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (bool)self::executeCurl(self::buildPost($bot, Methods::SET_MY_COMMANDS->value, $parameters));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getRequiredParameters(): ?array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'commands'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getOptionalParameters(): ?array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'scope',
|
||||||
|
'language_code'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue