Skip to content

Commit 4836dc6

Browse files
authored
fix: set_chat_permissions method miss permission handle (#204)
1 parent b552050 commit 4836dc6

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

pyrogram/methods/chats/restrict_chat_member.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ async def restrict_chat_member(
5252
New user permissions.
5353
5454
use_independent_chat_permissions (``bool``, *optional*):
55-
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.
55+
Pass True if chat permissions are set independently.
56+
Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will
57+
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;
58+
the can_send_polls permission will imply the can_send_messages permission.
5659
5760
until_date (:py:obj:`~datetime.datetime`, *optional*):
5861
Date when the user will be unbanned.

pyrogram/methods/chats/set_chat_permissions.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ async def set_chat_permissions(
2828
self: "pyrogram.Client",
2929
chat_id: Union[int, str],
3030
permissions: "types.ChatPermissions",
31+
use_independent_chat_permissions: bool = False,
3132
) -> "types.Chat":
3233
"""Set default chat permissions for all members.
3334
@@ -43,6 +44,12 @@ async def set_chat_permissions(
4344
permissions (:obj:`~pyrogram.types.ChatPermissions`):
4445
New default chat permissions.
4546
47+
use_independent_chat_permissions (``bool``, *optional*):
48+
Pass True if chat permissions are set independently.
49+
Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will
50+
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;
51+
the can_send_polls permission will imply the can_send_messages permission.
52+
4653
Returns:
4754
:obj:`~pyrogram.types.Chat`: On success, a chat object is returned.
4855
@@ -67,20 +74,7 @@ async def set_chat_permissions(
6774
r = await self.invoke(
6875
raw.functions.messages.EditChatDefaultBannedRights(
6976
peer=await self.resolve_peer(chat_id),
70-
banned_rights=raw.types.ChatBannedRights(
71-
until_date=0,
72-
send_messages=not permissions.can_send_messages,
73-
send_media=not permissions.can_send_media_messages,
74-
send_stickers=not permissions.can_send_other_messages,
75-
send_gifs=not permissions.can_send_other_messages,
76-
send_games=not permissions.can_send_other_messages,
77-
send_inline=not permissions.can_send_other_messages,
78-
embed_links=not permissions.can_add_web_page_previews,
79-
send_polls=not permissions.can_send_polls,
80-
change_info=not permissions.can_change_info,
81-
invite_users=not permissions.can_invite_users,
82-
pin_messages=not permissions.can_pin_messages,
83-
)
77+
banned_rights=permissions.write(use_independent_chat_permissions)
8478
)
8579
)
8680

0 commit comments

Comments
 (0)