2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-22 18:07:16 +00:00

src: Add fileOptions to remaining file-sending methods

This commit is contained in:
GochoMugo 2017-12-05 14:30:45 +03:00
parent 3b603b1dbd
commit 8edb687283
No known key found for this signature in database
GPG Key ID: 7B6A01CB57AA39E4
2 changed files with 36 additions and 24 deletions

View File

@ -22,7 +22,7 @@ TelegramBot
* [.closeWebHook()](#TelegramBot+closeWebHook) ⇒ <code>Promise</code> * [.closeWebHook()](#TelegramBot+closeWebHook) ⇒ <code>Promise</code>
* [.hasOpenWebHook()](#TelegramBot+hasOpenWebHook) ⇒ <code>Boolean</code> * [.hasOpenWebHook()](#TelegramBot+hasOpenWebHook) ⇒ <code>Boolean</code>
* [.getMe([options])](#TelegramBot+getMe) ⇒ <code>Promise</code> * [.getMe([options])](#TelegramBot+getMe) ⇒ <code>Promise</code>
* [.setWebHook(url, [options])](#TelegramBot+setWebHook) ⇒ <code>Promise</code> * [.setWebHook(url, [options], [fileOptions])](#TelegramBot+setWebHook) ⇒ <code>Promise</code>
* [.deleteWebHook([options])](#TelegramBot+deleteWebHook) ⇒ <code>Promise</code> * [.deleteWebHook([options])](#TelegramBot+deleteWebHook) ⇒ <code>Promise</code>
* [.getWebHookInfo([options])](#TelegramBot+getWebHookInfo) ⇒ <code>Promise</code> * [.getWebHookInfo([options])](#TelegramBot+getWebHookInfo) ⇒ <code>Promise</code>
* [.getUpdates([options])](#TelegramBot+getUpdates) ⇒ <code>Promise</code> * [.getUpdates([options])](#TelegramBot+getUpdates) ⇒ <code>Promise</code>
@ -33,7 +33,7 @@ TelegramBot
* [.sendPhoto(chatId, photo, [options], [fileOptions])](#TelegramBot+sendPhoto) ⇒ <code>Promise</code> * [.sendPhoto(chatId, photo, [options], [fileOptions])](#TelegramBot+sendPhoto) ⇒ <code>Promise</code>
* [.sendAudio(chatId, audio, [options], [fileOptions])](#TelegramBot+sendAudio) ⇒ <code>Promise</code> * [.sendAudio(chatId, audio, [options], [fileOptions])](#TelegramBot+sendAudio) ⇒ <code>Promise</code>
* [.sendDocument(chatId, doc, [options], [fileOptions])](#TelegramBot+sendDocument) ⇒ <code>Promise</code> * [.sendDocument(chatId, doc, [options], [fileOptions])](#TelegramBot+sendDocument) ⇒ <code>Promise</code>
* [.sendSticker(chatId, sticker, [options])](#TelegramBot+sendSticker) ⇒ <code>Promise</code> * [.sendSticker(chatId, sticker, [options], [fileOptions])](#TelegramBot+sendSticker) ⇒ <code>Promise</code>
* [.sendVideo(chatId, video, [options], [fileOptions])](#TelegramBot+sendVideo) ⇒ <code>Promise</code> * [.sendVideo(chatId, video, [options], [fileOptions])](#TelegramBot+sendVideo) ⇒ <code>Promise</code>
* [.sendVideoNote(chatId, videoNote, [options], [fileOptions])](#TelegramBot+sendVideoNote) ⇒ <code>Promise</code> * [.sendVideoNote(chatId, videoNote, [options], [fileOptions])](#TelegramBot+sendVideoNote) ⇒ <code>Promise</code>
* [.sendVoice(chatId, voice, [options], [fileOptions])](#TelegramBot+sendVoice) ⇒ <code>Promise</code> * [.sendVoice(chatId, voice, [options], [fileOptions])](#TelegramBot+sendVoice) ⇒ <code>Promise</code>
@ -43,7 +43,7 @@ TelegramBot
* [.restrictChatMember(chatId, userId, [options])](#TelegramBot+restrictChatMember) ⇒ <code>Promise</code> * [.restrictChatMember(chatId, userId, [options])](#TelegramBot+restrictChatMember) ⇒ <code>Promise</code>
* [.promoteChatMember(chatId, userId, [options])](#TelegramBot+promoteChatMember) ⇒ <code>Promise</code> * [.promoteChatMember(chatId, userId, [options])](#TelegramBot+promoteChatMember) ⇒ <code>Promise</code>
* [.exportChatInviteLink(chatId, [options])](#TelegramBot+exportChatInviteLink) ⇒ <code>Promise</code> * [.exportChatInviteLink(chatId, [options])](#TelegramBot+exportChatInviteLink) ⇒ <code>Promise</code>
* [.setChatPhoto(chatId, photo, [options])](#TelegramBot+setChatPhoto) ⇒ <code>Promise</code> * [.setChatPhoto(chatId, photo, [options], [fileOptions])](#TelegramBot+setChatPhoto) ⇒ <code>Promise</code>
* [.deleteChatPhoto(chatId, [options])](#TelegramBot+deleteChatPhoto) ⇒ <code>Promise</code> * [.deleteChatPhoto(chatId, [options])](#TelegramBot+deleteChatPhoto) ⇒ <code>Promise</code>
* [.setChatTitle(chatId, title, [options])](#TelegramBot+setChatTitle) ⇒ <code>Promise</code> * [.setChatTitle(chatId, title, [options])](#TelegramBot+setChatTitle) ⇒ <code>Promise</code>
* [.setChatDescription(chatId, description, [options])](#TelegramBot+setChatDescription) ⇒ <code>Promise</code> * [.setChatDescription(chatId, description, [options])](#TelegramBot+setChatDescription) ⇒ <code>Promise</code>
@ -81,9 +81,9 @@ TelegramBot
* [.answerShippingQuery(shippingQueryId, ok, [options])](#TelegramBot+answerShippingQuery) ⇒ <code>Promise</code> * [.answerShippingQuery(shippingQueryId, ok, [options])](#TelegramBot+answerShippingQuery) ⇒ <code>Promise</code>
* [.answerPreCheckoutQuery(preCheckoutQueryId, ok, [options])](#TelegramBot+answerPreCheckoutQuery) ⇒ <code>Promise</code> * [.answerPreCheckoutQuery(preCheckoutQueryId, ok, [options])](#TelegramBot+answerPreCheckoutQuery) ⇒ <code>Promise</code>
* [.getStickerSet(name, [options])](#TelegramBot+getStickerSet) ⇒ <code>Promise</code> * [.getStickerSet(name, [options])](#TelegramBot+getStickerSet) ⇒ <code>Promise</code>
* [.uploadStickerFile(userId, pngSticker, [options])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code> * [.uploadStickerFile(userId, pngSticker, [options], [fileOptions])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code>
* [.createNewStickerSet(userId, name, title, pngSticker, emojis, [options])](#TelegramBot+createNewStickerSet) ⇒ <code>Promise</code> * [.createNewStickerSet(userId, name, title, pngSticker, emojis, [options], [fileOptions])](#TelegramBot+createNewStickerSet) ⇒ <code>Promise</code>
* [.addStickerToSet(userId, name, pngSticker, emojis, [options])](#TelegramBot+addStickerToSet) ⇒ <code>Promise</code> * [.addStickerToSet(userId, name, pngSticker, emojis, [options], [fileOptions])](#TelegramBot+addStickerToSet) ⇒ <code>Promise</code>
* [.setStickerPositionInSet(sticker, position, [options])](#TelegramBot+setStickerPositionInSet) ⇒ <code>Promise</code> * [.setStickerPositionInSet(sticker, position, [options])](#TelegramBot+setStickerPositionInSet) ⇒ <code>Promise</code>
* [.deleteStickerFromSet(sticker, [options])](#TelegramBot+deleteStickerFromSet) ⇒ <code>Promise</code> * [.deleteStickerFromSet(sticker, [options])](#TelegramBot+deleteStickerFromSet) ⇒ <code>Promise</code>
* _static_ * _static_
@ -225,7 +225,7 @@ Returns basic information about the bot in form of a `User` object.
<a name="TelegramBot+setWebHook"></a> <a name="TelegramBot+setWebHook"></a>
### telegramBot.setWebHook(url, [options]) ⇒ <code>Promise</code> ### telegramBot.setWebHook(url, [options], [fileOptions]) ⇒ <code>Promise</code>
Specify an url to receive incoming updates via an outgoing webHook. Specify an url to receive incoming updates via an outgoing webHook.
This method has an [older, compatible signature][setWebHook-v0.25.0] This method has an [older, compatible signature][setWebHook-v0.25.0]
that is being deprecated. that is being deprecated.
@ -238,6 +238,7 @@ that is being deprecated.
| url | <code>String</code> | URL where Telegram will make HTTP Post. Leave empty to delete webHook. | | url | <code>String</code> | URL where Telegram will make HTTP Post. Leave empty to delete webHook. |
| [options] | <code>Object</code> | Additional Telegram query options | | [options] | <code>Object</code> | Additional Telegram query options |
| [options.certificate] | <code>String</code> &#124; <code>stream.Stream</code> | PEM certificate key (public). | | [options.certificate] | <code>String</code> &#124; <code>stream.Stream</code> | PEM certificate key (public). |
| [fileOptions] | <code>Object</code> | Optional file related meta-data |
<a name="TelegramBot+deleteWebHook"></a> <a name="TelegramBot+deleteWebHook"></a>
@ -396,7 +397,7 @@ Send Document
<a name="TelegramBot+sendSticker"></a> <a name="TelegramBot+sendSticker"></a>
### telegramBot.sendSticker(chatId, sticker, [options]) ⇒ <code>Promise</code> ### telegramBot.sendSticker(chatId, sticker, [options], [fileOptions]) ⇒ <code>Promise</code>
Send .webp stickers. Send .webp stickers.
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code> **Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
@ -407,6 +408,7 @@ Send .webp stickers.
| chatId | <code>Number</code> &#124; <code>String</code> | Unique identifier for the message recipient | | chatId | <code>Number</code> &#124; <code>String</code> | Unique identifier for the message recipient |
| sticker | <code>String</code> &#124; <code>stream.Stream</code> &#124; <code>Buffer</code> | A file path, Stream or Buffer. Can also be a `file_id` previously uploaded. Stickers are WebP format files. | | sticker | <code>String</code> &#124; <code>stream.Stream</code> &#124; <code>Buffer</code> | A file path, Stream or Buffer. Can also be a `file_id` previously uploaded. Stickers are WebP format files. |
| [options] | <code>Object</code> | Additional Telegram query options | | [options] | <code>Object</code> | Additional Telegram query options |
| [fileOptions] | <code>Object</code> | Optional file related meta-data |
<a name="TelegramBot+sendVideo"></a> <a name="TelegramBot+sendVideo"></a>
@ -570,7 +572,7 @@ Returns exported invite link as String on success.
<a name="TelegramBot+setChatPhoto"></a> <a name="TelegramBot+setChatPhoto"></a>
### telegramBot.setChatPhoto(chatId, photo, [options]) ⇒ <code>Promise</code> ### telegramBot.setChatPhoto(chatId, photo, [options], [fileOptions]) ⇒ <code>Promise</code>
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. Use this method to set a new profile photo for the chat. Photos can't be changed for private chats.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Returns True on success. Returns True on success.
@ -583,6 +585,7 @@ Returns True on success.
| chatId | <code>Number</code> &#124; <code>String</code> | Unique identifier for the message recipient | | chatId | <code>Number</code> &#124; <code>String</code> | Unique identifier for the message recipient |
| photo | <code>stream.Stream</code> &#124; <code>Buffer</code> | A file path or a Stream. | | photo | <code>stream.Stream</code> &#124; <code>Buffer</code> | A file path or a Stream. |
| [options] | <code>Object</code> | Additional Telegram query options | | [options] | <code>Object</code> | Additional Telegram query options |
| [fileOptions] | <code>Object</code> | Optional file related meta-data |
<a name="TelegramBot+deleteChatPhoto"></a> <a name="TelegramBot+deleteChatPhoto"></a>
@ -1154,7 +1157,7 @@ Use this method to get a sticker set. On success, a [StickerSet](https://core.te
<a name="TelegramBot+uploadStickerFile"></a> <a name="TelegramBot+uploadStickerFile"></a>
### telegramBot.uploadStickerFile(userId, pngSticker, [options]) ⇒ <code>Promise</code> ### telegramBot.uploadStickerFile(userId, pngSticker, [options], [fileOptions]) ⇒ <code>Promise</code>
Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
times). Returns the uploaded [File](https://core.telegram.org/bots/api#file) on success. times). Returns the uploaded [File](https://core.telegram.org/bots/api#file) on success.
@ -1166,10 +1169,11 @@ times). Returns the uploaded [File](https://core.telegram.org/bots/api#file) on
| userId | <code>Number</code> | User identifier of sticker file owner | | userId | <code>Number</code> | User identifier of sticker file owner |
| pngSticker | <code>String</code> &#124; <code>stream.Stream</code> &#124; <code>Buffer</code> | A file path or a Stream. Can also be a `file_id` previously uploaded. **Png** image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. | | pngSticker | <code>String</code> &#124; <code>stream.Stream</code> &#124; <code>Buffer</code> | A file path or a Stream. Can also be a `file_id` previously uploaded. **Png** image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. |
| [options] | <code>Object</code> | Additional Telegram query options | | [options] | <code>Object</code> | Additional Telegram query options |
| [fileOptions] | <code>Object</code> | Optional file related meta-data |
<a name="TelegramBot+createNewStickerSet"></a> <a name="TelegramBot+createNewStickerSet"></a>
### telegramBot.createNewStickerSet(userId, name, title, pngSticker, emojis, [options]) ⇒ <code>Promise</code> ### telegramBot.createNewStickerSet(userId, name, title, pngSticker, emojis, [options], [fileOptions]) ⇒ <code>Promise</code>
Use this method to create new sticker set owned by a user. Use this method to create new sticker set owned by a user.
The bot will be able to edit the created sticker set. The bot will be able to edit the created sticker set.
Returns True on success. Returns True on success.
@ -1189,10 +1193,11 @@ Returns True on success.
| pngSticker | <code>String</code> &#124; <code>stream.Stream</code> &#124; <code>Buffer</code> | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. | | pngSticker | <code>String</code> &#124; <code>stream.Stream</code> &#124; <code>Buffer</code> | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. |
| emojis | <code>String</code> | One or more emoji corresponding to the sticker | | emojis | <code>String</code> | One or more emoji corresponding to the sticker |
| [options] | <code>Object</code> | Additional Telegram query options | | [options] | <code>Object</code> | Additional Telegram query options |
| [fileOptions] | <code>Object</code> | Optional file related meta-data |
<a name="TelegramBot+addStickerToSet"></a> <a name="TelegramBot+addStickerToSet"></a>
### telegramBot.addStickerToSet(userId, name, pngSticker, emojis, [options]) ⇒ <code>Promise</code> ### telegramBot.addStickerToSet(userId, name, pngSticker, emojis, [options], [fileOptions]) ⇒ <code>Promise</code>
Use this method to add a new sticker to a set created by the bot. Use this method to add a new sticker to a set created by the bot.
Returns True on success. Returns True on success.
@ -1210,6 +1215,7 @@ Returns True on success.
| pngSticker | <code>String</code> &#124; <code>stream.Stream</code> &#124; <code>Buffer</code> | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px | | pngSticker | <code>String</code> &#124; <code>stream.Stream</code> &#124; <code>Buffer</code> | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px |
| emojis | <code>String</code> | One or more emoji corresponding to the sticker | | emojis | <code>String</code> | One or more emoji corresponding to the sticker |
| [options] | <code>Object</code> | Additional Telegram query options | | [options] | <code>Object</code> | Additional Telegram query options |
| [fileOptions] | <code>Object</code> | Optional file related meta-data |
<a name="TelegramBot+setStickerPositionInSet"></a> <a name="TelegramBot+setStickerPositionInSet"></a>

View File

@ -469,10 +469,11 @@ class TelegramBot extends EventEmitter {
* delete webHook. * delete webHook.
* @param {Object} [options] Additional Telegram query options * @param {Object} [options] Additional Telegram query options
* @param {String|stream.Stream} [options.certificate] PEM certificate key (public). * @param {String|stream.Stream} [options.certificate] PEM certificate key (public).
* @param {Object} [fileOptions] Optional file related meta-data
* @return {Promise} * @return {Promise}
* @see https://core.telegram.org/bots/api#setwebhook * @see https://core.telegram.org/bots/api#setwebhook
*/ */
setWebHook(url, options = {}) { setWebHook(url, options = {}, fileOptions = {}) {
/* The older method signature was setWebHook(url, cert). /* The older method signature was setWebHook(url, cert).
* We need to ensure backwards-compatibility while maintaining * We need to ensure backwards-compatibility while maintaining
* consistency of the method signatures throughout the library */ * consistency of the method signatures throughout the library */
@ -493,7 +494,7 @@ class TelegramBot extends EventEmitter {
if (cert) { if (cert) {
try { try {
const sendData = this._formatSendData('certificate', cert); const sendData = this._formatSendData('certificate', cert, fileOptions);
opts.formData = sendData[0]; opts.formData = sendData[0];
opts.qs.certificate = sendData[1]; opts.qs.certificate = sendData[1];
} catch (ex) { } catch (ex) {
@ -781,16 +782,17 @@ class TelegramBot extends EventEmitter {
* @param {String|stream.Stream|Buffer} sticker A file path, Stream or Buffer. * @param {String|stream.Stream|Buffer} sticker A file path, Stream or Buffer.
* Can also be a `file_id` previously uploaded. Stickers are WebP format files. * Can also be a `file_id` previously uploaded. Stickers are WebP format files.
* @param {Object} [options] Additional Telegram query options * @param {Object} [options] Additional Telegram query options
* @param {Object} [fileOptions] Optional file related meta-data
* @return {Promise} * @return {Promise}
* @see https://core.telegram.org/bots/api#sendsticker * @see https://core.telegram.org/bots/api#sendsticker
*/ */
sendSticker(chatId, sticker, options = {}) { sendSticker(chatId, sticker, options = {}, fileOptions = {}) {
const opts = { const opts = {
qs: options qs: options
}; };
opts.qs.chat_id = chatId; opts.qs.chat_id = chatId;
try { try {
const sendData = this._formatSendData('sticker', sticker); const sendData = this._formatSendData('sticker', sticker, fileOptions);
opts.formData = sendData[0]; opts.formData = sendData[0];
opts.qs.sticker = sendData[1]; opts.qs.sticker = sendData[1];
} catch (ex) { } catch (ex) {
@ -994,16 +996,17 @@ class TelegramBot extends EventEmitter {
* @param {Number|String} chatId Unique identifier for the message recipient * @param {Number|String} chatId Unique identifier for the message recipient
* @param {stream.Stream|Buffer} photo A file path or a Stream. * @param {stream.Stream|Buffer} photo A file path or a Stream.
* @param {Object} [options] Additional Telegram query options * @param {Object} [options] Additional Telegram query options
* @param {Object} [fileOptions] Optional file related meta-data
* @return {Promise} * @return {Promise}
* @see https://core.telegram.org/bots/api#setchatphoto * @see https://core.telegram.org/bots/api#setchatphoto
*/ */
setChatPhoto(chatId, photo, options = {}) { setChatPhoto(chatId, photo, options = {}, fileOptions = {}) {
const opts = { const opts = {
qs: options, qs: options,
}; };
opts.qs.chat_id = chatId; opts.qs.chat_id = chatId;
try { try {
const sendData = this._formatSendData('photo', photo); const sendData = this._formatSendData('photo', photo, fileOptions);
opts.formData = sendData[0]; opts.formData = sendData[0];
opts.qs.photo = sendData[1]; opts.qs.photo = sendData[1];
} catch (ex) { } catch (ex) {
@ -1659,16 +1662,17 @@ class TelegramBot extends EventEmitter {
* @param {String|stream.Stream|Buffer} pngSticker A file path or a Stream. Can also be a `file_id` previously uploaded. **Png** image with the * @param {String|stream.Stream|Buffer} pngSticker A file path or a Stream. Can also be a `file_id` previously uploaded. **Png** image with the
* sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. * sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
* @param {Object} [options] Additional Telegram query options * @param {Object} [options] Additional Telegram query options
* @param {Object} [fileOptions] Optional file related meta-data
* @return {Promise} * @return {Promise}
* @see https://core.telegram.org/bots/api#uploadstickerfile * @see https://core.telegram.org/bots/api#uploadstickerfile
*/ */
uploadStickerFile(userId, pngSticker, options = {}) { uploadStickerFile(userId, pngSticker, options = {}, fileOptions = {}) {
const opts = { const opts = {
qs: options, qs: options,
}; };
opts.qs.user_id = userId; opts.qs.user_id = userId;
try { try {
const sendData = this._formatSendData('png_sticker', pngSticker); const sendData = this._formatSendData('png_sticker', pngSticker, fileOptions);
opts.formData = sendData[0]; opts.formData = sendData[0];
opts.qs.png_sticker = sendData[1]; opts.qs.png_sticker = sendData[1];
} catch (ex) { } catch (ex) {
@ -1689,11 +1693,12 @@ class TelegramBot extends EventEmitter {
* dimensions must not exceed 512px, and either width or height must be exactly 512px. * dimensions must not exceed 512px, and either width or height must be exactly 512px.
* @param {String} emojis One or more emoji corresponding to the sticker * @param {String} emojis One or more emoji corresponding to the sticker
* @param {Object} [options] Additional Telegram query options * @param {Object} [options] Additional Telegram query options
* @param {Object} [fileOptions] Optional file related meta-data
* @return {Promise} * @return {Promise}
* @see https://core.telegram.org/bots/api#createnewstickerset * @see https://core.telegram.org/bots/api#createnewstickerset
* @todo Add tests for this method! * @todo Add tests for this method!
*/ */
createNewStickerSet(userId, name, title, pngSticker, emojis, options = {}) { createNewStickerSet(userId, name, title, pngSticker, emojis, options = {}, fileOptions = {}) {
const opts = { const opts = {
qs: options, qs: options,
}; };
@ -1703,7 +1708,7 @@ class TelegramBot extends EventEmitter {
opts.qs.emojis = emojis; opts.qs.emojis = emojis;
opts.qs.mask_position = stringify(options.mask_position); opts.qs.mask_position = stringify(options.mask_position);
try { try {
const sendData = this._formatSendData('png_sticker', pngSticker); const sendData = this._formatSendData('png_sticker', pngSticker, fileOptions);
opts.formData = sendData[0]; opts.formData = sendData[0];
opts.qs.png_sticker = sendData[1]; opts.qs.png_sticker = sendData[1];
} catch (ex) { } catch (ex) {
@ -1722,11 +1727,12 @@ class TelegramBot extends EventEmitter {
* dimensions must not exceed 512px, and either width or height must be exactly 512px * dimensions must not exceed 512px, and either width or height must be exactly 512px
* @param {String} emojis One or more emoji corresponding to the sticker * @param {String} emojis One or more emoji corresponding to the sticker
* @param {Object} [options] Additional Telegram query options * @param {Object} [options] Additional Telegram query options
* @param {Object} [fileOptions] Optional file related meta-data
* @return {Promise} * @return {Promise}
* @see https://core.telegram.org/bots/api#addstickertoset * @see https://core.telegram.org/bots/api#addstickertoset
* @todo Add tests for this method! * @todo Add tests for this method!
*/ */
addStickerToSet(userId, name, pngSticker, emojis, options = {}) { addStickerToSet(userId, name, pngSticker, emojis, options = {}, fileOptions = {}) {
const opts = { const opts = {
qs: options, qs: options,
}; };
@ -1735,7 +1741,7 @@ class TelegramBot extends EventEmitter {
opts.qs.emojis = emojis; opts.qs.emojis = emojis;
opts.qs.mask_position = stringify(options.mask_position); opts.qs.mask_position = stringify(options.mask_position);
try { try {
const sendData = this._formatSendData('png_sticker', pngSticker); const sendData = this._formatSendData('png_sticker', pngSticker, fileOptions);
opts.formData = sendData[0]; opts.formData = sendData[0];
opts.qs.png_sticker = sendData[1]; opts.qs.png_sticker = sendData[1];
} catch (ex) { } catch (ex) {