Add RestrictChatMember method to bot library
This commit is contained in:
parent
2377b239f3
commit
8119e791e4
2 changed files with 55 additions and 0 deletions
52
src/TgBotLib/Methods/RestrictChatMember.php
Normal file
52
src/TgBotLib/Methods/RestrictChatMember.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class RestrictChatMember extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
if($parameters['permissions'] instanceof ObjectTypeInterface)
|
||||
{
|
||||
$parameters['permissions'] = json_encode($parameters['permissions']->toArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
$parameters['permissions'] = json_encode($parameters['permissions']);
|
||||
}
|
||||
|
||||
return (bool)$bot->sendRequest(Methods::RESTRICT_CHAT_MEMBER->value, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'chat_id',
|
||||
'user_id',
|
||||
'permissions'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'use_independent_chat_permissions',
|
||||
'until_date'
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue