From d0d03d0c097e1973e506db5d64d1cc895e22479c Mon Sep 17 00:00:00 2001 From: coder2020official Date: Sat, 4 Feb 2023 19:59:49 +0400 Subject: [PATCH] Added use_independent_chat_permissions for restrictchatmember --- telebot/__init__.py | 11 +++++++++-- telebot/apihelper.py | 5 ++++- telebot/async_telebot.py | 11 +++++++++-- telebot/asyncio_helper.py | 5 ++++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index 6f6b452..095b12e 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -2917,7 +2917,8 @@ class TeleBot: can_add_web_page_previews: Optional[bool]=None, can_change_info: Optional[bool]=None, can_invite_users: Optional[bool]=None, - can_pin_messages: Optional[bool]=None) -> bool: + can_pin_messages: Optional[bool]=None, + use_independent_chat_permissions: Optional[bool]=None) -> bool: """ Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have @@ -2965,6 +2966,12 @@ class TeleBot: :param can_pin_messages: Pass True, if the user is allowed to pin messages. Ignored in public supergroups :type can_pin_messages: :obj:`bool` + :param use_independent_chat_permissions: Pass True if chat permissions are set independently. Otherwise, + the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, + can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and + can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission. + :type use_independent_chat_permissions: :obj:`bool` + :return: True on success :rtype: :obj:`bool` """ @@ -2973,7 +2980,7 @@ class TeleBot: can_send_messages, can_send_media_messages, can_send_polls, can_send_other_messages, can_add_web_page_previews, can_change_info, - can_invite_users, can_pin_messages) + can_invite_users, can_pin_messages, use_independent_chat_permissions) def promote_chat_member( self, chat_id: Union[int, str], user_id: int, diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 1086f54..aa9e337 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -972,7 +972,7 @@ def restrict_chat_member( can_send_messages=None, can_send_media_messages=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_change_info=None, - can_invite_users=None, can_pin_messages=None): + can_invite_users=None, can_pin_messages=None, use_independent_chat_permissions=None): method_url = 'restrictChatMember' permissions = {} if can_send_messages is not None: @@ -991,6 +991,9 @@ def restrict_chat_member( permissions['can_invite_users'] = can_invite_users if can_pin_messages is not None: permissions['can_pin_messages'] = can_pin_messages + if use_independent_chat_permissions is not None: + permissions['use_independent_chat_permissions'] = use_independent_chat_permissions + permissions_json = json.dumps(permissions) payload = {'chat_id': chat_id, 'user_id': user_id, 'permissions': permissions_json} if until_date is not None: diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 8dbf55a..d976c78 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -3775,7 +3775,8 @@ class AsyncTeleBot: can_add_web_page_previews: Optional[bool]=None, can_change_info: Optional[bool]=None, can_invite_users: Optional[bool]=None, - can_pin_messages: Optional[bool]=None) -> bool: + can_pin_messages: Optional[bool]=None, + use_independent_chat_permissions: Optional[bool]=None) -> bool: """ Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have @@ -3823,6 +3824,12 @@ class AsyncTeleBot: :param can_pin_messages: Pass True, if the user is allowed to pin messages. Ignored in public supergroups :type can_pin_messages: :obj:`bool` + :param use_independent_chat_permissions: Pass True if chat permissions are set independently. Otherwise, + the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, + can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and + can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission. + :type use_independent_chat_permissions: :obj:`bool` + :return: True on success :rtype: :obj:`bool` """ @@ -3831,7 +3838,7 @@ class AsyncTeleBot: can_send_messages, can_send_media_messages, can_send_polls, can_send_other_messages, can_add_web_page_previews, can_change_info, - can_invite_users, can_pin_messages) + can_invite_users, can_pin_messages, use_independent_chat_permissions) async def promote_chat_member( self, chat_id: Union[int, str], user_id: int, diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index 219cc1d..df4b17c 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -964,7 +964,7 @@ async def restrict_chat_member( can_send_messages=None, can_send_media_messages=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_change_info=None, - can_invite_users=None, can_pin_messages=None): + can_invite_users=None, can_pin_messages=None, use_independent_chat_permissions=None): method_url = 'restrictChatMember' permissions = {} if can_send_messages is not None: @@ -983,6 +983,9 @@ async def restrict_chat_member( permissions['can_invite_users'] = can_invite_users if can_pin_messages is not None: permissions['can_pin_messages'] = can_pin_messages + if use_independent_chat_permissions is not None: + permissions['use_independent_chat_permissions'] = use_independent_chat_permissions + permissions_json = json.dumps(permissions) payload = {'chat_id': chat_id, 'user_id': user_id, 'permissions': permissions_json} if until_date is not None: