From 37a136adce6de8fd2edb57c17323f3ead07f5344 Mon Sep 17 00:00:00 2001 From: Netkas Date: Mon, 10 Apr 2023 16:10:19 -0400 Subject: [PATCH] Added method `\TgBotLib\Bot > addStickerToSet()` to add a new sticker to a set created by the bot. See [addStickerToSet](https://core.telegram.org/bots/api#addstickertoset) for more information. https://git.n64.cc/nosial/libs/tgbot/-/issues/2 --- CHANGELOG.md | 2 ++ src/TgBotLib/Bot.php | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8e6234..ae7ee4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ This update accompanies the release of the [Telegram Bot API 6.6](https://core.t * Added method `\TgBotLib\Bot > createNewStickerSet()` to create a new sticker set owned by a user. See [createNewStickerSet](https://core.telegram.org/bots/api#createnewstickerset) for more information. * Added the field _needs_repainting_ to the [Sticker](https://core.telegram.org/bots/api#sticker) class which can be obtained via `TgBotLib\Objects\Telegram > Sticker > needsRepainting()` + * Added method `\TgBotLib\Bot > addStickerToSet()` to add a new sticker to a set created by the bot. + See [addStickerToSet](https://core.telegram.org/bots/api#addstickertoset) for more information. ### Changed * Removed unused `__destruct()` method from `\TgBotLib\Bot` diff --git a/src/TgBotLib/Bot.php b/src/TgBotLib/Bot.php index eccd83b..640197e 100644 --- a/src/TgBotLib/Bot.php +++ b/src/TgBotLib/Bot.php @@ -2501,4 +2501,29 @@ return true; } + + /** + * Use this method to add a new sticker to a set created by the bot. The format of the added sticker must match + * the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers. Animated and + * video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. + * Returns True on success. + * + * @param int $user_id User identifier of sticker set owner + * @param string $name Sticker set name + * @param array $sticker An InputSticker object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn't changed. + * @return bool + * @throws TelegramException + * @link https://core.telegram.org/bots/api#addstickertoset + * @noinspection PhpUnused + */ + public function addStickerToSet(int $user_id, string $name, array $sticker): bool + { + $this->sendRequest('addStickerToSet', [ + 'user_id' => $user_id, + 'name' => $name, + 'sticker' => $sticker + ]); + + return true; + } } \ No newline at end of file