Skip to content

Commit

Permalink
feat: Support Bot API v6.2 (#996)
Browse files Browse the repository at this point in the history
* docs: Update readme and add Typescript types

* feat: getCustomEmojiStickers

* feat: Add getCustomEmojiStickers test + fix other test

* fix: docs

* docs: Update changelog + docs
  • Loading branch information
danielperez9430 committed Aug 15, 2022
1 parent c9b05e7 commit fe4afd6
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 20 deletions.
27 changes: 17 additions & 10 deletions CHANGELOG.md
Expand Up @@ -3,30 +3,37 @@
All notable changes to this project will be documented in this file.
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 *depd* => Use node native deprecate util for warnings
* Remove contributor dev dependency and add list of contributors in the readme

2. Remove legacy methods: (@danielperez9430)
4. Remove legacy methods: (@danielperez9430)
* getChatMembersCount
* kickChatMember

3. Docs: (@danielperez9430)
* Update the docs of functions
* Order functions follow the Telegram bot API docs in src/telegram.js
5. Docs: (@danielperez9430)
* Update the docs of the methods
* 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
* 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
* setStickerPositionInSet

* getCustomEmojiStickers

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

Expand Down
19 changes: 13 additions & 6 deletions README.md
Expand Up @@ -5,7 +5,7 @@
Node.js module to interact with the official [Telegram Bot API](https://core.telegram.org/bots/api).


[![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)
[![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)
[![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)
[![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)
[![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)
Expand All @@ -16,13 +16,20 @@ Node.js module to interact with the official [Telegram Bot API](https://core.tel

</div>

## Install
## 📦 Install

```sh
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
const TelegramBot = require('node-telegram-bot-api');
Expand Down Expand Up @@ -56,7 +63,7 @@ bot.on('message', (msg) => {
});
```

## Documentation
## 📚 Documentation

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


## Community
## 💭 Community

We thank all the developers in the Open-Source community who continuously
take their time and effort in advancing this project.
Expand All @@ -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.


## Contributors
## 👥 Contributors

<p align="center">
<a href="https://github.com/yagop/node-telegram-bot-api/graphs/contributors">
Expand Down
17 changes: 16 additions & 1 deletion doc/api.md
Expand Up @@ -103,6 +103,7 @@ TelegramBot
* [.deleteMessage(chatId, messageId, [options])](#TelegramBot+deleteMessage) ⇒ <code>Promise</code>
* [.sendSticker(chatId, sticker, [options], [fileOptions])](#TelegramBot+sendSticker) ⇒ <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>
* [.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>
Expand Down Expand Up @@ -1619,10 +1620,24 @@ Use this method to get a sticker set.
| name | <code>String</code> | Name of the sticker set |
| [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>

### 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).

**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
Expand Down
15 changes: 14 additions & 1 deletion src/telegram.js
Expand Up @@ -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).
*
* @param {Number} userId User identifier of sticker file owner
Expand Down
26 changes: 24 additions & 2 deletions test/telegram.js
Expand Up @@ -1694,7 +1694,7 @@ describe('TelegramBot', function telegramSuite() {
assert.ok(is.object(resp));
assert.strictEqual(resp.name.toLowerCase(), STICKER_SET_NAME);
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));
});
});
Expand All @@ -1706,12 +1706,34 @@ describe('TelegramBot', function telegramSuite() {
assert.ok(is.object(resp));
assert.strictEqual(resp.name.toLowerCase(), stickerPackName.toLowerCase());
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));
});
});
});

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() {
before(function before() {
Expand Down

0 comments on commit fe4afd6

Please sign in to comment.