diff --git a/README.md b/README.md index b4439df..326f504 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ TelegramBot * [.getChatAdministrators(chatId)](#TelegramBot+getChatAdministrators) ⇒ Promise * [.getChatMembersCount(chatId)](#TelegramBot+getChatMembersCount) ⇒ Promise * [.getChatMember(chatId, userId)](#TelegramBot+getChatMember) ⇒ Promise + * [.leaveChat(chatId)](#TelegramBot+leaveChat) ⇒ Promise @@ -572,4 +573,16 @@ Use this method to get information about a member of a chat. | chatId | Number | String | Unique identifier for the target group or username of the target supergroup | | userId | String | Unique identifier of the target user | + + +### telegramBot.leaveChat(chatId) ⇒ Promise +Leave a group, supergroup or channel. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#leavechat + +| Param | Type | Description | +| --- | --- | --- | +| chatId | Number | String | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) | + * * * diff --git a/src/telegram.js b/src/telegram.js index efcc0c1..1119688 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -796,6 +796,19 @@ class TelegramBot extends EventEmitter { }; return this._request('getChatMember', { form }); } + + /** + * Leave a group, supergroup or channel. + * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) + * @return {Promise} + * @see https://core.telegram.org/bots/api#leavechat + */ + leaveChat(chatId) { + const form = { + chat_id: chatId + }; + return this._request('leaveChat', { form }); + } } module.exports = TelegramBot;