Skip to content

Commit 4f44b1c

Browse files
feat: Support Telegram Bot API v6.7
1 parent aa4083d commit 4f44b1c

File tree

3 files changed

+76
-10
lines changed

3 files changed

+76
-10
lines changed

doc/api.md

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ TelegramBot
103103
* [.setMyCommands(commands, [options])](#TelegramBot+setMyCommands) ⇒ <code>Promise</code>
104104
* [.deleteMyCommands([options])](#TelegramBot+deleteMyCommands) ⇒ <code>Promise</code>
105105
* [.getMyCommands([options])](#TelegramBot+getMyCommands) ⇒ <code>Promise</code>
106+
* [.setMyName([options])](#TelegramBot+setMyName) ⇒ <code>Promise</code>
107+
* [.getMyName([options])](#TelegramBot+getMyName) ⇒ <code>Promise</code>
106108
* [.setMyDescription([options])](#TelegramBot+setMyDescription) ⇒ <code>Promise</code>
107109
* [.getMyDescription([options])](#TelegramBot+getMyDescription) ⇒ <code>Promise</code>
108110
* [.setMyShortDescription([options])](#TelegramBot+setMyShortDescription) ⇒ <code>Promise</code>
@@ -120,7 +122,7 @@ TelegramBot
120122
* [.sendSticker(chatId, sticker, [options], [fileOptions])](#TelegramBot+sendSticker) ⇒ <code>Promise</code>
121123
* [.getStickerSet(name, [options])](#TelegramBot+getStickerSet) ⇒ <code>Promise</code>
122124
* [.getCustomEmojiStickers(custom_emoji_ids, [options])](#TelegramBot+getCustomEmojiStickers) ⇒ <code>Promise</code>
123-
* [.uploadStickerFile(userId, pngSticker, stickerFormat, [options], [fileOptions])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code>
125+
* [.uploadStickerFile(userId, sticker, stickerFormat, [options], [fileOptions])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code>
124126
* [.createNewStickerSet(userId, name, title, pngSticker, emojis, [options], [fileOptions])](#TelegramBot+createNewStickerSet) ⇒ <code>Promise</code>
125127
* [.addStickerToSet(userId, name, sticker, emojis, stickerType, [options], [fileOptions])](#TelegramBot+addStickerToSet) ⇒ <code>Promise</code>
126128
* [.setStickerPositionInSet(sticker, position, [options])](#TelegramBot+setStickerPositionInSet) ⇒ <code>Promise</code>
@@ -1642,6 +1644,32 @@ Use this method to get the current list of the bot's commands for the given scop
16421644
| --- | --- | --- |
16431645
| [options] | <code>Object</code> | Additional Telegram query options |
16441646

1647+
<a name="TelegramBot+setMyName"></a>
1648+
1649+
### telegramBot.setMyName([options]) ⇒ <code>Promise</code>
1650+
Use this method to change the bot's name.
1651+
1652+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1653+
**Returns**: <code>Promise</code> - True on success
1654+
**See**: https://core.telegram.org/bots/api#setmyname
1655+
1656+
| Param | Type | Description |
1657+
| --- | --- | --- |
1658+
| [options] | <code>Object</code> | Additional Telegram query options |
1659+
1660+
<a name="TelegramBot+getMyName"></a>
1661+
1662+
### telegramBot.getMyName([options]) ⇒ <code>Promise</code>
1663+
Use this method to get the current bot name for the given user language.
1664+
1665+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1666+
**Returns**: <code>Promise</code> - [BotName](https://core.telegram.org/bots/api#botname) on success
1667+
**See**: https://core.telegram.org/bots/api#getmyname
1668+
1669+
| Param | Type | Description |
1670+
| --- | --- | --- |
1671+
| [options] | <code>Object</code> | Additional Telegram query options |
1672+
16451673
<a name="TelegramBot+setMyDescription"></a>
16461674

16471675
### telegramBot.setMyDescription([options]) ⇒ <code>Promise</code>
@@ -1904,21 +1932,21 @@ Use this method to get information about custom emoji stickers by their identifi
19041932

19051933
<a name="TelegramBot+uploadStickerFile"></a>
19061934

1907-
### telegramBot.uploadStickerFile(userId, pngSticker, stickerFormat, [options], [fileOptions]) ⇒ <code>Promise</code>
1908-
Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
1935+
### telegramBot.uploadStickerFile(userId, sticker, stickerFormat, [options], [fileOptions]) ⇒ <code>Promise</code>
1936+
Use this method to upload a file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
19091937
times).
19101938

19111939
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
19121940
**Returns**: <code>Promise</code> - On success, a [File](https://core.telegram.org/bots/api#file) object is returned
19131941
**See**: https://core.telegram.org/bots/api#uploadstickerfile
19141942

1915-
| Param | Type | Description |
1916-
| --- | --- | --- |
1917-
| userId | <code>Number</code> | User identifier of sticker file owner |
1918-
| pngSticker | <code>String</code> \| <code>stream.Stream</code> \| <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. |
1919-
| stickerFormat | <code>String</code> | Allow values: `static`, `animated` or `video` |
1920-
| [options] | <code>Object</code> | Additional Telegram query options |
1921-
| [fileOptions] | <code>Object</code> | Optional file related meta-data |
1943+
| Param | Type | Default | Description |
1944+
| --- | --- | --- | --- |
1945+
| userId | <code>Number</code> | | User identifier of sticker file owner |
1946+
| sticker | <code>String</code> \| <code>stream.Stream</code> \| <code>Buffer</code> | | A file path or a Stream with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. Can also be a `file_id` previously uploaded. |
1947+
| stickerFormat | <code>String</code> | <code>static</code> | Allow values: `static`, `animated` or `video` |
1948+
| [options] | <code>Object</code> | | Additional Telegram query options |
1949+
| [fileOptions] | <code>Object</code> | | Optional file related meta-data |
19221950

19231951
<a name="TelegramBot+createNewStickerSet"></a>
19241952

src/telegram.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,6 +2158,28 @@ class TelegramBot extends EventEmitter {
21582158
return this._request('getMyCommands', { form });
21592159
}
21602160

2161+
/**
2162+
* Use this method to change the bot's name.
2163+
*
2164+
* @param {Object} [options] Additional Telegram query options
2165+
* @return {Promise} True on success
2166+
* @see https://core.telegram.org/bots/api#setmyname
2167+
*/
2168+
setMyName(form = {}) {
2169+
return this._request('setMyName', { form });
2170+
}
2171+
2172+
/**
2173+
* Use this method to get the current bot name for the given user language.
2174+
*
2175+
* @param {Object} [options] Additional Telegram query options
2176+
* @return {Promise} [BotName](https://core.telegram.org/bots/api#botname) on success
2177+
* @see https://core.telegram.org/bots/api#getmyname
2178+
*/
2179+
getMyName(form = {}) {
2180+
return this._request('getMyName', { form });
2181+
}
2182+
21612183
/**
21622184
* Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
21632185
*

test/telegram.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,22 @@ describe('TelegramBot', function telegramSuite() {
14321432
});
14331433
});
14341434

1435+
describe('#setMyName', function setMyNameSuite() {
1436+
it('should set bot name for Spanish users', function test() {
1437+
return bot.setMyName({ name: 'Spanish Bot', language_code: 'es' }).then(resp => {
1438+
assert.ok(is.boolean(resp));
1439+
});
1440+
});
1441+
});
1442+
1443+
describe('#getMyName', function setMyNameSuite() {
1444+
it('should get bot name for Spanish users', function test() {
1445+
return bot.getMyName({ language_code: 'es' }).then(resp => {
1446+
assert.ok(is.equal(resp.name, 'Spanish Bot'));
1447+
});
1448+
});
1449+
});
1450+
14351451
describe('#getMyDescription', function getMyDescriptionSuite() {
14361452
it('should get bot description for a user without lang code', function test() {
14371453
return bot.getMyDescription().then(resp => {

0 commit comments

Comments
 (0)