set_chat_permissions()

async 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.

Usable by Users Bots
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 hydrogram.types import ChatPermissions

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

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