Added method \TgBotLib\Bot > sendSticker() to send a sticker to a chat. See [sendSticker](https://core.telegram.org/bots/api#sendsticker) for more information.

This commit is contained in:
Netkas 2023-04-06 13:54:48 -04:00
parent 38012104ae
commit 8965ac3aff
2 changed files with 45 additions and 0 deletions

View file

@ -18,6 +18,7 @@ This update accompanies the release of the [Telegram Bot API 6.6](https://core.t
see [setMyShortDescription](https://core.telegram.org/bots/api#setmyshortdescription) for more information.
* Added the ability to get the current bot short description in the given language as the class [BotShortDescription](https://core.telegram.org/bots/api#botshortdescription)
using the method `\TgBotLib\Bot > getMyShortDescription()` see [getMyShortDescription](https://core.telegram.org/bots/api#getmyshortdescription) for more information.
* Added method `\TgBotLib\Bot > sendSticker()` to send a sticker to a chat. See [sendSticker](https://core.telegram.org/bots/api#sendsticker) for more information.
### Changed
* Removed unused `__destruct()` method from `\TgBotLib\Bot`

View file

@ -2415,4 +2415,48 @@
]);
return true;
}
/**
* Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers.
* On success, the sent Message is returned.
*
* @param int|string $chat_id
* @param string $sticker
* @param array $options
* @return Message
* @throws TelegramException
* @link Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned.
* @noinspection PhpUnused
*/
public function sendSticker(int|string $chat_id, string $sticker, array $options=[]): Message
{
if(file_exists($sticker))
{
return Message::fromArray(
$this->sendFileUpload('sendSticker', 'sticker', $sticker, array_merge([
'chat_id' => $chat_id
], $options))
);
}
$tmp_file = new TempFile();
file_put_contents($tmp_file, $sticker);
try
{
$response = Message::fromArray(
$this->sendFileUpload('sendSticker', 'sticker', $tmp_file, array_merge([
'chat_id' => $chat_id
], $options))
);
}
catch(TelegramException $e)
{
unset($tmp_file);
throw $e;
}
unset($tmp_file);
return $response;
}
}