Add SetStickerSetThumbnail method
This commit is contained in:
parent
f5a09f90e9
commit
c5e0e1992a
2 changed files with 57 additions and 0 deletions
|
@ -103,6 +103,7 @@
|
|||
use TgBotLib\Methods\SetStickerEmojiList;
|
||||
use TgBotLib\Methods\SetStickerMaskPosition;
|
||||
use TgBotLib\Methods\SetStickerPositionInSet;
|
||||
use TgBotLib\Methods\SetStickerSetThumbnail;
|
||||
use TgBotLib\Methods\SetStickerSetTitle;
|
||||
use TgBotLib\Methods\SetWebhook;
|
||||
use TgBotLib\Methods\StopMessageLiveLocation;
|
||||
|
@ -228,6 +229,7 @@
|
|||
case SET_STICKER_EMOJI_LIST = 'setStickerEmojiList';
|
||||
case SET_STICKER_MASK_POSITION = 'setStickerMaskPosition';
|
||||
case SET_STICKER_SET_TITLE = 'setStickerSetTitle';
|
||||
case SET_STICKER_SET_THUMBNAIL = 'setStickerSetThumbnail';
|
||||
|
||||
/**
|
||||
* Executes a command on the provided bot with the given parameters.
|
||||
|
@ -351,6 +353,7 @@
|
|||
self::SET_STICKER_EMOJI_LIST => SetStickerEmojiList::execute($bot, $parameters),
|
||||
self::SET_STICKER_MASK_POSITION => SetStickerMaskPosition::execute($bot, $parameters),
|
||||
self::SET_STICKER_SET_TITLE => SetStickerSetTitle::execute($bot, $parameters),
|
||||
self::SET_STICKER_SET_THUMBNAIL => SetStickerSetThumbnail::execute($bot, $parameters),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
54
src/TgBotLib/Methods/SetStickerSetThumbnail.php
Normal file
54
src/TgBotLib/Methods/SetStickerSetThumbnail.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Objects\Message;
|
||||
|
||||
class SetStickerSetThumbnail extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): true
|
||||
{
|
||||
// Handle different thumbnail input types
|
||||
if (isset($parameters['thumbnail']))
|
||||
{
|
||||
$thumbnail = $parameters['thumbnail'];
|
||||
|
||||
// If thumbnail is a file path and exists locally
|
||||
if (is_string($thumbnail) && file_exists($thumbnail) && is_file($thumbnail))
|
||||
{
|
||||
return (bool)self::executeCurl(self::buildUpload($bot, Methods::SET_STICKER_SET_THUMBNAIL->value, 'thumbnail', $thumbnail, array_diff_key($parameters, ['thumbnail' => null])));
|
||||
}
|
||||
}
|
||||
|
||||
return (bool)self::executeCurl(self::buildPost($bot, Methods::SET_STICKER_SET_THUMBNAIL->value, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'name',
|
||||
'user_id',
|
||||
'format'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'thumbnail'
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue