Skip to content

Commit fe4afd6

Browse files
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
1 parent c9b05e7 commit fe4afd6

File tree

5 files changed

+84
-20
lines changed

5 files changed

+84
-20
lines changed

CHANGELOG.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,37 @@
33
All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6-
## [0.59.0][0.59.0] - 2022-07-19
6+
## [0.59.0][0.59.0] - 2022-08-15
77

8-
1. Remove dependencies: (@danielperez9430)
8+
1. Support Telegrm Bot API v6.3 (@danielperez9430)
9+
* getCustomEmojiStickers
10+
11+
2. Support test enviroment (@tinsaeDev & @kamikazechaser)
12+
13+
3. Remove dependencies: (@danielperez9430)
914
* Remove *bluebird* => Use NodeJS Native Promises
1015
* Remove *depd* => Use node native deprecate util for warnings
1116
* Remove contributor dev dependency and add list of contributors in the readme
1217

13-
2. Remove legacy methods: (@danielperez9430)
18+
4. Remove legacy methods: (@danielperez9430)
1419
* getChatMembersCount
1520
* kickChatMember
1621

17-
3. Docs: (@danielperez9430)
18-
* Update the docs of functions
19-
* Order functions follow the Telegram bot API docs in src/telegram.js
22+
5. Docs: (@danielperez9430)
23+
* Update the docs of the methods
24+
* Order methods follow the Telegram bot API docs in src/telegram.js
25+
* Update README
2026

21-
4. Fix: (@danielperez9430)
27+
6. Fix: (@danielperez9430)
2228
* addStickerToSet() -> Allow to send tgs_sticker + webm_sticker
2329
* Remove mandatory param “start_parameter” from sendInvoice, because in the docs is a optional param
24-
* Fix some tests
30+
* getStickerSet test fix deprecated response value "contains_masks" change to "sticker_type"
31+
* Fix some other tests
2532

26-
5. New Test: (@danielperez9430)
33+
7. New Test: (@danielperez9430)
2734
* deleteStickerFromSet
2835
* setStickerPositionInSet
29-
36+
* getCustomEmojiStickers
3037

