Add SetMessageReaction method
This commit is contained in:
parent
547c19888a
commit
7b16b2bbc6
2 changed files with 49 additions and 0 deletions
|
@ -31,6 +31,7 @@
|
||||||
use TgBotLib\Methods\SendVideo;
|
use TgBotLib\Methods\SendVideo;
|
||||||
use TgBotLib\Methods\SendVideoNote;
|
use TgBotLib\Methods\SendVideoNote;
|
||||||
use TgBotLib\Methods\SendVoice;
|
use TgBotLib\Methods\SendVoice;
|
||||||
|
use TgBotLib\Methods\SetMessageReaction;
|
||||||
use TgBotLib\Methods\SetWebhook;
|
use TgBotLib\Methods\SetWebhook;
|
||||||
|
|
||||||
enum Methods : string
|
enum Methods : string
|
||||||
|
@ -62,6 +63,7 @@
|
||||||
case SEND_CHAT_ACTION = 'sendChatAction';
|
case SEND_CHAT_ACTION = 'sendChatAction';
|
||||||
case DELETE_WEBHOOK = 'deleteWebhook';
|
case DELETE_WEBHOOK = 'deleteWebhook';
|
||||||
case GET_WEBHOOK_INFO = 'getWebhookInfo';
|
case GET_WEBHOOK_INFO = 'getWebhookInfo';
|
||||||
|
case SET_MESSAGE_REACTION = 'setMessageReaction';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a command on the provided bot with the given parameters.
|
* Executes a command on the provided bot with the given parameters.
|
||||||
|
@ -102,6 +104,7 @@
|
||||||
self::SEND_POLL => SendPoll::execute($bot, $parameters),
|
self::SEND_POLL => SendPoll::execute($bot, $parameters),
|
||||||
self::SEND_DICE => SendDice::execute($bot, $parameters),
|
self::SEND_DICE => SendDice::execute($bot, $parameters),
|
||||||
self::SEND_CHAT_ACTION => SendChatAction::execute($bot, $parameters),
|
self::SEND_CHAT_ACTION => SendChatAction::execute($bot, $parameters),
|
||||||
|
self::SET_MESSAGE_REACTION => SetMessageReaction::execute($bot, $parameters),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
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
Reference in a new issue