mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-22 18:07:16 +00:00
feat: Support Telegram Bot API v6.7
This commit is contained in:
parent
aa4083d1b1
commit
4f44b1c400
48
doc/api.md
48
doc/api.md
@ -103,6 +103,8 @@ TelegramBot
|
|||||||
* [.setMyCommands(commands, [options])](#TelegramBot+setMyCommands) ⇒ <code>Promise</code>
|
* [.setMyCommands(commands, [options])](#TelegramBot+setMyCommands) ⇒ <code>Promise</code>
|
||||||
* [.deleteMyCommands([options])](#TelegramBot+deleteMyCommands) ⇒ <code>Promise</code>
|
* [.deleteMyCommands([options])](#TelegramBot+deleteMyCommands) ⇒ <code>Promise</code>
|
||||||
* [.getMyCommands([options])](#TelegramBot+getMyCommands) ⇒ <code>Promise</code>
|
* [.getMyCommands([options])](#TelegramBot+getMyCommands) ⇒ <code>Promise</code>
|
||||||
|
* [.setMyName([options])](#TelegramBot+setMyName) ⇒ <code>Promise</code>
|
||||||
|
* [.getMyName([options])](#TelegramBot+getMyName) ⇒ <code>Promise</code>
|
||||||
* [.setMyDescription([options])](#TelegramBot+setMyDescription) ⇒ <code>Promise</code>
|
* [.setMyDescription([options])](#TelegramBot+setMyDescription) ⇒ <code>Promise</code>
|
||||||
* [.getMyDescription([options])](#TelegramBot+getMyDescription) ⇒ <code>Promise</code>
|
* [.getMyDescription([options])](#TelegramBot+getMyDescription) ⇒ <code>Promise</code>
|
||||||
* [.setMyShortDescription([options])](#TelegramBot+setMyShortDescription) ⇒ <code>Promise</code>
|
* [.setMyShortDescription([options])](#TelegramBot+setMyShortDescription) ⇒ <code>Promise</code>
|
||||||
@ -120,7 +122,7 @@ TelegramBot
|
|||||||
* [.sendSticker(chatId, sticker, [options], [fileOptions])](#TelegramBot+sendSticker) ⇒ <code>Promise</code>
|
* [.sendSticker(chatId, sticker, [options], [fileOptions])](#TelegramBot+sendSticker) ⇒ <code>Promise</code>
|
||||||
* [.getStickerSet(name, [options])](#TelegramBot+getStickerSet) ⇒ <code>Promise</code>
|
* [.getStickerSet(name, [options])](#TelegramBot+getStickerSet) ⇒ <code>Promise</code>
|
||||||
* [.getCustomEmojiStickers(custom_emoji_ids, [options])](#TelegramBot+getCustomEmojiStickers) ⇒ <code>Promise</code>
|
* [.getCustomEmojiStickers(custom_emoji_ids, [options])](#TelegramBot+getCustomEmojiStickers) ⇒ <code>Promise</code>
|
||||||
* [.uploadStickerFile(userId, pngSticker, stickerFormat, [options], [fileOptions])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code>
|
* [.uploadStickerFile(userId, sticker, stickerFormat, [options], [fileOptions])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code>
|
||||||
* [.createNewStickerSet(userId, name, title, pngSticker, emojis, [options], [fileOptions])](#TelegramBot+createNewStickerSet) ⇒ <code>Promise</code>
|
* [.createNewStickerSet(userId, name, title, pngSticker, emojis, [options], [fileOptions])](#TelegramBot+createNewStickerSet) ⇒ <code>Promise</code>
|
||||||
* [.addStickerToSet(userId, name, sticker, emojis, stickerType, [options], [fileOptions])](#TelegramBot+addStickerToSet) ⇒ <code>Promise</code>
|
* [.addStickerToSet(userId, name, sticker, emojis, stickerType, [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>
|
||||||
@ -1642,6 +1644,32 @@ Use this method to get the current list of the bot's commands for the given scop
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
|
<a name="TelegramBot+setMyName"></a>
|
||||||
|
|
||||||
|
### telegramBot.setMyName([options]) ⇒ <code>Promise</code>
|
||||||
|
Use this method to change the bot's name.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||||
|
**Returns**: <code>Promise</code> - True on success
|
||||||
|
**See**: https://core.telegram.org/bots/api#setmyname
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
|
<a name="TelegramBot+getMyName"></a>
|
||||||
|
|
||||||
|
### telegramBot.getMyName([options]) ⇒ <code>Promise</code>
|
||||||
|
Use this method to get the current bot name for the given user language.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||||
|
**Returns**: <code>Promise</code> - [BotName](https://core.telegram.org/bots/api#botname) on success
|
||||||
|
**See**: https://core.telegram.org/bots/api#getmyname
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+setMyDescription"></a>
|
<a name="TelegramBot+setMyDescription"></a>
|
||||||
|
|
||||||
### telegramBot.setMyDescription([options]) ⇒ <code>Promise</code>
|
### telegramBot.setMyDescription([options]) ⇒ <code>Promise</code>
|
||||||
@ -1904,21 +1932,21 @@ Use this method to get information about custom emoji stickers by their identifi
|
|||||||
|
|
||||||
<a name="TelegramBot+uploadStickerFile"></a>
|
<a name="TelegramBot+uploadStickerFile"></a>
|
||||||
|
|
||||||
### telegramBot.uploadStickerFile(userId, pngSticker, stickerFormat, [options], [fileOptions]) ⇒ <code>Promise</code>
|
### telegramBot.uploadStickerFile(userId, sticker, stickerFormat, [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 file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
|
||||||
times).
|
times).
|
||||||
|
|
||||||
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||||
**Returns**: <code>Promise</code> - On success, a [File](https://core.telegram.org/bots/api#file) object is returned
|
**Returns**: <code>Promise</code> - On success, a [File](https://core.telegram.org/bots/api#file) object is returned
|
||||||
**See**: https://core.telegram.org/bots/api#uploadstickerfile
|
**See**: https://core.telegram.org/bots/api#uploadstickerfile
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Default | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| userId | <code>Number</code> | User identifier of sticker file owner |
|
| userId | <code>Number</code> | | User identifier of sticker file owner |
|
||||||
| 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. |
|
| 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. |
|
||||||
| stickerFormat | <code>String</code> | Allow values: `static`, `animated` or `video` |
|
| stickerFormat | <code>String</code> | <code>static</code> | Allow values: `static`, `animated` or `video` |
|
||||||
| [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 |
|
| [fileOptions] | <code>Object</code> | | Optional file related meta-data |
|
||||||
|
|
||||||
<a name="TelegramBot+createNewStickerSet"></a>
|
<a name="TelegramBot+createNewStickerSet"></a>
|
||||||
|
|
||||||
|
@ -2158,6 +2158,28 @@ class TelegramBot extends EventEmitter {
|
|||||||
return this._request('getMyCommands', { form });
|
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.
|
* Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
|
||||||
*
|
*
|
||||||
|
@ -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() {
|
describe('#getMyDescription', function getMyDescriptionSuite() {
|
||||||
it('should get bot description for a user without lang code', function test() {
|
it('should get bot description for a user without lang code', function test() {
|
||||||
return bot.getMyDescription().then(resp => {
|
return bot.getMyDescription().then(resp => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user