2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-28 21:07:39 +00:00

Closes #186: Add TelegramBot#leaveChat() method

This commit is contained in:
GochoMugo 2016-10-10 14:48:28 +03:00
commit ce4decebd8
No known key found for this signature in database
GPG Key ID: 7B6A01CB57AA39E4
2 changed files with 26 additions and 0 deletions

View File

@ -91,6 +91,7 @@ TelegramBot
* [.getChatAdministrators(chatId)](#TelegramBot+getChatAdministrators) ⇒ <code>Promise</code>
* [.getChatMembersCount(chatId)](#TelegramBot+getChatMembersCount) ⇒ <code>Promise</code>
* [.getChatMember(chatId, userId)](#TelegramBot+getChatMember) ⇒ <code>Promise</code>
* [.leaveChat(chatId)](#TelegramBot+leaveChat) ⇒ <code>Promise</code>
<a name="new_TelegramBot_new"></a>
@ -572,4 +573,16 @@ Use this method to get information about a member of a chat.
| chatId | <code>Number</code> &#124; <code>String</code> | Unique identifier for the target group or username of the target supergroup |
| userId | <code>String</code> | Unique identifier of the target user |
<a name="TelegramBot+leaveChat"></a>
### telegramBot.leaveChat(chatId) ⇒ <code>Promise</code>
Leave a group, supergroup or channel.
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
**See**: https://core.telegram.org/bots/api#leavechat
| Param | Type | Description |
| --- | --- | --- |
| chatId | <code>Number</code> &#124; <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
* * *

View File

@ -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;