diff --git a/src/TgBotLib/Enums/Methods.php b/src/TgBotLib/Enums/Methods.php index d4a4ea2..d44e135 100644 --- a/src/TgBotLib/Enums/Methods.php +++ b/src/TgBotLib/Enums/Methods.php @@ -73,6 +73,7 @@ use TgBotLib\Methods\SetChatStickerSet; use TgBotLib\Methods\SetChatTitle; use TgBotLib\Methods\SetMessageReaction; + use TgBotLib\Methods\SetMyCommands; use TgBotLib\Methods\SetWebhook; use TgBotLib\Methods\UnbanChatMember; use TgBotLib\Methods\UnbanChatSenderChat; @@ -160,6 +161,7 @@ case ANSWER_CALLBACK_QUERY = 'answerCallbackQuery'; case GET_USER_CHAT_BOOSTS = 'getUserChatBoosts'; case GET_BUSINESS_CONNECTION = 'getBusinessConnection'; + case SET_MY_COMMANDS = 'setMyCommands'; /** * Executes a command on the provided bot with the given parameters. @@ -249,6 +251,7 @@ self::ANSWER_CALLBACK_QUERY => AnswerCallbackQuery::execute($bot, $parameters), self::GET_USER_CHAT_BOOSTS => GetUserChatBoosts::execute($bot, $parameters), self::GET_BUSINESS_CONNECTION => GetBusinessConnection::execute($bot, $parameters), + self::SET_MY_COMMANDS => SetMyCommands::execute($bot, $parameters), }; } } diff --git a/src/TgBotLib/Methods/SetMyCommands.php b/src/TgBotLib/Methods/SetMyCommands.php new file mode 100644 index 0000000..ddf2c9d --- /dev/null +++ b/src/TgBotLib/Methods/SetMyCommands.php @@ -0,0 +1,51 @@ +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' + ]; + } + } \ No newline at end of file