diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b9a5082..ecfe391a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,20 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
+## [0.62.0][0.62.0] - 2023-03-19
+
+1. Support Telegram Bot API v6.6 (@danielperez9430)
+ * setMyDescription
+ * getMyDescription
+ * setMyShortDescription
+ * getMyShortDescription
+ * setCustomEmojiStickerSetThumbnail
+ * setStickerSetTitle
+ * deleteStickerSet
+ * setStickerEmojiList
+ * setStickerKeywords
+ * setStickerMaskPosition
+
## [0.61.0][0.61.0] - 2022-12-30
1. Support Telegram Bot API v6.4 (@danielperez9430)
diff --git a/doc/api.md b/doc/api.md
index f309e1e3..773155f9 100644
--- a/doc/api.md
+++ b/doc/api.md
@@ -103,6 +103,12 @@ TelegramBot
* [.setMyCommands(commands, [options])](#TelegramBot+setMyCommands) ⇒ Promise
* [.deleteMyCommands([options])](#TelegramBot+deleteMyCommands) ⇒ Promise
* [.getMyCommands([options])](#TelegramBot+getMyCommands) ⇒ Promise
+ * [.setMyName([options])](#TelegramBot+setMyName) ⇒ Promise
+ * [.getMyName([options])](#TelegramBot+getMyName) ⇒ Promise
+ * [.setMyDescription([options])](#TelegramBot+setMyDescription) ⇒ Promise
+ * [.getMyDescription([options])](#TelegramBot+getMyDescription) ⇒ Promise
+ * [.setMyShortDescription([options])](#TelegramBot+setMyShortDescription) ⇒ Promise
+ * [.getMyShortDescription([options])](#TelegramBot+getMyShortDescription) ⇒ Promise
* [.setChatMenuButton([options])](#TelegramBot+setChatMenuButton) ⇒ Promise
* [.getChatMenuButton([options])](#TelegramBot+getChatMenuButton) ⇒ Promise
* [.setMyDefaultAdministratorRights([options])](#TelegramBot+setMyDefaultAdministratorRights) ⇒ Promise
@@ -116,12 +122,18 @@ TelegramBot
* [.sendSticker(chatId, sticker, [options], [fileOptions])](#TelegramBot+sendSticker) ⇒ Promise
* [.getStickerSet(name, [options])](#TelegramBot+getStickerSet) ⇒ Promise
* [.getCustomEmojiStickers(custom_emoji_ids, [options])](#TelegramBot+getCustomEmojiStickers) ⇒ Promise
- * [.uploadStickerFile(userId, pngSticker, [options], [fileOptions])](#TelegramBot+uploadStickerFile) ⇒ Promise
+ * [.uploadStickerFile(userId, sticker, stickerFormat, [options], [fileOptions])](#TelegramBot+uploadStickerFile) ⇒ Promise
* [.createNewStickerSet(userId, name, title, pngSticker, emojis, [options], [fileOptions])](#TelegramBot+createNewStickerSet) ⇒ Promise
* [.addStickerToSet(userId, name, sticker, emojis, stickerType, [options], [fileOptions])](#TelegramBot+addStickerToSet) ⇒ Promise
* [.setStickerPositionInSet(sticker, position, [options])](#TelegramBot+setStickerPositionInSet) ⇒ Promise
* [.deleteStickerFromSet(sticker, [options])](#TelegramBot+deleteStickerFromSet) ⇒ Promise
- * [.setStickerSetThumb(userId, name, pngThumb, [options], [fileOptions])](#TelegramBot+setStickerSetThumb) ⇒ Promise
+ * [.setStickerEmojiList(sticker, emojiList, [options])](#TelegramBot+setStickerEmojiList) ⇒ Promise
+ * [.setStickerKeywords(sticker, [options])](#TelegramBot+setStickerKeywords) ⇒ Promise
+ * [.setStickerMaskPosition(sticker, [options])](#TelegramBot+setStickerMaskPosition) ⇒ Promise
+ * [.setStickerSetTitle(name, title, [options])](#TelegramBot+setStickerSetTitle) ⇒ Promise
+ * [.setStickerSetThumbnail(userId, name, thumbnail, [options], [fileOptions])](#TelegramBot+setStickerSetThumbnail) ⇒ Promise
+ * [.setCustomEmojiStickerSetThumbnail(name, [options])](#TelegramBot+setCustomEmojiStickerSetThumbnail) ⇒ Promise
+ * [.deleteStickerSet(name, [options])](#TelegramBot+deleteStickerSet) ⇒ Promise
* [.answerInlineQuery(inlineQueryId, results, [options])](#TelegramBot+answerInlineQuery) ⇒ Promise
* [.answerWebAppQuery(webAppQueryId, result, [options])](#TelegramBot+answerWebAppQuery) ⇒ Promise
* [.sendInvoice(chatId, title, description, payload, providerToken, currency, prices, [options])](#TelegramBot+sendInvoice) ⇒ Promise
@@ -1632,6 +1644,87 @@ Use this method to get the current list of the bot's commands for the given scop
| --- | --- | --- |
| [options] | Object
| Additional Telegram query options |
+
+
+### telegramBot.setMyName([options]) ⇒ Promise
+Use this method to change the bot's name.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- True on success
+**See**: https://core.telegram.org/bots/api#setmyname
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [options] | Object
| Additional Telegram query options |
+
+
+
+### telegramBot.getMyName([options]) ⇒ Promise
+Use this method to get the current bot name for the given user language.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- [BotName](https://core.telegram.org/bots/api#botname) on success
+**See**: https://core.telegram.org/bots/api#getmyname
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [options] | Object
| Additional Telegram query options |
+
+
+
+### telegramBot.setMyDescription([options]) ⇒ Promise
+Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
+
+Returns True on success.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- True on success
+**See**: https://core.telegram.org/bots/api#setmydescription
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [options] | Object
| Additional Telegram query options |
+
+
+
+### telegramBot.getMyDescription([options]) ⇒ Promise
+Use this method to get the current bot description for the given user language.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- Returns [BotDescription](https://core.telegram.org/bots/api#botdescription) on success.
+**See**: https://core.telegram.org/bots/api#getmydescription
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [options] | Object
| Additional Telegram query options |
+
+
+
+### telegramBot.setMyShortDescription([options]) ⇒ Promise
+Use this method to change the bot's short description, which is shown on the bot's profile page
+and is sent together with the link when users share the bot.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- Returns True on success.
+**See**: https://core.telegram.org/bots/api#setmyshortdescription
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [options] | Object
| Additional Telegram query options |
+
+
+
+### telegramBot.getMyShortDescription([options]) ⇒ Promise
+Use this method to get the current bot short description for the given user language.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- Returns [BotShortDescription](https://core.telegram.org/bots/api#botshortdescription) on success.
+**See**: https://core.telegram.org/bots/api#getmyshortdescription
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [options] | Object
| Additional Telegram query options |
+
### telegramBot.setChatMenuButton([options]) ⇒ Promise
@@ -1839,20 +1932,21 @@ Use this method to get information about custom emoji stickers by their identifi
-### telegramBot.uploadStickerFile(userId, pngSticker, [options], [fileOptions]) ⇒ Promise
-Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
+### telegramBot.uploadStickerFile(userId, sticker, stickerFormat, [options], [fileOptions]) ⇒ Promise
+Use this method to upload a file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
times).
**Kind**: instance method of [TelegramBot
](#TelegramBot)
**Returns**: Promise
- On success, a [File](https://core.telegram.org/bots/api#file) object is returned
**See**: https://core.telegram.org/bots/api#uploadstickerfile
-| Param | Type | Description |
-| --- | --- | --- |
-| userId | Number
| User identifier of sticker file owner |
-| pngSticker | String
\| stream.Stream
\| Buffer
| 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] | Object
| Additional Telegram query options |
-| [fileOptions] | Object
| Optional file related meta-data |
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| userId | Number
| | User identifier of sticker file owner |
+| sticker | String
\| stream.Stream
\| Buffer
| | A file path or a Stream with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. Can also be a `file_id` previously uploaded. |
+| stickerFormat | String
| static
| Allow values: `static`, `animated` or `video` |
+| [options] | Object
| | Additional Telegram query options |
+| [fileOptions] | Object
| | Optional file related meta-data |
@@ -1935,25 +2029,123 @@ Use this method to delete a sticker from a set created by the bot.
| sticker | String
| File identifier of the sticker |
| [options] | Object
| Additional Telegram query options |
-
+
+
+### telegramBot.setStickerEmojiList(sticker, emojiList, [options]) ⇒ Promise
+Use this method to change the list of emoji assigned to a regular or custom emoji sticker.
+
+The sticker must belong to a sticker set created by the bot.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- True on success
+**See**: https://core.telegram.org/bots/api#setstickeremojilist
+
+| Param | Type | Description |
+| --- | --- | --- |
+| sticker | String
| File identifier of the sticker |
+| emojiList | Array
| A JSON-serialized list of 1-20 emoji associated with the sticker |
+| [options] | Object
| Additional Telegram query options |
+
+
+
+### telegramBot.setStickerKeywords(sticker, [options]) ⇒ Promise
+Use this method to change the list of emoji assigned to a `regular` or `custom emoji` sticker.
+
+The sticker must belong to a sticker set created by the bot.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- True on success
+**See**: https://core.telegram.org/bots/api#setstickerkeywords
+
+| Param | Type | Description |
+| --- | --- | --- |
+| sticker | String
| File identifier of the sticker |
+| [options] | Object
| Additional Telegram query options |
+
+
+
+### telegramBot.setStickerMaskPosition(sticker, [options]) ⇒ Promise
+Use this method to change the [mask position](https://core.telegram.org/bots/api#maskposition) of a mask sticker.
+
+The sticker must belong to a sticker set created by the bot.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- True on success
+**See**: https://core.telegram.org/bots/api#setstickermaskposition
+
+| Param | Type | Description |
+| --- | --- | --- |
+| sticker | String
| File identifier of the sticker |
+| [options] | Object
| Additional Telegram query options |
+
+
+
+### telegramBot.setStickerSetTitle(name, title, [options]) ⇒ Promise
+Use this method to set the title of a created sticker set.
-### telegramBot.setStickerSetThumb(userId, name, pngThumb, [options], [fileOptions]) ⇒ Promise
+The sticker must belong to a sticker set created by the bot.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- True on success
+**See**: https://core.telegram.org/bots/api#setstickersettitle
+
+| Param | Type | Description |
+| --- | --- | --- |
+| name | String
| Sticker set name |
+| title | String
| Sticker set title, 1-64 characters |
+| [options] | Object
| Additional Telegram query options |
+
+
+
+### telegramBot.setStickerSetThumbnail(userId, name, thumbnail, [options], [fileOptions]) ⇒ Promise
Use this method to add a thumb to a set created by the bot.
Animated thumbnails can be set for animated sticker sets only. Video thumbnails can be set only for video sticker sets only
**Kind**: instance method of [TelegramBot
](#TelegramBot)
**Returns**: Promise
- True on success
-**See**: https://core.telegram.org/bots/api#setstickersetthumb
+**See**: https://core.telegram.org/bots/api#setstickersetthumbnail
| Param | Type | Description |
| --- | --- | --- |
| userId | Number
| User identifier of sticker set owner |
| name | String
| Sticker set name |
-| pngThumb | String
\| stream.Stream
\| Buffer
| A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, a TGS animation with the thumbnail up to 32 kilobytes in size or a WEBM video with the thumbnail up to 32 kilobytes in size. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one. Animated sticker set thumbnails can't be uploaded via HTTP URL. |
+| thumbnail | String
\| stream.Stream
\| Buffer
| A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, a TGS animation with the thumbnail up to 32 kilobytes in size or a WEBM video with the thumbnail up to 32 kilobytes in size. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one. Animated sticker set thumbnails can't be uploaded via HTTP URL. |
| [options] | Object
| Additional Telegram query options |
| [fileOptions] | Object
| Optional file related meta-data |
+
+
+### telegramBot.setCustomEmojiStickerSetThumbnail(name, [options]) ⇒ Promise
+Use this method to set the thumbnail of a custom emoji sticker set.
+
+The sticker must belong to a sticker set created by the bot.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- True on success
+**See**: https://core.telegram.org/bots/api#setcustomemojistickersetthumbnail
+
+| Param | Type | Description |
+| --- | --- | --- |
+| name | String
| Sticker set name |
+| [options] | Object
| Additional Telegram query options |
+
+
+
+### telegramBot.deleteStickerSet(name, [options]) ⇒ Promise
+Use this method to delete a sticker set that was created by the bot.
+
+The sticker must belong to a sticker set created by the bot.
+
+**Kind**: instance method of [TelegramBot
](#TelegramBot)
+**Returns**: Promise
- True on success
+**See**: https://core.telegram.org/bots/api#deletestickerset
+
+| Param | Type | Description |
+| --- | --- | --- |
+| name | String
| Sticker set name |
+| [options] | Object
| Additional Telegram query options |
+
### telegramBot.answerInlineQuery(inlineQueryId, results, [options]) ⇒ Promise
diff --git a/src/telegram.js b/src/telegram.js
index 7b9440a3..c826f793 100644
--- a/src/telegram.js
+++ b/src/telegram.js
@@ -237,7 +237,7 @@ class TelegramBot extends EventEmitter {
}
}
- _fixAddFileThumb(options, opts) {
+ _fixAddFileThumbnail(options, opts) {
if (options.thumb) {
if (opts.formData === null) {
opts.formData = {};
@@ -248,7 +248,7 @@ class TelegramBot extends EventEmitter {
if (formData) {
opts.formData[attachName] = formData[attachName];
- opts.qs.thumb = `attach://${attachName}`;
+ opts.qs.thumbnail = `attach://${attachName}`;
}
}
}
@@ -1003,7 +1003,7 @@ class TelegramBot extends EventEmitter {
const sendData = this._formatSendData('audio', audio, fileOptions);
opts.formData = sendData[0];
opts.qs.audio = sendData[1];
- this._fixAddFileThumb(options, opts);
+ this._fixAddFileThumbnail(options, opts);
} catch (ex) {
return Promise.reject(ex);
}
@@ -1031,7 +1031,7 @@ class TelegramBot extends EventEmitter {
const sendData = this._formatSendData('document', doc, fileOptions);
opts.formData = sendData[0];
opts.qs.document = sendData[1];
- this._fixAddFileThumb(options, opts);
+ this._fixAddFileThumbnail(options, opts);
} catch (ex) {
return Promise.reject(ex);
}
@@ -1060,7 +1060,7 @@ class TelegramBot extends EventEmitter {
const sendData = this._formatSendData('video', video, fileOptions);
opts.formData = sendData[0];
opts.qs.video = sendData[1];
- this._fixAddFileThumb(options, opts);
+ this._fixAddFileThumbnail(options, opts);
} catch (ex) {
return Promise.reject(ex);
}
@@ -1143,7 +1143,7 @@ class TelegramBot extends EventEmitter {
const sendData = this._formatSendData('video_note', videoNote, fileOptions);
opts.formData = sendData[0];
opts.qs.video_note = sendData[1];
- this._fixAddFileThumb(options, opts);
+ this._fixAddFileThumbnail(options, opts);
} catch (ex) {
return Promise.reject(ex);
}
@@ -1469,7 +1469,6 @@ class TelegramBot extends EventEmitter {
* The bot **must be an administrator** in the chat for this to work
* and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user.
*
- *
* @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
* @param {Number} userId
* @param {Object} [options] Additional Telegram query options
@@ -2159,6 +2158,75 @@ class TelegramBot extends EventEmitter {
return this._request('getMyCommands', { form });
}
+ /**
+ * Use this method to change the bot's name.
+ *
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} True on success
+ * @see https://core.telegram.org/bots/api#setmyname
+ */
+ setMyName(form = {}) {
+ return this._request('setMyName', { form });
+ }
+
+ /**
+ * Use this method to get the current bot name for the given user language.
+ *
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} [BotName](https://core.telegram.org/bots/api#botname) on success
+ * @see https://core.telegram.org/bots/api#getmyname
+ */
+ getMyName(form = {}) {
+ return this._request('getMyName', { form });
+ }
+
+ /**
+ * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
+ *
+ * Returns True on success.
+ *
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} True on success
+ * @see https://core.telegram.org/bots/api#setmydescription
+ */
+ setMyDescription(form = {}) {
+ return this._request('setMyDescription', { form });
+ }
+
+ /**
+ * Use this method to get the current bot description for the given user language.
+ *
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} Returns [BotDescription](https://core.telegram.org/bots/api#botdescription) on success.
+ * @see https://core.telegram.org/bots/api#getmydescription
+ */
+ getMyDescription(form = {}) {
+ return this._request('getMyDescription', { form });
+ }
+
+ /**
+ * Use this method to change the bot's short description, which is shown on the bot's profile page
+ * and is sent together with the link when users share the bot.
+ *
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} Returns True on success.
+ * @see https://core.telegram.org/bots/api#setmyshortdescription
+ */
+ setMyShortDescription(form = {}) {
+ return this._request('setMyShortDescription', { form });
+ }
+
+ /**
+ * Use this method to get the current bot short description for the given user language.
+ *
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} Returns [BotShortDescription](https://core.telegram.org/bots/api#botshortdescription) on success.
+ * @see https://core.telegram.org/bots/api#getmyshortdescription
+ */
+ getMyShortDescription(form = {}) {
+ return this._request('getMyShortDescription', { form });
+ }
+
/**
* Use this method to change the bot's menu button in a private chat, or the default menu button.
*
@@ -2397,26 +2465,28 @@ class TelegramBot extends EventEmitter {
}
/**
- * 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 file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
* times).
*
* @param {Number} userId User identifier of sticker file owner
- * @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.
+ * @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.
+ * @param {String} stickerFormat Allow values: `static`, `animated` or `video`
* @param {Object} [options] Additional Telegram query options
* @param {Object} [fileOptions] Optional file related meta-data
* @return {Promise} On success, a [File](https://core.telegram.org/bots/api#file) object is returned
* @see https://core.telegram.org/bots/api#uploadstickerfile
*/
- uploadStickerFile(userId, pngSticker, options = {}, fileOptions = {}) {
+ uploadStickerFile(userId, sticker, stickerFormat = 'static', options = {}, fileOptions = {}) {
const opts = {
qs: options,
};
opts.qs.user_id = userId;
+ opts.qs.sticker_format = stickerFormat;
+
try {
- const sendData = this._formatSendData('png_sticker', pngSticker, fileOptions);
+ const sendData = this._formatSendData('sticker', sticker, fileOptions);
opts.formData = sendData[0];
- opts.qs.png_sticker = sendData[1];
+ opts.qs.sticker = sendData[1];
} catch (ex) {
return Promise.reject(ex);
}
@@ -2536,6 +2606,76 @@ class TelegramBot extends EventEmitter {
}
+ /**
+ * Use this method to change the list of emoji assigned to a regular or custom emoji sticker.
+ *
+ * The sticker must belong to a sticker set created by the bot.
+ *
+ * @param {String} sticker File identifier of the sticker
+ * @param { Array } emojiList A JSON-serialized list of 1-20 emoji associated with the sticker
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} True on success
+ * @see https://core.telegram.org/bots/api#setstickeremojilist
+ */
+ setStickerEmojiList(sticker, emojiList, form = {}) {
+ form.sticker = sticker;
+ form.emoji_list = stringify(emojiList);
+ return this._request('setStickerEmojiList', { form });
+ }
+
+ /**
+ * Use this method to change the list of emoji assigned to a `regular` or `custom emoji` sticker.
+ *
+ * The sticker must belong to a sticker set created by the bot.
+ *
+ * @param {String} sticker File identifier of the sticker
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} True on success
+ * @see https://core.telegram.org/bots/api#setstickerkeywords
+ */
+ setStickerKeywords(sticker, form = {}) {
+ form.sticker = sticker;
+ if (form.keywords) {
+ form.keywords = stringify(form.keywords);
+ }
+ return this._request('setStickerKeywords', { form });
+ }
+
+ /**
+ * Use this method to change the [mask position](https://core.telegram.org/bots/api#maskposition) of a mask sticker.
+ *
+ * The sticker must belong to a sticker set created by the bot.
+ *
+ * @param {String} sticker File identifier of the sticker
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} True on success
+ * @see https://core.telegram.org/bots/api#setstickermaskposition
+ */
+ setStickerMaskPosition(sticker, form = {}) {
+ form.sticker = sticker;
+ if (form.mask_position) {
+ form.mask_position = stringify(form.mask_position);
+ }
+ return this._request('setStickerMaskPosition', { form });
+ }
+
+ /**
+ * Use this method to set the title of a created sticker set.
+ *
+ * The sticker must belong to a sticker set created by the bot.
+ *
+ * @param {String} name Sticker set name
+ * @param {String} title Sticker set title, 1-64 characters
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} True on success
+ * @see https://core.telegram.org/bots/api#setstickersettitle
+ */
+ setStickerSetTitle(name, title, form = {}) {
+ form.name = name;
+ form.title = title;
+ return this._request('setStickerSetTitle', { form });
+ }
+
/**
* Use this method to add a thumb to a set created by the bot.
*
@@ -2543,7 +2683,7 @@ class TelegramBot extends EventEmitter {
*
* @param {Number} userId User identifier of sticker set owner
* @param {String} name Sticker set name
- * @param {String|stream.Stream|Buffer} pngThumb A PNG image with the thumbnail,
+ * @param {String|stream.Stream|Buffer} thumbnail A .WEBP or .PNG image with the thumbnail,
* must be up to 128 kilobytes in size and have width and height exactly 100px,
* a TGS animation with the thumbnail up to 32 kilobytes in size or a WEBM video with the thumbnail up to 32 kilobytes in size.
*
@@ -2552,9 +2692,9 @@ class TelegramBot extends EventEmitter {
* @param {Object} [options] Additional Telegram query options
* @param {Object} [fileOptions] Optional file related meta-data
* @return {Promise} True on success
- * @see https://core.telegram.org/bots/api#setstickersetthumb
+ * @see https://core.telegram.org/bots/api#setstickersetthumbnail
*/
- setStickerSetThumb(userId, name, pngThumb, options = {}, fileOptions = {}) {
+ setStickerSetThumbnail(userId, name, thumbnail, options = {}, fileOptions = {}) {
const opts = {
qs: options,
};
@@ -2562,13 +2702,44 @@ class TelegramBot extends EventEmitter {
opts.qs.name = name;
opts.qs.mask_position = stringify(options.mask_position);
try {
- const sendData = this._formatSendData('thumb', pngThumb, fileOptions);
+ const sendData = this._formatSendData('thumbnail', thumbnail, fileOptions);
opts.formData = sendData[0];
- opts.qs.thumb = sendData[1];
+ opts.qs.thumbnail = sendData[1];
} catch (ex) {
return Promise.reject(ex);
}
- return this._request('setStickerSetThumb', opts);
+ return this._request('setStickerSetThumbnail', opts);
+ }
+
+
+ /**
+ * Use this method to set the thumbnail of a custom emoji sticker set.
+ *
+ * The sticker must belong to a sticker set created by the bot.
+ *
+ * @param {String} name Sticker set name
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} True on success
+ * @see https://core.telegram.org/bots/api#setcustomemojistickersetthumbnail
+ */
+ setCustomEmojiStickerSetThumbnail(name, form = {}) {
+ form.name = name;
+ return this._request('setCustomEmojiStickerSetThumbnail', { form });
+ }
+
+ /**
+ * Use this method to delete a sticker set that was created by the bot.
+ *
+ * The sticker must belong to a sticker set created by the bot.
+ *
+ * @param {String} name Sticker set name
+ * @param {Object} [options] Additional Telegram query options
+ * @return {Promise} True on success
+ * @see https://core.telegram.org/bots/api#deletestickerset
+ */
+ deleteStickerSet(name, form = {}) {
+ form.name = name;
+ return this._request('deleteStickerSet', { form });
}
/**
diff --git a/test/telegram.js b/test/telegram.js
index 55284d4f..404fe354 100644
--- a/test/telegram.js
+++ b/test/telegram.js
@@ -50,6 +50,7 @@ let GAME_MSG_ID;
let BOT_USERNAME;
let CHAT_INFO;
let STICKER_FILE_ID_FROM_SET;
+let STICKERS_FROM_BOT_SET;
before(function beforeAll() {
utils.startStaticServer(staticPort);
@@ -1418,6 +1419,74 @@ describe('TelegramBot', function telegramSuite() {
});
});
+ describe('#setMyDescription', function getMyCommandsSuite() {
+ it('should set bot description for users with a specific lang code', function test() {
+ return bot.setMyDescription({ description: 'Bot description' }).then(resp => {
+ assert.ok(is.boolean(resp));
+ });
+ });
+ it('should set bot description for Spanish users', function test() {
+ return bot.setMyDescription({ description: 'Spanish bot description', language_code: 'es' }).then(resp => {
+ assert.ok(is.boolean(resp));
+ });
+ });
+ });
+
+ describe('#setMyName', function setMyNameSuite() {
+ it('should set bot name for Spanish users', function test() {
+ return bot.setMyName({ name: 'Spanish Bot', language_code: 'es' }).then(resp => {
+ assert.ok(is.boolean(resp));
+ });
+ });
+ });
+
+ describe('#getMyName', function setMyNameSuite() {
+ it('should get bot name for Spanish users', function test() {
+ return bot.getMyName({ language_code: 'es' }).then(resp => {
+ assert.ok(is.equal(resp.name, 'Spanish Bot'));
+ });
+ });
+ });
+
+ describe('#getMyDescription', function getMyDescriptionSuite() {
+ it('should get bot description for a user without lang code', function test() {
+ return bot.getMyDescription().then(resp => {
+ assert.ok(is.equal(resp.description, 'Bot description'));
+ });
+ });
+ it('should get bot description for Spanish users', function test() {
+ return bot.getMyDescription({ language_code: 'es' }).then(resp => {
+ assert.ok(is.equal(resp.description, 'Spanish bot description'));
+ });
+ });
+ });
+
+ describe('#setMyShortDescription', function setMyShortDescriptionSuite() {
+ it('should set sort bot description for a user without lang code', function test() {
+ return bot.setMyShortDescription({ short_description: 'Bot sort description' }).then(resp => {
+ assert.ok(is.boolean(resp));
+ });
+ });
+ it('should set sort description for Spanish users', function test() {
+ return bot.setMyShortDescription({ short_description: 'Spanish bot sort description', language_code: 'es' }).then(resp => {
+ assert.ok(is.boolean(resp));
+ });
+ });
+ });
+
+ describe('#getMyShortDescription', function getMyShortDescriptionSuite() {
+ it('should get bot sort description for a user without lang code', function test() {
+ return bot.getMyShortDescription().then(resp => {
+ assert.ok(is.equal(resp.short_description, 'Bot sort description'));
+ });
+ });
+ it('should get bot sort description for Spanish users', function test() {
+ return bot.getMyShortDescription({ language_code: 'es' }).then(resp => {
+ assert.ok(is.equal(resp.short_description, 'Spanish bot sort description'));
+ });
+ });
+ });
+
describe('#getMyCommands', function getMyCommandsSuite() {
it('should get bot commands', function test() {
return bot.getMyCommands().then(resp => {
@@ -1781,16 +1850,105 @@ describe('TelegramBot', function telegramSuite() {
});
});
- describe('#setStickerSetThumb', function setStickerSetThumbSuite() {
+ describe('#setStickerEmojiList', function setStickerEmojiListSuite() {
before(function before() {
- utils.handleRatelimit(bot, 'setStickerSetThumb', this);
+ utils.handleRatelimit(bot, 'setStickerEmojiList', this);
+ });
+
+ it('should get the list for the given sticker of the bot sticker pack', function test(done) {
+ const stickerPackName = `s${CURRENT_TIMESTAMP}_by_${BOT_USERNAME}`;
+
+ bot.getStickerSet(stickerPackName).then(resp => {
+ STICKERS_FROM_BOT_SET = resp.stickers;
+ assert.ok(is.array(STICKERS_FROM_BOT_SET));
+ });
+
+ setTimeout(() => done(), 2000);
+ });
+
+ it('should set a emoji list for the given sticker', function test() {
+ assert.ok(is.equal(STICKERS_FROM_BOT_SET[0].type, 'regular'));
+
+ bot.setStickerEmojiList(STICKERS_FROM_BOT_SET[0].file_id, ['🥳', '😀', '😇']).then((resp) => {
+ assert.ok(is.boolean(resp));
+ });
+ });
+ });
+
+ describe('#setStickerKeywords', function setStickerKeywordsSuite() {
+ before(function before() {
+ utils.handleRatelimit(bot, 'setStickerKeywords', this);
+ });
+ it('should set a keywords list for the given sticker', function test() {
+ assert.ok(is.equal(STICKERS_FROM_BOT_SET[0].type, 'regular'));
+ bot.setStickerKeywords(STICKERS_FROM_BOT_SET[0].file_id, { keywords: ['house', 'cat'] }).then((resp) => {
+ assert.ok(is.boolean(resp));
+ });
+ });
+ });
+
+ describe.skip('#setStickerMaskPosition', function setStickerKeywordsSuite() {
+ before(function before() {
+ utils.handleRatelimit(bot, 'setStickerMaskPosition', this);
+ });
+ it('should delete a sticker from a set', function test() {
+ bot.setStickerMaskPosition(STICKER_FILE_ID_FROM_SET, { point: 'eyes', scale: 2, x_shift: 1, y_shift: 1 }).then((resp) => {
+ assert.ok(is.boolean(resp));
+ });
+ });
+ });
+
+ describe('#setStickerSetTitle', function setStickerSetTitleSuite() {
+ before(function before() {
+ utils.handleRatelimit(bot, 'setStickerSetTitle', this);
+ });
+ it('should set a new sticker set title', function test() {
+ const stickerPackName = `s${CURRENT_TIMESTAMP}_by_${BOT_USERNAME}`;
+
+ bot.setStickerSetTitle(stickerPackName, 'New title').then((resp) => {
+ assert.ok(is.boolean(resp));
+ });
+ });
+ });
+
+ describe('#setStickerSetThumbnail', function setStickerSetThumbnailSuite() {
+ before(function before() {
+ utils.handleRatelimit(bot, 'setStickerSetThumbnail', this);
});
it('should set a sticker set thumb', function test() {
const stickerThumb = `${__dirname}/data/sticker_thumb.png`;
const stickerPackName = `s${CURRENT_TIMESTAMP}_by_${BOT_USERNAME}`;
- bot.setStickerSetThumb(USERID, stickerPackName, stickerThumb).then((resp) => {
+ bot.setStickerSetThumbnail(USERID, stickerPackName, stickerThumb).then((resp) => {
+ assert.ok(is.boolean(resp));
+ });
+ });
+ });
+
+ describe.skip('#setCustomEmojiStickerSetThumbnail', function setCustomEmojiStickerSetThumbnailSuite() {
+ before(function before() {
+ utils.handleRatelimit(bot, 'setCustomEmojiStickerSetThumbnail', this);
+ });
+
+ it('should set a custom emoji sticjer set as thumbnail', function test() {
+ const stickerPackName = `s${CURRENT_TIMESTAMP}_by_${BOT_USERNAME}`;
+
+ bot.setCustomEmojiStickerSetThumbnail(stickerPackName, { custom_emoji_id: null }).then((resp) => {
+ assert.ok(is.boolean(resp));
+ });
+ });
+ });
+
+ describe.skip('#deleteStickerSet', function deleteStickerSetSuite() {
+ before(function before() {
+ utils.handleRatelimit(bot, 'deleteStickerSet', this);
+ });
+
+ it('should delete sticker set', function test() {
+ const stickerPackName = `s${CURRENT_TIMESTAMP}_by_${BOT_USERNAME}`;
+
+ bot.deleteStickerSet(stickerPackName).then((resp) => {
assert.ok(is.boolean(resp));
});
});