Skip to content

Commit aa4083d

Browse files
refactor: uploadStickerFile
1 parent 9272423 commit aa4083d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/telegram.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,27 +2443,28 @@ class TelegramBot extends EventEmitter {
24432443
}
24442444

24452445
/**
2446-
* Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
2446+
* Use this method to upload a file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
24472447
* times).
24482448
*
24492449
* @param {Number} userId User identifier of sticker file owner
2450-
* @param {String|stream.Stream|Buffer} pngSticker A file path or a Stream. Can also be a `file_id` previously uploaded. **Png** image with the
2451-
* sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
2450+
* @param {String|stream.Stream|Buffer} sticker A file path or a Stream with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. Can also be a `file_id` previously uploaded.
24522451
* @param {String} stickerFormat Allow values: `static`, `animated` or `video`
24532452
* @param {Object} [options] Additional Telegram query options
24542453
* @param {Object} [fileOptions] Optional file related meta-data
24552454
* @return {Promise} On success, a [File](https://core.telegram.org/bots/api#file) object is returned
24562455
* @see https://core.telegram.org/bots/api#uploadstickerfile
24572456
*/
2458-
uploadStickerFile(userId, sticker, stickerFormat, options = {}, fileOptions = {}) {
2457+
uploadStickerFile(userId, sticker, stickerFormat = 'static', options = {}, fileOptions = {}) {
24592458
const opts = {
24602459
qs: options,
24612460
};
24622461
opts.qs.user_id = userId;
2462+
opts.qs.sticker_format = stickerFormat;
2463+
24632464
try {
2464-
const sendData = this._formatSendData('png_sticker', sticker, fileOptions);
2465+
const sendData = this._formatSendData('sticker', sticker, fileOptions);
24652466
opts.formData = sendData[0];
2466-
opts.qs.png_sticker = sendData[1];
2467+
opts.qs.sticker = sendData[1];
24672468
} catch (ex) {
24682469
return Promise.reject(ex);
24692470
}

0 commit comments

Comments
 (0)