diff --git a/CHANGELOG.md b/CHANGELOG.md index 59066f4..e7021de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). * getAvailableGifts (@danielperez9430) * sendGift (@danielperez9430) +4. Support Telegram Bot API 8.2 and 8.3 (@danielperez9430) + * verifyUser + * verifyChat + * removeUserVerification + * removeChatVerification + ## [0.67.0][0.67.0] - 2024-05-30 1. Support Telegram Bot API 7.4 (@danielperez9430) diff --git a/README.md b/README.md index 4c1fe50..04f4fb1 100644 --- a/README.md +++ b/README.md @@ -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.8.1-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api) +[![Bot API](https://img.shields.io/badge/Bot%20API-v.8.3-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) [![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) diff --git a/doc/api.md b/doc/api.md index 487a3b3..1424e36 100644 --- a/doc/api.md +++ b/doc/api.md @@ -161,6 +161,10 @@ TelegramBot * [.deleteMessages(chatId, messageIds, [options])](#TelegramBot+deleteMessages) ⇒ [ 'Promise' ].<Boolean> * [.getAvailableGifts([options])](#TelegramBot+getAvailableGifts) ⇒ Promise * [.sendGift(giftId, [options])](#TelegramBot+sendGift) ⇒ Promise + * [.verifyUser(userId)](#TelegramBot+verifyUser) ⇒ Promise + * [.verifyChat(chatId)](#TelegramBot+verifyChat) ⇒ Promise + * [.removeUserVerification(userId)](#TelegramBot+removeUserVerification) ⇒ Promise + * [.removeChatVerification(chatId)](#TelegramBot+removeChatVerification) ⇒ Promise * _static_ * [.errors](#TelegramBot.errors) : Object * [.messageTypes](#TelegramBot.messageTypes) : [ 'Array' ].<String> @@ -2609,6 +2613,58 @@ Use this method to sends a gift to the given user or channel chat. | giftId | String | Unique identifier of the gift | | [options] | Object | Additional Telegram query options | + + +### telegramBot.verifyUser(userId) ⇒ Promise +This method verifies a user [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#verifyuser + +| Param | Type | Description | +| --- | --- | --- | +| userId | Number | Unique identifier of the target user | + + + +### telegramBot.verifyChat(chatId) ⇒ Promise +This method verifies a chat [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#verifychat + +| Param | Type | Description | +| --- | --- | --- | +| chatId | Number | Unique identifier of the target chat | + + + +### telegramBot.removeUserVerification(userId) ⇒ Promise +This method removes verification from a user who is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#removeuserverification + +| Param | Type | Description | +| --- | --- | --- | +| userId | Number | Unique identifier of the target user | + + + +### telegramBot.removeChatVerification(chatId) ⇒ Promise +This method removes verification from a chat who is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**Returns**: Promise - On success, returns true. +**See**: https://core.telegram.org/bots/api#removechatverification + +| Param | Type | Description | +| --- | --- | --- | +| chatId | Number | Unique identifier of the target chat | + ### TelegramBot.errors : Object diff --git a/src/telegram.js b/src/telegram.js index 0e2cca4..f3df5d0 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -3356,7 +3356,55 @@ class TelegramBot extends EventEmitter { */ sendGift(giftId, form = {}) { form.gift_id = giftId; - return this._request('getAvailableGifts', { form }); + return this._request('sendGift', { form }); + } + + /** + * This method verifies a user [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. + * + * @param {Number} userId Unique identifier of the target user + * @return {Promise} On success, returns true. + * @see https://core.telegram.org/bots/api#verifyuser + */ + verifyUser(userId, form = {}) { + form.user_id = userId; + return this._request('verifyUser', { form }); + } + + /** + * This method verifies a chat [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. + * + * @param {Number} chatId Unique identifier of the target chat + * @return {Promise} On success, returns true. + * @see https://core.telegram.org/bots/api#verifychat + */ + verifyChat(chatId, form = {}) { + form.chat_id = chatId; + return this._request('verifyChat', { form }); + } + + /** + * This method removes verification from a user who is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. + * + * @param {Number} userId Unique identifier of the target user + * @return {Promise} On success, returns true. + * @see https://core.telegram.org/bots/api#removeuserverification + */ + removeUserVerification(userId, form = {}) { + form.user_id = userId; + return this._request('removeUserVerification', { form }); + } + + /** + * This method removes verification from a chat who is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. + * + * @param {Number} chatId Unique identifier of the target chat + * @return {Promise} On success, returns true. + * @see https://core.telegram.org/bots/api#removechatverification + */ + removeChatVerification(chatId, form = {}) { + form.chat_id = chatId; + return this._request('removeChatVerification', { form }); } }