Add SetMessageReaction method
This commit is contained in:
parent
547c19888a
commit
7b16b2bbc6
2 changed files with 49 additions and 0 deletions
46
src/TgBotLib/Methods/SetMessageReaction.php
Normal file
46
src/TgBotLib/Methods/SetMessageReaction.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Objects\ReactionType;
|
||||
|
||||
class SetMessageReaction extends Method
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): bool
|
||||
{
|
||||
if (isset($parameters['reaction']) && is_array($parameters['reaction']))
|
||||
{
|
||||
$parameters['reaction'] = json_encode(array_map(function (ReactionType|string $reaction) {return is_string($reaction) ? $reaction : $reaction->value;}, $parameters['reaction']));
|
||||
}
|
||||
|
||||
return self::executeCurl(self::buildPost($bot, Methods::SET_MESSAGE_REACTION->value, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'chat_id',
|
||||
'message_id'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'reaction',
|
||||
'is_big'
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue