Chat.restrict_member()#

Chat.restrict_member()#

Bound method unban_member of Chat.

Use as a shortcut for:

await client.restrict_chat_member(
    chat_id=chat_id,
    user_id=user_id,
    permissions=ChatPermissions()
)

Example

await chat.restrict_member(user_id, ChatPermissions())
Parameters:
  • user_id (int | str) – Unique identifier (int) or username (str) of the target user. For a contact that exists in your Telegram address book you can use his phone number (str).

  • permissions (ChatPermissions) – 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.

  • until_date (datetime, optional) – Date when the user will be unbanned. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Defaults to epoch (ban forever).

Returns:

Chat – On success, a chat object is returned.

Raises:

RPCError – In case of a Telegram RPC error.