From b60f065a838bb5a363bcc73d129509c3497b17ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=C3=A9rez=20Fern=C3=A1ndez?= Date: Sun, 7 Nov 2021 16:06:51 +0100 Subject: [PATCH] feat: Add new method "approveChatJoinRequest" and "declineChatJoinRequest" --- src/telegram.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/telegram.js b/src/telegram.js index 15eb07b..330b67f 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -1225,6 +1225,40 @@ class TelegramBot extends EventEmitter { return this._request('revokeChatInviteLink', { form }); } + /** + * Use this method to approve a chat join request. + * The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. + * Returns True on success. + * + * @param {Number|String} chatId Unique identifier for the target chat or username of the target supergroup + * @param {Number} userId Unique identifier of the target user + * @param {Object} [options] Additional Telegram query options + * @return {Boolean} True on success + * @see https://core.telegram.org/bots/api#approvechatjoinrequest + */ + approveChatJoinRequest(chatId, userId, form = {}) { + form.chat_id = chatId; + form.user_id = userId; + return this._request('approveChatJoinRequest', { form }); + } + + /** + * Use this method to decline a chat join request. + * The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. + * Returns True on success. + * + * @param {Number|String} chatId Unique identifier for the target chat or username of the target supergroup + * @param {Number} userId Unique identifier of the target user + * @param {Object} [options] Additional Telegram query options + * @return {Boolean} True on success + * @see https://core.telegram.org/bots/api#declinechatjoinrequest + */ + declineChatJoinRequest(chatId, userId, form = {}) { + form.chat_id = chatId; + form.user_id = userId; + return this._request('declineChatJoinRequest', { form }); + } + /** * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats.