Add GetCustomEmojiStickers method
This commit is contained in:
parent
a5b472794d
commit
36e2305ce7
2 changed files with 48 additions and 0 deletions
|
@ -104,6 +104,7 @@
|
|||
use TgBotLib\Methods\UnpinAllForumTopicMessages;
|
||||
use TgBotLib\Methods\UnpinAllGeneralForumTopicMessages;
|
||||
use TgBotLib\Methods\UnpinChatMessage;
|
||||
use TgBotLib\Objects\GetCustomEmojiStickers;
|
||||
use TgBotLib\Objects\GetStickerSet;
|
||||
|
||||
enum Methods : string
|
||||
|
@ -208,6 +209,7 @@
|
|||
case DELETE_MESSAGES = 'deleteMessages';
|
||||
case SEND_STICKER = 'sendSticker';
|
||||
case GET_STICKER_SET = 'getStickerSet';
|
||||
case GET_CUSTOM_EMOJI_STICKERS = 'getCustomEmojiStickers';
|
||||
|
||||
/**
|
||||
* Executes a command on the provided bot with the given parameters.
|
||||
|
@ -321,6 +323,7 @@
|
|||
self::DELETE_MESSAGES => DeleteMessages::execute($bot, $parameters),
|
||||
self::SEND_STICKER => SendSticker::execute($bot, $parameters),
|
||||
self::GET_STICKER_SET => GetStickerSet::execute($bot, $parameters),
|
||||
self::GET_CUSTOM_EMOJI_STICKERS => GetCustomEmojiStickers::execute($bot, $parameters),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
45
src/TgBotLib/Objects/GetCustomEmojiStickers.php
Normal file
45
src/TgBotLib/Objects/GetCustomEmojiStickers.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Objects\Stickers\Sticker;
|
||||
|
||||
class GetCustomEmojiStickers extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): array
|
||||
{
|
||||
if(isset($parameters['custom_emoji_ids']) && is_array($parameters['custom_emoji_ids']))
|
||||
{
|
||||
$parameters['custom_emoji_ids'] = json_encode($parameters['custom_emoji_ids']);
|
||||
}
|
||||
|
||||
return array_map(function($emoji) {
|
||||
return Sticker::fromArray($emoji);
|
||||
}, self::executeCurl(self::buildPost($bot, Methods::GET_CUSTOM_EMOJI_STICKERS->value, $parameters)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'custom_emoji_ids'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue