Skip to content

Commit ab59286

Browse files
feat: Telegram Bot API v6.3 (yagop#1020)
* feat: Telegram Topics * update docs * fix: test * update: docs
1 parent 0eb8b80 commit ab59286

File tree

6 files changed

+253
-3
lines changed

6 files changed

+253
-3
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
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.60.0][0.60.0] - 2022-10-06
7+
8+
1. Support Telegram Bot API v6.3 (@danielperez9430)
9+
* createForumTopic
10+
* closeForumTopic
11+
* reopenForumTopic
12+
* deleteForumTopic
13+
* unpinAllForumTopicMessages
14+
* getForumTopicIconStickers
15+
16+
2. Fix test getMyDefaultAdministratorRights (@danielperez9430)
17+
18+
3. Fix parse entities - (@toniop99)
19+
620
## [0.59.0][0.59.0] - 2022-08-15
721

822
1. Support Telegram Bot API v6.2 (@danielperez9430)

README.md

Lines changed: 1 addition & 1 deletion
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.2-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.3-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)

doc/api.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ TelegramBot
8787
* [.getChatMember(chatId, userId, [options])](#TelegramBot+getChatMember) ⇒ <code>Promise</code>
8888
* [.setChatStickerSet(chatId, stickerSetName, [options])](#TelegramBot+setChatStickerSet) ⇒ <code>Promise</code>
8989
* [.deleteChatStickerSet(chatId, [options])](#TelegramBot+deleteChatStickerSet) ⇒ <code>Promise</code>
90+
* [.getForumTopicIconStickers(chatId, [options])](#TelegramBot+getForumTopicIconStickers) ⇒ <code>Promise</code>
91+
* [.createForumTopic(chatId, name, [options])](#TelegramBot+createForumTopic)
92+
* [.editForumTopic(chatId, messageThreadId, name, iconCustomEmojiId, [options])](#TelegramBot+editForumTopic) ⇒ <code>Promise</code>
93+
* [.closeForumTopic(chatId, messageThreadId, [options])](#TelegramBot+closeForumTopic) ⇒ <code>Promise</code>
94+
* [.reopenForumTopic(chatId, messageThreadId, [options])](#TelegramBot+reopenForumTopic) ⇒ <code>Promise</code>
95+
* [.deleteForumTopic(chatId, messageThreadId, [options])](#TelegramBot+deleteForumTopic) ⇒ <code>Promise</code>
96+
* [.unpinAllForumTopicMessages(chatId, messageThreadId, [options])](#TelegramBot+unpinAllForumTopicMessages) ⇒ <code>Promise</code>
9097
* [.answerCallbackQuery(callbackQueryId, [options])](#TelegramBot+answerCallbackQuery) ⇒ <code>Promise</code>
9198
* [.setMyCommands(commands, [options])](#TelegramBot+setMyCommands) ⇒ <code>Promise</code>
9299
* [.deleteMyCommands([options])](#TelegramBot+deleteMyCommands) ⇒ <code>Promise</code>
@@ -1365,6 +1372,119 @@ Use the field `can_set_sticker_set` optionally returned in [getChat](https://cor
13651372
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
13661373
| [options] | <code>Object</code> | Additional Telegram query options |
13671374

1375+
<a name="TelegramBot+getForumTopicIconStickers"></a>
1376+
1377+
### telegramBot.getForumTopicIconStickers(chatId, [options]) ⇒ <code>Promise</code>
1378+
Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
1379+
1380+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1381+
**Returns**: <code>Promise</code> - Array of [Sticker](https://core.telegram.org/bots/api#sticker) objects
1382+
**See**: https://core.telegram.org/bots/api#getforumtopiciconstickers
1383+
1384+
| Param | Type | Description |
1385+
| --- | --- | --- |
1386+
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
1387+
| [options] | <code>Object</code> | Additional Telegram query options |
1388+
1389+
<a name="TelegramBot+createForumTopic"></a>
1390+
1391+
### telegramBot.createForumTopic(chatId, name, [options])
1392+
Use this method to create a topic in a forum supergroup chat.
1393+
The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
1394+
1395+
Returns information about the created topic as a [ForumTopic](https://core.telegram.org/bots/api#forumtopic) object.
1396+
1397+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1398+
**See**: https://core.telegram.org/bots/api#createforumtopic
1399+
1400+
| Param | Type | Description |
1401+
| --- | --- | --- |
1402+
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
1403+
| name | <code>String</code> | Topic name, 1-128 characters |
1404+
| [options] | <code>Object</code> | Additional Telegram query options |
1405+
1406+
<a name="TelegramBot+editForumTopic"></a>
1407+
1408+
### telegramBot.editForumTopic(chatId, messageThreadId, name, iconCustomEmojiId, [options]) ⇒ <code>Promise</code>
1409+
Use this method to edit name and icon of a topic in a forum supergroup chat.
1410+
The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic.
1411+
1412+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1413+
**Returns**: <code>Promise</code> - True on success
1414+
**See**: https://core.telegram.org/bots/api#editforumtopic
1415+
1416+
| Param | Type | Description |
1417+
| --- | --- | --- |
1418+
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
1419+
| messageThreadId | <code>Number</code> | Unique identifier for the target message thread of the forum topic |
1420+
| name | <code>String</code> | New topic name, 1-128 characters |
1421+
| iconCustomEmojiId | <code>String</code> | New unique identifier of the custom emoji shown as the topic icon. Use [getForumTopicIconStickers](https://core.telegram.org/bots/api#getforumtopiciconstickers) to get all allowed custom emoji identifiers |
1422+
| [options] | <code>Object</code> | Additional Telegram query options |
1423+
1424+
<a name="TelegramBot+closeForumTopic"></a>
1425+
1426+
### telegramBot.closeForumTopic(chatId, messageThreadId, [options]) ⇒ <code>Promise</code>
1427+
Use this method to close an open topic in a forum supergroup chat.
1428+
The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
1429+
1430+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1431+
**Returns**: <code>Promise</code> - True on success
1432+
**See**: https://core.telegram.org/bots/api#closeforumtopic
1433+
1434+
| Param | Type | Description |
1435+
| --- | --- | --- |
1436+
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
1437+
| messageThreadId | <code>Number</code> | Unique identifier for the target message thread of the forum topic |
1438+
| [options] | <code>Object</code> | Additional Telegram query options |
1439+
1440+
<a name="TelegramBot+reopenForumTopic"></a>
1441+
1442+
### telegramBot.reopenForumTopic(chatId, messageThreadId, [options]) ⇒ <code>Promise</code>
1443+
Use this method to reopen a closed topic in a forum supergroup chat.
1444+
The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
1445+
1446+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1447+
**Returns**: <code>Promise</code> - True on success
1448+
**See**: https://core.telegram.org/bots/api#reopenforumtopic
1449+
1450+
| Param | Type | Description |
1451+
| --- | --- | --- |
1452+
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
1453+
| messageThreadId | <code>Number</code> | Unique identifier for the target message thread of the forum topic |
1454+
| [options] | <code>Object</code> | Additional Telegram query options |
1455+
1456+
<a name="TelegramBot+deleteForumTopic"></a>
1457+
1458+
### telegramBot.deleteForumTopic(chatId, messageThreadId, [options]) ⇒ <code>Promise</code>
1459+
Use this method to delete a forum topic along with all its messages in a forum supergroup chat.
1460+
The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights.
1461+
1462+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1463+
**Returns**: <code>Promise</code> - True on success
1464+
**See**: https://core.telegram.org/bots/api#deleteforumtopic
1465+
1466+
| Param | Type | Description |
1467+
| --- | --- | --- |
1468+
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
1469+
| messageThreadId | <code>Number</code> | Unique identifier for the target message thread of the forum topic |
1470+
| [options] | <code>Object</code> | Additional Telegram query options |
1471+
1472+
<a name="TelegramBot+unpinAllForumTopicMessages"></a>
1473+
1474+
### telegramBot.unpinAllForumTopicMessages(chatId, messageThreadId, [options]) ⇒ <code>Promise</code>
1475+
Use this method to clear the list of pinned messages in a forum topic.
1476+
The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
1477+
1478+
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
1479+
**Returns**: <code>Promise</code> - True on success
1480+
**See**: https://core.telegram.org/bots/api#unpinallforumtopicmessages
1481+
1482+
| Param | Type | Description |
1483+
| --- | --- | --- |
1484+
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
1485+
| messageThreadId | <code>Number</code> | Unique identifier for the target message thread of the forum topic |
1486+
| [options] | <code>Object</code> | Additional Telegram query options |
1487+
13681488
<a name="TelegramBot+answerCallbackQuery"></a>
13691489

13701490
### telegramBot.answerCallbackQuery(callbackQueryId, [options]) ⇒ <code>Promise</code>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-telegram-bot-api",
3-
"version": "0.59.0",
3+
"version": "0.60.0",
44
"description": "Telegram Bot API",
55
"main": "./index.js",
66
"directories": {

src/telegram.js

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,121 @@ class TelegramBot extends EventEmitter {
18801880
return this._request('deleteChatStickerSet', { form });
18811881
}
18821882

1883+
/**
1884+
* Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
1885+
*
1886+
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
1887+
* @param {Object} [options] Additional Telegram query options
1888+
* @return {Promise} Array of [Sticker](https://core.telegram.org/bots/api#sticker) objects
1889+
* @see https://core.telegram.org/bots/api#getforumtopiciconstickers
1890+
*/
1891+
getForumTopicIconStickers(chatId, form = {}) {
1892+
form.chat_id = chatId;
1893+
return this._request('getForumTopicIconStickers', { form });
1894+
}
1895+
1896+
/**
1897+
* Use this method to create a topic in a forum supergroup chat.
1898+
* The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
1899+
*
1900+
* Returns information about the created topic as a [ForumTopic](https://core.telegram.org/bots/api#forumtopic) object.
1901+
*
1902+
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
1903+
* @param {String} name Topic name, 1-128 characters
1904+
* @param {Object} [options] Additional Telegram query options
1905+
* @see https://core.telegram.org/bots/api#createforumtopic
1906+
*/
1907+
createForumTopic(chatId, name, form = {}) {
1908+
form.chat_id = chatId;
1909+
form.name = name;
1910+
return this._request('createForumTopic', { form });
1911+
}
1912+
1913+
/**
1914+
* Use this method to edit name and icon of a topic in a forum supergroup chat.
1915+
* The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic.
1916+
*
1917+
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
1918+
* @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
1919+
* @param {String} name New topic name, 1-128 characters
1920+
* @param {String} iconCustomEmojiId New unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers
1921+
* @param {Object} [options] Additional Telegram query options
1922+
* @return {Promise} True on success
1923+
* @see https://core.telegram.org/bots/api#editforumtopic
1924+
*/
1925+
editForumTopic(chatId, messageThreadId, name, iconCustomEmojiId, form = {}) {
1926+
form.chat_id = chatId;
1927+
form.message_thread_id = messageThreadId;
1928+
form.name = name;
1929+
form.icon_custom_emoji_id = iconCustomEmojiId;
1930+
return this._request('editForumTopic', { form });
1931+
}
1932+
1933+
/**
1934+
* Use this method to close an open topic in a forum supergroup chat.
1935+
* The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
1936+
*
1937+
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
1938+
* @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
1939+
* @param {Object} [options] Additional Telegram query options
1940+
* @return {Promise} True on success
1941+
* @see https://core.telegram.org/bots/api#closeforumtopic
1942+
*/
1943+
closeForumTopic(chatId, messageThreadId, form = {}) {
1944+
form.chat_id = chatId;
1945+
form.message_thread_id = messageThreadId;
1946+
return this._request('closeForumTopic', { form });
1947+
}
1948+
1949+
/**
1950+
* Use this method to reopen a closed topic in a forum supergroup chat.
1951+
* The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
1952+
*
1953+
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
1954+
* @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
1955+
* @param {Object} [options] Additional Telegram query options
1956+
* @return {Promise} True on success
1957+
* @see https://core.telegram.org/bots/api#reopenforumtopic
1958+
*/
1959+
reopenForumTopic(chatId, messageThreadId, form = {}) {
1960+
form.chat_id = chatId;
1961+
form.message_thread_id = messageThreadId;
1962+
return this._request('reopenForumTopic', { form });
1963+
}
1964+
1965+
/**
1966+
* Use this method to delete a forum topic along with all its messages in a forum supergroup chat.
1967+
* The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights.
1968+
*
1969+
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
1970+
* @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
1971+
* @param {Object} [options] Additional Telegram query options
1972+
* @return {Promise} True on success
1973+
* @see https://core.telegram.org/bots/api#deleteforumtopic
1974+
*/
1975+
deleteForumTopic(chatId, messageThreadId, form = {}) {
1976+
form.chat_id = chatId;
1977+
form.message_thread_id = messageThreadId;
1978+
return this._request('deleteForumTopic', { form });
1979+
}
1980+
1981+
/**
1982+
* Use this method to clear the list of pinned messages in a forum topic.
1983+
* The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
1984+
*
1985+
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
1986+
* @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
1987+
* @param {Object} [options] Additional Telegram query options
1988+
* @return {Promise} True on success
1989+
* @see https://core.telegram.org/bots/api#unpinallforumtopicmessages
1990+
*/
1991+
unpinAllForumTopicMessages(chatId, messageThreadId, form = {}) {
1992+
form.chat_id = chatId;
1993+
form.message_thread_id = messageThreadId;
1994+
return this._request('unpinAllForumTopicMessages', { form });
1995+
}
1996+
1997+
18831998
/**
18841999
* Use this method to send answers to callback queries sent from
18852000
* [inline keyboards](https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating).

test/telegram.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,8 @@ describe('TelegramBot', function telegramSuite() {
14851485
can_pin_messages: true,
14861486
can_promote_members: false,
14871487
can_manage_video_chats: false,
1488-
is_anonymous: false
1488+
is_anonymous: false,
1489+
can_manage_topics: false,
14891490
}));
14901491
});
14911492
});

0 commit comments

Comments
 (0)