Add DeleteMyCommands method

This commit is contained in:
netkas 2024-11-13 15:16:17 -05:00
parent b9a46da443
commit c7eec21824
2 changed files with 47 additions and 0 deletions

View file

@ -21,6 +21,7 @@
use TgBotLib\Methods\DeleteChatPhoto;
use TgBotLib\Methods\DeleteChatStickerSet;
use TgBotLib\Methods\DeleteForumTopic;
use TgBotLib\Methods\DeleteMyCommands;
use TgBotLib\Methods\DeleteWebhook;
use TgBotLib\Methods\EditChatInviteLink;
use TgBotLib\Methods\EditChatSubscriptionInviteLink;
@ -162,6 +163,7 @@
case GET_USER_CHAT_BOOSTS = 'getUserChatBoosts';
case GET_BUSINESS_CONNECTION = 'getBusinessConnection';
case SET_MY_COMMANDS = 'setMyCommands';
case DELETE_MY_COMMANDS = 'deleteMyCommands';
/**
* Executes a command on the provided bot with the given parameters.
@ -252,6 +254,7 @@
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),
self::DELETE_MY_COMMANDS => DeleteMyCommands::execute($bot, $parameters),
};
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace TgBotLib\Methods;
use TgBotLib\Abstracts\Method;
use TgBotLib\Bot;
use TgBotLib\Enums\Methods;
use TgBotLib\Interfaces\ObjectTypeInterface;
class DeleteMyCommands extends Method
{
/**
* @inheritDoc
*/
public static function execute(Bot $bot, array $parameters = []): true
{
if(isset($parameters['scope']) && $parameters['scope'] instanceof ObjectTypeInterface)
{
$parameters['scope'] = json_encode($parameters['scope']->toArray());
}
return (bool)self::executeCurl(self::buildPost($bot, Methods::DELETE_MY_COMMANDS->value, $parameters));
}
/**
* @inheritDoc
*/
public static function getRequiredParameters(): ?array
{
return null;
}
/**
* @inheritDoc
*/
public static function getOptionalParameters(): ?array
{
return [
'scope',
'language_code'
];
}
}