2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 13:27:44 +00:00

feat: banChatSenderChat and unbanChatSenderChat methods

This commit is contained in:
danielperez9430 2021-12-07 16:42:00 +01:00
parent 19b5fc5bd3
commit 5ff22148d8
2 changed files with 42 additions and 0 deletions

View File

@ -1148,6 +1148,44 @@ class TelegramBot extends EventEmitter {
return this._request('setChatAdministratorCustomTitle', { form });
}
/**
* Use this method to ban a channel chat in a supergroup or a channel.
* The owner of the chat will not be able to send messages and join live streams
* on behalf of the chat, unless it is unbanned first.
* The bot must be an administrator in the supergroup or channel for this to work
* and must have the appropriate administrator rights.
* Returns True on success.
*
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
* @param {Number} senderChatId Unique identifier of the target user
* @param {Object} [options] Additional Telegram query options
* @return {Boolean}
* @see https://core.telegram.org/bots/api#banchatsenderchat
*/
banChatSenderChat(chatId, senderChatId, form = {}) {
form.chat_id = chatId;
form.sender_chat_id = senderChatId;
return this._request('banChatSenderChat', { form });
}
/**
* Use this method to unban a previously banned channel chat in a supergroup or channel.
* The bot must be an administrator for this to work and must have the appropriate administrator rights.
* Returns True on success.
*
* @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
* @param {Number} senderChatId Unique identifier of the target user
* @param {Object} [options] Additional Telegram query options
* @return {Boolean}
* @see https://core.telegram.org/bots/api#unbanchatsenderchat
*/
unbanChatSenderChat(chatId, senderChatId, form = {}) {
form.chat_id = chatId;
form.sender_chat_id = senderChatId;
return this._request('unbanChatSenderChat', { form });
}
/**
* Use this method to set default chat permissions for all members.
* The bot must be an administrator in the group or a supergroup for this to

View File

@ -880,6 +880,10 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe.skip('#banChatSenderChat', function banChatSenderChatSuite() { });
describe.skip('#unbanChatSenderChat', function banChatSenderChatSuite() { });
describe('#setChatPermissions ', function setChatPermissionsSuite() {
it('should set chat permissions', function test() {
const ChatPermissions = {