3138
## [0.58.0][0.58.0] - 2022-06-22
3239

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Node.js module to interact with the official [Telegram Bot API](https://core.telegram.org/bots/api).
66

77

8-
[![Bot API](https://img.shields.io/badge/Bot%20API-v.6.1-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
8+
[![Bot API](https://img.shields.io/badge/Bot%20API-v.6.2-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
99
[![npm package](https://img.shields.io/npm/v/node-telegram-bot-api?logo=npm&style=flat-square)](https://www.npmjs.org/package/node-telegram-bot-api)
1010
[![Build Status](https://img.shields.io/travis/yagop/node-telegram-bot-api/master?style=flat-square&logo=travis)](https://travis-ci.org/yagop/node-telegram-bot-api)
1111
[![Coverage Status](https://img.shields.io/codecov/c/github/yagop/node-telegram-bot-api?style=flat-square&logo=codecov)](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
1616

1717
</div>
1818

19-
## Install
19+
## 📦 Install
2020

2121
```sh
2222
npm i node-telegram-bot-api
2323
```
2424

25-
## Usage
25+
<br/>
26+
27+
> ✍️ **Note:** If you use Typescript you can install this package that contains type definitions for this library
28+
>```sh
29+
>npm install --save @types/node-telegram-bot-api
30+
>```
31+
32+
## 🚀 Usage
2633
2734
```js
2835
const TelegramBot = require('node-telegram-bot-api');
@@ -56,7 +63,7 @@ bot.on('message', (msg) => {
5663
});
5764
```
5865
59-
## Documentation
66+
## 📚 Documentation
6067

6168
* [Usage][usage]
6269
* [Examples][examples]
@@ -71,7 +78,7 @@ Code for the latest release resides on the **release** branch.
7178
Experimental features reside on the **experimental** branch._
7279

7380

74-
## Community
81+
## 💭 Community
7582

7683
We thank all the developers in the Open-Source community who continuously
7784
take their time and effort in advancing this project.
@@ -93,7 +100,7 @@ Some things built using this library that might interest you:
93100
* [beetube-bot](https://github.com/kodjunkie/beetube-bot): A telegram bot for music, videos, movies, EDM tracks, torrent downloads, files and more.
94101

95102

96-
## Contributors
103+
## 👥 Contributors
97104

98105
<p align="center">
99106
<a href="https://github.com/yagop/node-telegram-bot-api/graphs/contributors">

doc/api.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ TelegramBot
103103
* [.deleteMessage(chatId, messageId, [options])](#TelegramBot+deleteMessage) ⇒ <code>Promise</code>
104104
* [.sendSticker(chatId, sticker, [options], [fileOptions])](#TelegramBot+sendSticker) ⇒ <code>Promise</code>
105105
* [.getStickerSet(name, [options])](#TelegramBot+getStickerSet) ⇒ <code>Promise</code>
106+
* [.getCustomEmojiStickers(custom_emoji_ids, [options])](#TelegramBot+getCustomEmojiStickers) ⇒ <code>Promise</code>
106107
* [.uploadStickerFile(userId, pngSticker, [options], [fileOptions])](#TelegramBot+uploadStickerFile) ⇒ <code>Promise</code>
107108
* [.createNewStickerSet(userId, name, title, pngSticker, emojis, [options], [fileOptions])](#TelegramBot+createNewStickerSet) ⇒ <code>Promise</code>
108109
* [.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.
16191620
| name | <code>String</code> | Name of the sticker set |
16201621
| [options] | <code>Object</code> | Additional Telegram query options |
16211622

1623+
<a name="TelegramBot+getCustomEmojiStickers"></a>
1624+
1625+
### telegramBot.getCustomEmojiStickers(custom_emoji_ids, [options]) ⇒ <code>Promise</code>
1626+
Use this method to get information about custom emoji stickers by their identifiers.
1627+
1628+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1629+
**Returns**: <code>Promise</code> - Array of [Sticker](https://core.telegram.org/bots/api#sticker) objects.
1630+
**See**: https://core.telegram.org/bots/api#getcustomemojistickers
1631+
1632+
| Param | Type | Description |
1633+
| --- | --- | --- |
1634+
| custom_emoji_ids | <code>Array</code> | List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. |
1635+
| [options] | <code>Object</code> | Additional Telegram query options |
1636+
16221637
<a name="TelegramBot+uploadStickerFile"></a>
16231638

16241639
### telegramBot.uploadStickerFile(userId, pngSticker, [options], [fileOptions]) ⇒ <code>Promise</code>
1625-
Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
1640+
Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
16261641
times).
16271642

16281643
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)

src/telegram.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2160,7 +2160,20 @@ class TelegramBot extends EventEmitter {
21602160
}
21612161

21622162
/**
2163-
* Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
2163+
* Use this method to get information about custom emoji stickers by their identifiers.
2164+
*
2165+
* @param {Array} custom_emoji_ids List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
2166+
* @param {Object} [options] Additional Telegram query options
2167+
* @return {Promise} Array of [Sticker](https://core.telegram.org/bots/api#sticker) objects.
2168+
* @see https://core.telegram.org/bots/api#getcustomemojistickers
2169+
*/
2170+
getCustomEmojiStickers(customEmojiIds, form = {}) {
2171+
form.custom_emoji_ids = stringify(customEmojiIds);
2172+
return this._request('getCustomEmojiStickers', { form });
2173+
}
2174+
2175+
/**
2176+
* Use this method to upload a .png file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
21642177
* times).
21652178
*
21662179
* @param {Number} userId User identifier of sticker file owner

test/telegram.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ describe('TelegramBot', function telegramSuite() {
16941694
assert.ok(is.object(resp));
16951695
assert.strictEqual(resp.name.toLowerCase(), STICKER_SET_NAME);
16961696
assert.ok(is.string(resp.title));
1697-
assert.ok(is.boolean(resp.contains_masks));
1697+
assert.ok(is.string(resp.sticker_type));
16981698
assert.ok(is.array(resp.stickers));
16991699
});
17001700
});
@@ -1706,12 +1706,34 @@ describe('TelegramBot', function telegramSuite() {
17061706
assert.ok(is.object(resp));
17071707
assert.strictEqual(resp.name.toLowerCase(), stickerPackName.toLowerCase());
17081708
assert.ok(is.string(resp.title));
1709-
assert.ok(is.boolean(resp.contains_masks));
1709+
assert.ok(is.string(resp.sticker_type));
17101710
assert.ok(is.array(resp.stickers));
17111711
});
17121712
});
17131713
});
17141714

1715+
describe('#getCustomEmojiStickers', function getCustomEmojiStickersSuite() {
1716+
const CHERRY_EMOJI_STICKERS_ID = ['5380109565226391871', '5431711346724968789'];
1717+
const STICKER_EMOJI_SET_NAME = 'CherryEmoji';
1718+
1719+
it('should get the custom emoji stickers', function test() {
1720+
return bot.getCustomEmojiStickers([CHERRY_EMOJI_STICKERS_ID[0]]).then(resp => {
1721+
assert.ok(is.array(resp));
1722+
assert.ok(is.object(resp[0]));
1723+
assert.ok(is.string(resp[0].set_name) && resp[0].set_name === STICKER_EMOJI_SET_NAME);
1724+
assert.ok(resp[0].custom_emoji_id === CHERRY_EMOJI_STICKERS_ID[0]);
1725+
});
1726+
});
1727+
it('should get 2 custom emoji stickers', function test() {
1728+
return bot.getCustomEmojiStickers(CHERRY_EMOJI_STICKERS_ID).then(resp => {
1729+
assert.ok(is.array(resp) && resp.length === 2);
1730+
assert.ok(is.object(resp[1]));
1731+
assert.ok(is.string(resp[1].set_name) && resp[1].set_name === STICKER_EMOJI_SET_NAME);
1732+
assert.ok(resp[1].custom_emoji_id === CHERRY_EMOJI_STICKERS_ID[1]);
1733+
});
1734+
});
1735+
});
1736+
17151737

17161738
describe('#addStickerToSet', function addStickerToSetSuite() {
17171739
before(function before() {

0 commit comments

Comments
 (0)