mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 05:17:41 +00:00
feat: Support Bot API v6.2 (#996)
* docs: Update readme and add Typescript types * feat: getCustomEmojiStickers * feat: Add getCustomEmojiStickers test + fix other test * fix: docs * docs: Update changelog + docs
This commit is contained in:
parent
c9b05e7996
commit
fe4afd6533
27
CHANGELOG.md
27
CHANGELOG.md
@ -3,30 +3,37 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
## [0.59.0][0.59.0] - 2022-07-19
|
## [0.59.0][0.59.0] - 2022-08-15
|
||||||
|
|
||||||
1. Remove dependencies: (@danielperez9430)
|
1. Support Telegrm Bot API v6.3 (@danielperez9430)
|
||||||
|
* getCustomEmojiStickers
|
||||||
|
|
||||||
|
2. Support test enviroment (@tinsaeDev & @kamikazechaser)
|
||||||
|
|
||||||
|
3. Remove dependencies: (@danielperez9430)
|
||||||
* Remove *bluebird* => Use NodeJS Native Promises
|
* Remove *bluebird* => Use NodeJS Native Promises
|
||||||
* Remove *depd* => Use node native deprecate util for warnings
|
* Remove *depd* => Use node native deprecate util for warnings
|
||||||
* Remove contributor dev dependency and add list of contributors in the readme
|
* Remove contributor dev dependency and add list of contributors in the readme
|
||||||
|
|
||||||
2. Remove legacy methods: (@danielperez9430)
|
4. Remove legacy methods: (@danielperez9430)
|
||||||
* getChatMembersCount
|
* getChatMembersCount
|
||||||
* kickChatMember
|
* kickChatMember
|
||||||
|
|
||||||
3. Docs: (@danielperez9430)
|
5. Docs: (@danielperez9430)
|
||||||
* Update the docs of functions
|
* Update the docs of the methods
|
||||||
* Order functions follow the Telegram bot API docs in src/telegram.js
|
* Order methods follow the Telegram bot API docs in src/telegram.js
|
||||||
|
* Update README
|
||||||
|
|
||||||
4. Fix: (@danielperez9430)
|
6. Fix: (@danielperez9430)
|
||||||
* addStickerToSet() -> Allow to send tgs_sticker + webm_sticker
|
* addStickerToSet() -> Allow to send tgs_sticker + webm_sticker
|
||||||
* Remove mandatory param “start_parameter” from sendInvoice, because in the docs is a optional param
|
* Remove mandatory param “start_parameter” from sendInvoice, because in the docs is a optional param
|
||||||
* Fix some tests
|
* getStickerSet test fix deprecated response value "contains_masks" change to "sticker_type"
|
||||||
|
* Fix some other tests
|
||||||
|
|
||||||
5. New Test: (@danielperez9430)
|
7. New Test: (@danielperez9430)
|
||||||
* deleteStickerFromSet
|
* deleteStickerFromSet
|
||||||
* setStickerPositionInSet
|
* setStickerPositionInSet
|
||||||
|
* getCustomEmojiStickers
|
||||||
|
|
||||||
## [0.58.0][0.58.0] - 2022-06-22
|
## [0.58.0][0.58.0] - 2022-06-22
|
||||||
|
|
||||||
|
19
README.md
19
README.md
@ -5,7 +5,7 @@
|
|||||||
Node.js module to interact with the official [Telegram Bot API](https://core.telegram.org/bots/api).
|
Node.js module to interact with the official [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||||
|
|
||||||
|
|
||||||
[](https://core.telegram.org/bots/api)
|
[](https://core.telegram.org/bots/api)
|
||||||
[](https://www.npmjs.org/package/node-telegram-bot-api)
|
[](https://www.npmjs.org/package/node-telegram-bot-api)
|
||||||
[](https://travis-ci.org/yagop/node-telegram-bot-api)
|
[](https://travis-ci.org/yagop/node-telegram-bot-api)
|
||||||
[](https://codecov.io/gh/yagop/node-telegram-bot-api)
|
[](https://codecov.io/gh/yagop/node-telegram-bot-api)
|
||||||
@ -16,13 +16,20 @@ Node.js module to interact with the official [Telegram Bot API](https://core.tel
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Install
|
## 📦 Install
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm i node-telegram-bot-api
|
npm i node-telegram-bot-api
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
<br/>
|
||||||
|
|
||||||
|
> ✍️ **Note:** If you use Typescript you can install this package that contains type definitions for this library
|
||||||
|
>```sh
|
||||||
|
>npm install --save @types/node-telegram-bot-api
|
||||||
|
>```
|
||||||
|
|
||||||
|
## 🚀 Usage
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const TelegramBot = require('node-telegram-bot-api');
|
const TelegramBot = require('node-telegram-bot-api');
|
||||||
@ -56,7 +63,7 @@ bot.on('message', (msg) => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation
|
## 📚 Documentation
|
||||||
|
|
||||||
* [Usage][usage]
|
* [Usage][usage]
|
||||||
* [Examples][examples]
|
* [Examples][examples]
|
||||||
@ -71,7 +78,7 @@ Code for the latest release resides on the **release** branch.
|
|||||||
Experimental features reside on the **experimental** branch._
|
Experimental features reside on the **experimental** branch._
|
||||||
|
|
||||||
|
|
||||||
## Community
|
## 💭 Community
|
||||||
|
|
||||||
We thank all the developers in the Open-Source community who continuously
|
We thank all the developers in the Open-Source community who continuously
|
||||||
take their time and effort in advancing this project.
|
take their time and effort in advancing this project.
|
||||||
@ -93,7 +100,7 @@ Some things built using this library that might interest you:
|
|||||||
* [beetube-bot](https://github.com/kodjunkie/beetube-bot): A telegram bot for music, videos, movies, EDM tracks, torrent downloads, files and more.
|
* [beetube-bot](https://github.com/kodjunkie/beetube-bot): A telegram bot for music, videos, movies, EDM tracks, torrent downloads, files and more.
|
||||||
|
|
||||||
|
|
||||||
## Contributors
|
## 👥 Contributors
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/yagop/node-telegram-bot-api/graphs/contributors">
|
<a href="https://github.com/yagop/node-telegram-bot-api/graphs/contributors">
|
||||||
|
17
doc/api.md
17
doc/api.md
@ -103,6 +103,7 @@ TelegramBot
|
|||||||
* [.deleteMessage(chatId, messageId, [options])](#TelegramBot+deleteMessage) ⇒ <code>Promise</code>
|
* [.deleteMessage(chatId, messageId, [options])](#TelegramBot+deleteMessage) ⇒ <code>Promise</code>
|
||||||
* [.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>
|
||||||
* [.uploadStickerFile(userId, pngSticker, [options], [fileOptions])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code>
|
* [.uploadStickerFile(userId, pngSticker, [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>
|
||||||
@ -1619,10 +1620,24 @@ Use this method to get a sticker set.
|
|||||||
| name | <code>String</code> | Name of the sticker set |
|
| name | <code>String</code> | Name of the sticker set |
|
||||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
|
<a name="TelegramBot+getCustomEmojiStickers"></a>
|
||||||
|
|
||||||
|
### telegramBot.getCustomEmojiStickers(custom_emoji_ids, [options]) ⇒ <code>Promise</code>
|
||||||
|
Use this method to get information about custom emoji stickers by their identifiers.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||||
|
**Returns**: <code>Promise</code> - Array of [Sticker](https://core.telegram.org/bots/api#sticker) objects.
|
||||||
|
**See**: https://core.telegram.org/bots/api#getcustomemojistickers
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| custom_emoji_ids | <code>Array</code> | List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+uploadStickerFile"></a>
|
<a name="TelegramBot+uploadStickerFile"></a>
|
||||||
|
|
||||||
### telegramBot.uploadStickerFile(userId, pngSticker, [options], [fileOptions]) ⇒ <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).
|
times).
|
||||||
|
|
||||||
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||||
|
@ -2160,7 +2160,20 @@ 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 get information about custom emoji stickers by their identifiers.
|
||||||
|
*
|
||||||
|
* @param {Array} custom_emoji_ids List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
|
||||||
|
* @param {Object} [options] Additional Telegram query options
|
||||||
|
* @return {Promise} Array of [Sticker](https://core.telegram.org/bots/api#sticker) objects.
|
||||||
|
* @see https://core.telegram.org/bots/api#getcustomemojistickers
|
||||||
|
*/
|
||||||
|
getCustomEmojiStickers(customEmojiIds, form = {}) {
|
||||||
|
form.custom_emoji_ids = stringify(customEmojiIds);
|
||||||
|
return this._request('getCustomEmojiStickers', { form });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
|
||||||
* times).
|
* times).
|
||||||
*
|
*
|
||||||
* @param {Number} userId User identifier of sticker file owner
|
* @param {Number} userId User identifier of sticker file owner
|
||||||
|
@ -1694,7 +1694,7 @@ describe('TelegramBot', function telegramSuite() {
|
|||||||
assert.ok(is.object(resp));
|
assert.ok(is.object(resp));
|
||||||
assert.strictEqual(resp.name.toLowerCase(), STICKER_SET_NAME);
|
assert.strictEqual(resp.name.toLowerCase(), STICKER_SET_NAME);
|
||||||
assert.ok(is.string(resp.title));
|
assert.ok(is.string(resp.title));
|
||||||
assert.ok(is.boolean(resp.contains_masks));
|
assert.ok(is.string(resp.sticker_type));
|
||||||
assert.ok(is.array(resp.stickers));
|
assert.ok(is.array(resp.stickers));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1706,12 +1706,34 @@ describe('TelegramBot', function telegramSuite() {
|
|||||||
assert.ok(is.object(resp));
|
assert.ok(is.object(resp));
|
||||||
assert.strictEqual(resp.name.toLowerCase(), stickerPackName.toLowerCase());
|
assert.strictEqual(resp.name.toLowerCase(), stickerPackName.toLowerCase());
|
||||||
assert.ok(is.string(resp.title));
|
assert.ok(is.string(resp.title));
|
||||||
assert.ok(is.boolean(resp.contains_masks));
|
assert.ok(is.string(resp.sticker_type));
|
||||||
assert.ok(is.array(resp.stickers));
|
assert.ok(is.array(resp.stickers));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getCustomEmojiStickers', function getCustomEmojiStickersSuite() {
|
||||||
|
const CHERRY_EMOJI_STICKERS_ID = ['5380109565226391871', '5431711346724968789'];
|
||||||
|
const STICKER_EMOJI_SET_NAME = 'CherryEmoji';
|
||||||
|
|
||||||
|
it('should get the custom emoji stickers', function test() {
|
||||||
|
return bot.getCustomEmojiStickers([CHERRY_EMOJI_STICKERS_ID[0]]).then(resp => {
|
||||||
|
assert.ok(is.array(resp));
|
||||||
|
assert.ok(is.object(resp[0]));
|
||||||
|
assert.ok(is.string(resp[0].set_name) && resp[0].set_name === STICKER_EMOJI_SET_NAME);
|
||||||
|
assert.ok(resp[0].custom_emoji_id === CHERRY_EMOJI_STICKERS_ID[0]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('should get 2 custom emoji stickers', function test() {
|
||||||
|
return bot.getCustomEmojiStickers(CHERRY_EMOJI_STICKERS_ID).then(resp => {
|
||||||
|
assert.ok(is.array(resp) && resp.length === 2);
|
||||||
|
assert.ok(is.object(resp[1]));
|
||||||
|
assert.ok(is.string(resp[1].set_name) && resp[1].set_name === STICKER_EMOJI_SET_NAME);
|
||||||
|
assert.ok(resp[1].custom_emoji_id === CHERRY_EMOJI_STICKERS_ID[1]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('#addStickerToSet', function addStickerToSetSuite() {
|
describe('#addStickerToSet', function addStickerToSetSuite() {
|
||||||
before(function before() {
|
before(function before() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user