set_chat_photo()

Client.set_chat_photo()

Set a new profile photo for the chat.

You must be an administrator in the chat for this to work and must have the appropriate admin rights.

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

  • photo (str) – New chat photo. You can pass a Photo file_id or a file path to upload a new photo from your local machine.

Returns

bool – True on success.

Raises

ValueError – if a chat_id belongs to user.

Example

# Set chat photo using a local file
app.set_chat_photo(chat_id, "photo.jpg")

# Set chat photo using an exiting Photo file_id
app.set_chat_photo(chat_id, photo.file_id)