restrict_chat_member()¶
-
Client.restrict_chat_member()¶ Restrict a user in a supergroup.
You must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all permissions to lift restrictions from a user.
- Parameters
chat_id (
int|str) – Unique identifier (int) or username (str) of the target chat.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.until_date (
int, optional) – Date when the user will be unbanned, unix time. 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 0 (ban forever).
- Returns
Chat– On success, a chat object is returned.
Example
from time import time from pyrogram.types import ChatPermissions # Completely restrict chat member (mute) forever app.restrict_chat_member(chat_id, user_id, ChatPermissions()) # Chat member muted for 24h app.restrict_chat_member(chat_id, user_id, ChatPermissions(), int(time() + 86400)) # Chat member can only send text messages app.restrict_chat_member(chat_id, user_id, ChatPermissions(can_send_messages=True))