Implemented method sendChatAction
This commit is contained in:
parent
97346e217c
commit
ead1347f34
4 changed files with 179 additions and 3 deletions
47
src/TgBotLib/Methods/SendChatAction.php
Normal file
47
src/TgBotLib/Methods/SendChatAction.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Enums\Types\ChatActionType;
|
||||
use TgBotLib\Objects\Message;
|
||||
|
||||
class SendChatAction extends Method
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): mixed
|
||||
{
|
||||
if($parameters['action'] instanceof ChatActionType)
|
||||
{
|
||||
$parameters['action'] = $parameters['action']->value;
|
||||
}
|
||||
|
||||
return (bool)self::executeCurl(self::buildPost($bot, Methods::SEND_CHAT_ACTION->value, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'chat_id',
|
||||
'action'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'business_connection_id',
|
||||
'message_thread_id'
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue