Add SetMyDefaultAdministratorRights

This commit is contained in:
netkas 2024-11-13 21:47:02 -05:00
parent 95020c9ed9
commit c61c37be02
2 changed files with 46 additions and 0 deletions

View file

@ -81,6 +81,7 @@
use TgBotLib\Methods\SetChatTitle;
use TgBotLib\Methods\SetMessageReaction;
use TgBotLib\Methods\SetMyCommands;
use TgBotLib\Methods\SetMyDefaultAdministratorRights;
use TgBotLib\Methods\SetMyDescription;
use TgBotLib\Methods\SetMyName;
use TgBotLib\Methods\SetMyShortDescription;
@ -182,6 +183,7 @@
case GET_MY_SHORT_DESCRIPTION = 'getMyShortDescription';
case SET_CHAT_MENU_BUTTON = 'setChatMenuButton';
case GET_CHAT_MENU_BUTTON = 'getChatMenuButton';
case SET_MY_DEFAULT_ADMINISTRATOR_RIGHTS = 'setMyDefaultAdministratorRights';
/**
* Executes a command on the provided bot with the given parameters.
@ -282,6 +284,7 @@
self::GET_MY_SHORT_DESCRIPTION => GetMyShortDescription::execute($bot, $parameters),
self::SET_CHAT_MENU_BUTTON => SetChatMenuButton::execute($bot, $parameters),
self::GET_CHAT_MENU_BUTTON => GetChatMenuButton::execute($bot, $parameters),
self::SET_MY_DEFAULT_ADMINISTRATOR_RIGHTS => SetMyDefaultAdministratorRights::execute($bot, $parameters),
};
}
}

View file

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