mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-22 18:07:16 +00:00
feat: Telegram Bot API v6.3 (#1020)
* feat: Telegram Topics * update docs * fix: test * update: docs
This commit is contained in:
parent
0eb8b8032f
commit
ab5928669b
14
CHANGELOG.md
14
CHANGELOG.md
@ -3,6 +3,20 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [0.60.0][0.60.0] - 2022-10-06
|
||||
|
||||
1. Support Telegram Bot API v6.3 (@danielperez9430)
|
||||
* createForumTopic
|
||||
* closeForumTopic
|
||||
* reopenForumTopic
|
||||
* deleteForumTopic
|
||||
* unpinAllForumTopicMessages
|
||||
* getForumTopicIconStickers
|
||||
|
||||
2. Fix test getMyDefaultAdministratorRights (@danielperez9430)
|
||||
|
||||
3. Fix parse entities - (@toniop99)
|
||||
|
||||
## [0.59.0][0.59.0] - 2022-08-15
|
||||
|
||||
1. Support Telegram Bot API v6.2 (@danielperez9430)
|
||||
|
@ -5,7 +5,7 @@
|
||||
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://travis-ci.org/yagop/node-telegram-bot-api)
|
||||
[](https://codecov.io/gh/yagop/node-telegram-bot-api)
|
||||
|
120
doc/api.md
120
doc/api.md
@ -87,6 +87,13 @@ TelegramBot
|
||||
* [.getChatMember(chatId, userId, [options])](#TelegramBot+getChatMember) ⇒ <code>Promise</code>
|
||||
* [.setChatStickerSet(chatId, stickerSetName, [options])](#TelegramBot+setChatStickerSet) ⇒ <code>Promise</code>
|
||||
* [.deleteChatStickerSet(chatId, [options])](#TelegramBot+deleteChatStickerSet) ⇒ <code>Promise</code>
|
||||
* [.getForumTopicIconStickers(chatId, [options])](#TelegramBot+getForumTopicIconStickers) ⇒ <code>Promise</code>
|
||||
* [.createForumTopic(chatId, name, [options])](#TelegramBot+createForumTopic)
|
||||
* [.editForumTopic(chatId, messageThreadId, name, iconCustomEmojiId, [options])](#TelegramBot+editForumTopic) ⇒ <code>Promise</code>
|
||||
* [.closeForumTopic(chatId, messageThreadId, [options])](#TelegramBot+closeForumTopic) ⇒ <code>Promise</code>
|
||||
* [.reopenForumTopic(chatId, messageThreadId, [options])](#TelegramBot+reopenForumTopic) ⇒ <code>Promise</code>
|
||||
* [.deleteForumTopic(chatId, messageThreadId, [options])](#TelegramBot+deleteForumTopic) ⇒ <code>Promise</code>
|
||||
* [.unpinAllForumTopicMessages(chatId, messageThreadId, [options])](#TelegramBot+unpinAllForumTopicMessages) ⇒ <code>Promise</code>
|
||||
* [.answerCallbackQuery(callbackQueryId, [options])](#TelegramBot+answerCallbackQuery) ⇒ <code>Promise</code>
|
||||
* [.setMyCommands(commands, [options])](#TelegramBot+setMyCommands) ⇒ <code>Promise</code>
|
||||
* [.deleteMyCommands([options])](#TelegramBot+deleteMyCommands) ⇒ <code>Promise</code>
|
||||
@ -1365,6 +1372,119 @@ Use the field `can_set_sticker_set` optionally returned in [getChat](https://cor
|
||||
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot+getForumTopicIconStickers"></a>
|
||||
|
||||
### telegramBot.getForumTopicIconStickers(chatId, [options]) ⇒ <code>Promise</code>
|
||||
Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
|
||||
|
||||
**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#getforumtopiciconstickers
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot+createForumTopic"></a>
|
||||
|
||||
### telegramBot.createForumTopic(chatId, name, [options])
|
||||
Use this method to create a topic in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
|
||||
|
||||
Returns information about the created topic as a [ForumTopic](https://core.telegram.org/bots/api#forumtopic) object.
|
||||
|
||||
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||
**See**: https://core.telegram.org/bots/api#createforumtopic
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||
| name | <code>String</code> | Topic name, 1-128 characters |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot+editForumTopic"></a>
|
||||
|
||||
### telegramBot.editForumTopic(chatId, messageThreadId, name, iconCustomEmojiId, [options]) ⇒ <code>Promise</code>
|
||||
Use this method to edit name and icon of a topic in a forum supergroup chat.
|
||||
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.
|
||||
|
||||
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||
**Returns**: <code>Promise</code> - True on success
|
||||
**See**: https://core.telegram.org/bots/api#editforumtopic
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||
| messageThreadId | <code>Number</code> | Unique identifier for the target message thread of the forum topic |
|
||||
| name | <code>String</code> | New topic name, 1-128 characters |
|
||||
| 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 |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot+closeForumTopic"></a>
|
||||
|
||||
### telegramBot.closeForumTopic(chatId, messageThreadId, [options]) ⇒ <code>Promise</code>
|
||||
Use this method to close an open topic in a forum supergroup chat.
|
||||
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.
|
||||
|
||||
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||
**Returns**: <code>Promise</code> - True on success
|
||||
**See**: https://core.telegram.org/bots/api#closeforumtopic
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||
| messageThreadId | <code>Number</code> | Unique identifier for the target message thread of the forum topic |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot+reopenForumTopic"></a>
|
||||
|
||||
### telegramBot.reopenForumTopic(chatId, messageThreadId, [options]) ⇒ <code>Promise</code>
|
||||
Use this method to reopen a closed topic in a forum supergroup chat.
|
||||
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.
|
||||
|
||||
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||
**Returns**: <code>Promise</code> - True on success
|
||||
**See**: https://core.telegram.org/bots/api#reopenforumtopic
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||
| messageThreadId | <code>Number</code> | Unique identifier for the target message thread of the forum topic |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot+deleteForumTopic"></a>
|
||||
|
||||
### telegramBot.deleteForumTopic(chatId, messageThreadId, [options]) ⇒ <code>Promise</code>
|
||||
Use this method to delete a forum topic along with all its messages in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights.
|
||||
|
||||
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||
**Returns**: <code>Promise</code> - True on success
|
||||
**See**: https://core.telegram.org/bots/api#deleteforumtopic
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||
| messageThreadId | <code>Number</code> | Unique identifier for the target message thread of the forum topic |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot+unpinAllForumTopicMessages"></a>
|
||||
|
||||
### telegramBot.unpinAllForumTopicMessages(chatId, messageThreadId, [options]) ⇒ <code>Promise</code>
|
||||
Use this method to clear the list of pinned messages in a forum topic.
|
||||
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.
|
||||
|
||||
**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
|
||||
**Returns**: <code>Promise</code> - True on success
|
||||
**See**: https://core.telegram.org/bots/api#unpinallforumtopicmessages
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||
| messageThreadId | <code>Number</code> | Unique identifier for the target message thread of the forum topic |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot+answerCallbackQuery"></a>
|
||||
|
||||
### telegramBot.answerCallbackQuery(callbackQueryId, [options]) ⇒ <code>Promise</code>
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-telegram-bot-api",
|
||||
"version": "0.59.0",
|
||||
"version": "0.60.0",
|
||||
"description": "Telegram Bot API",
|
||||
"main": "./index.js",
|
||||
"directories": {
|
||||
|
115
src/telegram.js
115
src/telegram.js
@ -1880,6 +1880,121 @@ class TelegramBot extends EventEmitter {
|
||||
return this._request('deleteChatStickerSet', { form });
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
|
||||
*
|
||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
||||
* @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#getforumtopiciconstickers
|
||||
*/
|
||||
getForumTopicIconStickers(chatId, form = {}) {
|
||||
form.chat_id = chatId;
|
||||
return this._request('getForumTopicIconStickers', { form });
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to create a topic in a forum supergroup chat.
|
||||
* The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
|
||||
*
|
||||
* Returns information about the created topic as a [ForumTopic](https://core.telegram.org/bots/api#forumtopic) object.
|
||||
*
|
||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
||||
* @param {String} name Topic name, 1-128 characters
|
||||
* @param {Object} [options] Additional Telegram query options
|
||||
* @see https://core.telegram.org/bots/api#createforumtopic
|
||||
*/
|
||||
createForumTopic(chatId, name, form = {}) {
|
||||
form.chat_id = chatId;
|
||||
form.name = name;
|
||||
return this._request('createForumTopic', { form });
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to edit name and icon of a topic in a forum supergroup chat.
|
||||
* 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.
|
||||
*
|
||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
||||
* @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
|
||||
* @param {String} name New topic name, 1-128 characters
|
||||
* @param {String} iconCustomEmojiId New unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers
|
||||
* @param {Object} [options] Additional Telegram query options
|
||||
* @return {Promise} True on success
|
||||
* @see https://core.telegram.org/bots/api#editforumtopic
|
||||
*/
|
||||
editForumTopic(chatId, messageThreadId, name, iconCustomEmojiId, form = {}) {
|
||||
form.chat_id = chatId;
|
||||
form.message_thread_id = messageThreadId;
|
||||
form.name = name;
|
||||
form.icon_custom_emoji_id = iconCustomEmojiId;
|
||||
return this._request('editForumTopic', { form });
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to close an open topic in a forum supergroup chat.
|
||||
* 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.
|
||||
*
|
||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
||||
* @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
|
||||
* @param {Object} [options] Additional Telegram query options
|
||||
* @return {Promise} True on success
|
||||
* @see https://core.telegram.org/bots/api#closeforumtopic
|
||||
*/
|
||||
closeForumTopic(chatId, messageThreadId, form = {}) {
|
||||
form.chat_id = chatId;
|
||||
form.message_thread_id = messageThreadId;
|
||||
return this._request('closeForumTopic', { form });
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to reopen a closed topic in a forum supergroup chat.
|
||||
* 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.
|
||||
*
|
||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
||||
* @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
|
||||
* @param {Object} [options] Additional Telegram query options
|
||||
* @return {Promise} True on success
|
||||
* @see https://core.telegram.org/bots/api#reopenforumtopic
|
||||
*/
|
||||
reopenForumTopic(chatId, messageThreadId, form = {}) {
|
||||
form.chat_id = chatId;
|
||||
form.message_thread_id = messageThreadId;
|
||||
return this._request('reopenForumTopic', { form });
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to delete a forum topic along with all its messages in a forum supergroup chat.
|
||||
* The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights.
|
||||
*
|
||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
||||
* @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
|
||||
* @param {Object} [options] Additional Telegram query options
|
||||
* @return {Promise} True on success
|
||||
* @see https://core.telegram.org/bots/api#deleteforumtopic
|
||||
*/
|
||||
deleteForumTopic(chatId, messageThreadId, form = {}) {
|
||||
form.chat_id = chatId;
|
||||
form.message_thread_id = messageThreadId;
|
||||
return this._request('deleteForumTopic', { form });
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to clear the list of pinned messages in a forum topic.
|
||||
* 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.
|
||||
*
|
||||
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
|
||||
* @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
|
||||
* @param {Object} [options] Additional Telegram query options
|
||||
* @return {Promise} True on success
|
||||
* @see https://core.telegram.org/bots/api#unpinallforumtopicmessages
|
||||
*/
|
||||
unpinAllForumTopicMessages(chatId, messageThreadId, form = {}) {
|
||||
form.chat_id = chatId;
|
||||
form.message_thread_id = messageThreadId;
|
||||
return this._request('unpinAllForumTopicMessages', { form });
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use this method to send answers to callback queries sent from
|
||||
* [inline keyboards](https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating).
|
||||
|
@ -1485,7 +1485,8 @@ describe('TelegramBot', function telegramSuite() {
|
||||
can_pin_messages: true,
|
||||
can_promote_members: false,
|
||||
can_manage_video_chats: false,
|
||||
is_anonymous: false
|
||||
is_anonymous: false,
|
||||
can_manage_topics: false,
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user