diff --git a/src/telegram.js b/src/telegram.js index 7c84f20..de2a2ea 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -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 diff --git a/test/telegram.js b/test/telegram.js index 5a11aad..f9f3258 100644 --- a/test/telegram.js +++ b/test/telegram.js @@ -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 = {