Add PromoteChatMember method to TgBotLib

This commit is contained in:
netkas 2024-11-05 21:27:13 -05:00
parent 8119e791e4
commit 47fde54d40
2 changed files with 57 additions and 0 deletions

View file

@ -18,6 +18,7 @@
use TgBotLib\Methods\GetUserProfilePhotos;
use TgBotLib\Methods\GetWebhookInfo;
use TgBotLib\Methods\Logout;
use TgBotLib\Methods\PromoteChatMember;
use TgBotLib\Methods\RestrictChatMember;
use TgBotLib\Methods\SendAnimation;
use TgBotLib\Methods\SendAudio;
@ -74,6 +75,7 @@
case BAN_CHAT_MEMBER = 'banChatMember';
case UNBAN_CHAT_MEMBER = 'unbanChatMember';
case RESTRICT_CHAT_MEMBER = 'restrictChatMember';
case PROMOTE_CHAT_MEMBER = 'promoteChatMember';
/**
* Executes a command on the provided bot with the given parameters.
@ -120,6 +122,7 @@
self::BAN_CHAT_MEMBER => BanChatMember::execute($bot, $parameters),
self::UNBAN_CHAT_MEMBER => UnbanChatMember::execute($bot, $parameters),
self::RESTRICT_CHAT_MEMBER => RestrictChatMember::execute($bot, $parameters),
self::PROMOTE_CHAT_MEMBER => PromoteChatMember::execute($bot, $parameters),
};
}
}

View file

@ -0,0 +1,54 @@
<?php
namespace TgBotLib\Methods;
use TgBotLib\Abstracts\Method;
use TgBotLib\Bot;
use TgBotLib\Enums\Methods;
class PromoteChatMember extends Method
{
/**
* @inheritDoc
*/
public static function execute(Bot $bot, array $parameters = []): true
{
return (bool)$bot->sendRequest(Methods::PROMOTE_CHAT_MEMBER->value, $parameters);
}
/**
* @inheritDoc
*/
public static function getRequiredParameters(): ?array
{
return [
'chat_id',
'user_id'
];
}
/**
* @inheritDoc
*/
public static function getOptionalParameters(): ?array
{
return [
'is_anonymous',
'can_manage_chat',
'can_delete_messages',
'can_manage_video_chats',
'can_restrict_members',
'can_promote_members',
'can_change_info',
'can_invite_users',
'can_post_stories',
'can_edit_stories',
'can_delete_stories',
'can_post_messages',
'can_edit_messages',
'can_pin_messages',
'can_manage_topics'
];
}
}