diff --git a/CHANGELOG.md b/CHANGELOG.md index b959b3b..9b6b621 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.61.0][0.61.0] - 2022-12-30 + +1. Support Telegram Bot API v6.4 (@danielperez9430) + * editGeneralForumTopic + * closeGeneralForumTopic + * reopenGeneralForumTopic + * hideGeneralForumTopic + * unhideGeneralForumTopic + +2. Minor changes: + * The parameters `name` and `icon_custom_emoji_id` of the method `editForumTopic` are now optional. + ## [0.60.0][0.60.0] - 2022-10-06 1. Support Telegram Bot API v6.3 (@danielperez9430) diff --git a/package.json b/package.json index 233da35..d26fecb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-telegram-bot-api", - "version": "0.60.0", + "version": "0.61.0", "description": "Telegram Bot API", "main": "./index.js", "directories": { @@ -71,4 +71,4 @@ "url": "https://github.com/yagop/node-telegram-bot-api/issues" }, "homepage": "https://github.com/yagop/node-telegram-bot-api" -} \ No newline at end of file +} diff --git a/src/telegram.js b/src/telegram.js index 5e7ef8e..0316dd1 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -1916,17 +1916,13 @@ class TelegramBot extends EventEmitter { * * @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 = {}) { + editForumTopic(chatId, messageThreadId, form = {}) { form.chat_id = chatId; form.message_thread_id = messageThreadId; - form.name = name; - form.icon_custom_emoji_id = iconCustomEmojiId; return this._request('editForumTopic', { form }); } @@ -1994,6 +1990,81 @@ class TelegramBot extends EventEmitter { return this._request('unpinAllForumTopicMessages', { form }); } + /** + * Use this method to edit the name of the 'General' 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. + * The topic will be automatically unhidden if it was hidden. + * + * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) + * @param {String} name New topic name, 1-128 characters + * @param {Object} [options] Additional Telegram query options + * @return {Promise} True on success + * @see https://core.telegram.org/bots/api#editgeneralforumtopic + */ + editGeneralForumTopic(chatId, name, form = {}) { + form.chat_id = chatId; + form.name = name; + return this._request('editGeneralForumTopic', { form }); + } + + /** + * Use this method to close an open 'General' 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. + * The topic will be automatically unhidden if it was hidden. + * + * @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} True on success + * @see https://core.telegram.org/bots/api#closegeneralforumtopic + */ + closeGeneralForumTopic(chatId, form = {}) { + form.chat_id = chatId; + return this._request('closeGeneralForumTopic', { form }); + } + + /** + * Use this method to reopen a closed 'General' 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. + * The topic will be automatically unhidden if it was hidden. + * + * @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} True on success + * @see https://core.telegram.org/bots/api#reopengeneralforumtopic + */ + reopenGeneralForumTopic(chatId, form = {}) { + form.chat_id = chatId; + return this._request('reopenGeneralForumTopic', { form }); + } + + /** + * Use this method to hide the 'General' 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. + * The topic will be automatically closed if it was open. + * + * @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} True on success + * @see https://core.telegram.org/bots/api#hidegeneralforumtopic + */ + hideGeneralForumTopic(chatId, form = {}) { + form.chat_id = chatId; + return this._request('hideGeneralForumTopic', { form }); + } + + /** + * Use this method to unhide the 'General' 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 + * + * @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} True on success + * @see https://core.telegram.org/bots/api#unhidegeneralforumtopic + */ + unhideGeneralForumTopic(chatId, form = {}) { + form.chat_id = chatId; + return this._request('unhideGeneralForumTopic', { form }); + } /** * Use this method to send answers to callback queries sent from