Add GetChat method to retrieve chat details
This commit is contained in:
parent
1661e744ab
commit
4be031f96c
3 changed files with 42 additions and 1 deletions
|
@ -21,6 +21,7 @@
|
||||||
use TgBotLib\Methods\ExportChatInviteLink;
|
use TgBotLib\Methods\ExportChatInviteLink;
|
||||||
use TgBotLib\Methods\ForwardMessage;
|
use TgBotLib\Methods\ForwardMessage;
|
||||||
use TgBotLib\Methods\ForwardMessages;
|
use TgBotLib\Methods\ForwardMessages;
|
||||||
|
use TgBotLib\Methods\GetChat;
|
||||||
use TgBotLib\Methods\GetFile;
|
use TgBotLib\Methods\GetFile;
|
||||||
use TgBotLib\Methods\GetMe;
|
use TgBotLib\Methods\GetMe;
|
||||||
use TgBotLib\Methods\GetUpdates;
|
use TgBotLib\Methods\GetUpdates;
|
||||||
|
@ -116,6 +117,7 @@
|
||||||
case UNPIN_CHAT_MESSAGE = 'unpinChatMessage';
|
case UNPIN_CHAT_MESSAGE = 'unpinChatMessage';
|
||||||
case UNPIN_ALL_CHAT_MESSAGES = 'unpinAllChatMessages';
|
case UNPIN_ALL_CHAT_MESSAGES = 'unpinAllChatMessages';
|
||||||
case LEAVE_CHAT = 'leaveChat';
|
case LEAVE_CHAT = 'leaveChat';
|
||||||
|
case GET_CHAT = 'getChat';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a command on the provided bot with the given parameters.
|
* Executes a command on the provided bot with the given parameters.
|
||||||
|
@ -183,6 +185,7 @@
|
||||||
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)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
38
src/TgBotLib/Methods/GetChat.php
Normal file
38
src/TgBotLib/Methods/GetChat.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TgBotLib\Methods;
|
||||||
|
|
||||||
|
use TgBotLib\Abstracts\Method;
|
||||||
|
use TgBotLib\Bot;
|
||||||
|
use TgBotLib\Enums\Methods;
|
||||||
|
use TgBotLib\Objects\ChatFullInfo;
|
||||||
|
|
||||||
|
class GetChat extends Method
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function execute(Bot $bot, array $parameters = []): ChatFullInfo
|
||||||
|
{
|
||||||
|
return ChatFullInfo::fromArray(self::executeCurl(self::buildPost($bot, Methods::GET_CHAT->value, $parameters)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getRequiredParameters(): ?array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'chat_id'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getOptionalParameters(): ?array
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -569,7 +569,7 @@
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public static function fromArray(?array $data): ?ObjectTypeInterface
|
public static function fromArray(?array $data): ?ChatFullInfo
|
||||||
{
|
{
|
||||||
if($data === null)
|
if($data === null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue