Skip to content

Commit 6ad9115

Browse files
Merge pull request yagop#846 from elihaidv/master
setStickerSetThumb function added
2 parents 72feca3 + 7738677 commit 6ad9115

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/telegram.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,38 @@ class TelegramBot extends EventEmitter {
23352335
}
23362336
return this._request('addStickerToSet', opts);
23372337
}
2338+
2339+
/**
2340+
* Use this method to add a thumb to a set created by the bot.
2341+
* Returns True on success.
2342+
*
2343+
* @param {Number} userId User identifier of sticker set owner
2344+
* @param {String} name Sticker set name
2345+
* @param {String|stream.Stream|Buffer} pngThumb A PNG image with the thumbnail,
2346+
* must be up to 128 kilobytes in size and have width and height exactly 100px,
2347+
* or a TGS animation with the thumbnail up to 32 kilobytes in size;
2348+
* @param {Object} [options] Additional Telegram query options
2349+
* @param {Object} [fileOptions] Optional file related meta-data
2350+
* @return {Promise}
2351+
* @see https://core.telegram.org/bots/api#setstickersetthumb
2352+
* @todo Add tests for this method!
2353+
*/
2354+
setStickerSetThumb(userId, name, pngThumb, options = {}, fileOptions = {}) {
2355+
const opts = {
2356+
qs: options,
2357+
};
2358+
opts.qs.user_id = userId;
2359+
opts.qs.name = name;
2360+
opts.qs.mask_position = stringify(options.mask_position);
2361+
try {
2362+
const sendData = this._formatSendData('thumb', pngThumb, fileOptions);
2363+
opts.formData = sendData[0];
2364+
opts.qs.thumb = sendData[1];
2365+
} catch (ex) {
2366+
return Promise.reject(ex);
2367+
}
2368+
return this._request('setStickerSetThumb', opts);
2369+
}
23382370

23392371
/**
23402372
* Use this method to move a sticker in a set created by the bot to a specific position.

0 commit comments

Comments
 (0)