set_chat_permissions()

Client.set_chat_permissions()

Set default chat permissions for all members.

You must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights.

Parameters
  • chat_id (int | str) – Unique identifier (int) or username (str) of the target chat.

  • permissions (ChatPermissions) – New default chat permissions.

Returns

Chat – On success, a chat object is returned.

Example

from pyrogram import ChatPermissions

# Completely restrict chat
app.set_chat_permissions(chat_id, ChatPermissions())

# Chat members can only send text messages, media, stickers and GIFs
app.set_chat_permissions(
    chat_id,
    ChatPermissions(
        can_send_messages=True,
        can_send_media_messages=True,
        can_send_other_messages=True
    )
)