Add GetChatAdministrators method
This commit is contained in:
parent
4be031f96c
commit
7a18d72419
2 changed files with 46 additions and 1 deletions
|
@ -22,6 +22,7 @@
|
||||||
use TgBotLib\Methods\ForwardMessage;
|
use TgBotLib\Methods\ForwardMessage;
|
||||||
use TgBotLib\Methods\ForwardMessages;
|
use TgBotLib\Methods\ForwardMessages;
|
||||||
use TgBotLib\Methods\GetChat;
|
use TgBotLib\Methods\GetChat;
|
||||||
|
use TgBotLib\Methods\GetChatAdministrators;
|
||||||
use TgBotLib\Methods\GetFile;
|
use TgBotLib\Methods\GetFile;
|
||||||
use TgBotLib\Methods\GetMe;
|
use TgBotLib\Methods\GetMe;
|
||||||
use TgBotLib\Methods\GetUpdates;
|
use TgBotLib\Methods\GetUpdates;
|
||||||
|
@ -118,6 +119,7 @@
|
||||||
case UNPIN_ALL_CHAT_MESSAGES = 'unpinAllChatMessages';
|
case UNPIN_ALL_CHAT_MESSAGES = 'unpinAllChatMessages';
|
||||||
case LEAVE_CHAT = 'leaveChat';
|
case LEAVE_CHAT = 'leaveChat';
|
||||||
case GET_CHAT = 'getChat';
|
case GET_CHAT = 'getChat';
|
||||||
|
case GET_CHAT_ADMINISTRATORS = 'getChatAdministrators';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a command on the provided bot with the given parameters.
|
* Executes a command on the provided bot with the given parameters.
|
||||||
|
@ -185,7 +187,8 @@
|
||||||
self::UNPIN_CHAT_MESSAGE => UnpinChatMessage::execute($bot, $parameters),
|
self::UNPIN_CHAT_MESSAGE => UnpinChatMessage::execute($bot, $parameters),
|
||||||
self::UNPIN_ALL_CHAT_MESSAGES => UnpinAllChatMessages::execute($bot, $parameters),
|
self::UNPIN_ALL_CHAT_MESSAGES => UnpinAllChatMessages::execute($bot, $parameters),
|
||||||
self::LEAVE_CHAT => LeaveChat::execute($bot, $parameters),
|
self::LEAVE_CHAT => LeaveChat::execute($bot, $parameters),
|
||||||
self::GET_CHAT => GetChat::execute($bot, $parameters)
|
self::GET_CHAT => GetChat::execute($bot, $parameters),
|
||||||
|
self::GET_CHAT_ADMINISTRATORS => GetChatAdministrators::execute($bot, $parameters),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
42
src/TgBotLib/Methods/GetChatAdministrators.php
Normal file
42
src/TgBotLib/Methods/GetChatAdministrators.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TgBotLib\Methods;
|
||||||
|
|
||||||
|
use TgBotLib\Abstracts\Method;
|
||||||
|
use TgBotLib\Bot;
|
||||||
|
use TgBotLib\Enums\Methods;
|
||||||
|
use TgBotLib\Objects\ChatMember;
|
||||||
|
use TgBotLib\Objects\Update;
|
||||||
|
|
||||||
|
class GetChatAdministrators extends Method
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function execute(Bot $bot, array $parameters = []): array
|
||||||
|
{
|
||||||
|
return array_map(
|
||||||
|
fn($update) => ChatMember::fromArray($update),
|
||||||
|
self::executeCurl(self::buildPost($bot, Methods::GET_CHAT_ADMINISTRATORS->value, $parameters))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getRequiredParameters(): ?array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'chat_id'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getOptionalParameters(): ?array
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue