Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pyrogram/methods/chats/restrict_chat_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ async def restrict_chat_member(
New user permissions.

use_independent_chat_permissions (``bool``, *optional*):
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.
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.

until_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the user will be unbanned.
Expand Down
22 changes: 8 additions & 14 deletions pyrogram/methods/chats/set_chat_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async def set_chat_permissions(
self: "pyrogram.Client",
chat_id: Union[int, str],
permissions: "types.ChatPermissions",
use_independent_chat_permissions: bool = False,
) -> "types.Chat":
"""Set default chat permissions for all members.

Expand All @@ -43,6 +44,12 @@ async def set_chat_permissions(
permissions (:obj:`~pyrogram.types.ChatPermissions`):
New default chat permissions.

use_independent_chat_permissions (``bool``, *optional*):
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.

Returns:
:obj:`~pyrogram.types.Chat`: On success, a chat object is returned.

Expand All @@ -67,20 +74,7 @@ async def set_chat_permissions(
r = await self.invoke(
raw.functions.messages.EditChatDefaultBannedRights(
peer=await self.resolve_peer(chat_id),
banned_rights=raw.types.ChatBannedRights(
until_date=0,
send_messages=not permissions.can_send_messages,
send_media=not permissions.can_send_media_messages,
send_stickers=not permissions.can_send_other_messages,
send_gifs=not permissions.can_send_other_messages,
send_games=not permissions.can_send_other_messages,
send_inline=not permissions.can_send_other_messages,
embed_links=not permissions.can_add_web_page_previews,
send_polls=not permissions.can_send_polls,
change_info=not permissions.can_change_info,
invite_users=not permissions.can_invite_users,
pin_messages=not permissions.can_pin_messages,
)
banned_rights=permissions.write(use_independent_chat_permissions)
)
)

Expand Down