Add RestrictChatMember method to bot library
This commit is contained in:
parent
2377b239f3
commit
8119e791e4
2 changed files with 55 additions and 0 deletions
|
@ -18,6 +18,7 @@
|
||||||
use TgBotLib\Methods\GetUserProfilePhotos;
|
use TgBotLib\Methods\GetUserProfilePhotos;
|
||||||
use TgBotLib\Methods\GetWebhookInfo;
|
use TgBotLib\Methods\GetWebhookInfo;
|
||||||
use TgBotLib\Methods\Logout;
|
use TgBotLib\Methods\Logout;
|
||||||
|
use TgBotLib\Methods\RestrictChatMember;
|
||||||
use TgBotLib\Methods\SendAnimation;
|
use TgBotLib\Methods\SendAnimation;
|
||||||
use TgBotLib\Methods\SendAudio;
|
use TgBotLib\Methods\SendAudio;
|
||||||
use TgBotLib\Methods\SendChatAction;
|
use TgBotLib\Methods\SendChatAction;
|
||||||
|
@ -72,6 +73,7 @@
|
||||||
case GET_FILE = 'getFile';
|
case GET_FILE = 'getFile';
|
||||||
case BAN_CHAT_MEMBER = 'banChatMember';
|
case BAN_CHAT_MEMBER = 'banChatMember';
|
||||||
case UNBAN_CHAT_MEMBER = 'unbanChatMember';
|
case UNBAN_CHAT_MEMBER = 'unbanChatMember';
|
||||||
|
case RESTRICT_CHAT_MEMBER = 'restrictChatMember';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a command on the provided bot with the given parameters.
|
* Executes a command on the provided bot with the given parameters.
|
||||||
|
@ -117,6 +119,7 @@
|
||||||
self::GET_FILE => GetFile::execute($bot, $parameters),
|
self::GET_FILE => GetFile::execute($bot, $parameters),
|
||||||
self::BAN_CHAT_MEMBER => BanChatMember::execute($bot, $parameters),
|
self::BAN_CHAT_MEMBER => BanChatMember::execute($bot, $parameters),
|
||||||
self::UNBAN_CHAT_MEMBER => UnbanChatMember::execute($bot, $parameters),
|
self::UNBAN_CHAT_MEMBER => UnbanChatMember::execute($bot, $parameters),
|
||||||
|
self::RESTRICT_CHAT_MEMBER => RestrictChatMember::execute($bot, $parameters),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
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
Reference in a new issue