diff --git a/doc/api.md b/doc/api.md index e966e2e..773155f 100644 --- a/doc/api.md +++ b/doc/api.md @@ -103,6 +103,8 @@ 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 @@ -120,7 +122,7 @@ 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, stickerFormat, [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 @@ -1642,6 +1644,32 @@ 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 @@ -1904,21 +1932,21 @@ Use this method to get information about custom emoji stickers by their identifi -### telegramBot.uploadStickerFile(userId, pngSticker, stickerFormat, [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. | -| stickerFormat | String | Allow values: `static`, `animated` or `video` | -| [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 | diff --git a/src/telegram.js b/src/telegram.js index a6b9da6..c826f79 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -2158,6 +2158,28 @@ 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. * diff --git a/test/telegram.js b/test/telegram.js index fb39914..506fee3 100644 --- a/test/telegram.js +++ b/test/telegram.js @@ -1432,6 +1432,22 @@ describe('TelegramBot', function telegramSuite() { }); }); + 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 => {