Add BanChatMember method to TgBotLib

This commit is contained in:
netkas 2024-11-05 19:24:25 -05:00
parent d9dd03f601
commit 9e2e19d593
2 changed files with 44 additions and 0 deletions

View file

@ -5,6 +5,7 @@
use TgBotLib\Bot; use TgBotLib\Bot;
use TgBotLib\Exceptions\TelegramException; use TgBotLib\Exceptions\TelegramException;
use TgBotLib\Interfaces\ObjectTypeInterface; use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Methods\BanChatMember;
use TgBotLib\Methods\Close; use TgBotLib\Methods\Close;
use TgBotLib\Methods\CopyMessage; use TgBotLib\Methods\CopyMessage;
use TgBotLib\Methods\CopyMessages; use TgBotLib\Methods\CopyMessages;
@ -68,6 +69,7 @@
case SET_MESSAGE_REACTION = 'setMessageReaction'; case SET_MESSAGE_REACTION = 'setMessageReaction';
case GET_USER_PROFILE_PHOTOS = 'getUserProfilePhotos'; case GET_USER_PROFILE_PHOTOS = 'getUserProfilePhotos';
case GET_FILE = 'getFile'; case GET_FILE = 'getFile';
case BAN_CHAT_MEMBER = 'banChatMember';
/** /**
* Executes a command on the provided bot with the given parameters. * Executes a command on the provided bot with the given parameters.
@ -111,6 +113,7 @@
self::SET_MESSAGE_REACTION => SetMessageReaction::execute($bot, $parameters), self::SET_MESSAGE_REACTION => SetMessageReaction::execute($bot, $parameters),
self::GET_USER_PROFILE_PHOTOS => GetUserProfilePhotos::execute($bot, $parameters), self::GET_USER_PROFILE_PHOTOS => GetUserProfilePhotos::execute($bot, $parameters),
self::GET_FILE => GetFile::execute($bot, $parameters), self::GET_FILE => GetFile::execute($bot, $parameters),
self::BAN_CHAT_MEMBER => BanChatMember::execute($bot, $parameters),
}; };
} }
} }

View file

@ -0,0 +1,41 @@
<?php
namespace TgBotLib\Methods;
use TgBotLib\Abstracts\Method;
use TgBotLib\Bot;
use TgBotLib\Enums\Methods;
class BanChatMember extends Method
{
/**
* @inheritDoc
*/
public static function execute(Bot $bot, array $parameters = []): true
{
return (bool)$bot->sendRequest(Methods::BAN_CHAT_MEMBER->value, $parameters);
}
/**
* @inheritDoc
*/
public static function getRequiredParameters(): ?array
{
return [
'chat_id',
'user_id'
];
}
/**
* @inheritDoc
*/
public static function getOptionalParameters(): ?array
{
return [
'until_date',
'revoke_messages'
];
}
}