Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit e708f8d

Browse files
Add missing parameters to Chat.set_photo (#980)
1 parent 0bc3400 commit e708f8d

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

pyrogram/methods/chats/set_chat_photo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ async def set_chat_photo(
7070
# Set chat photo using a local file
7171
await app.set_chat_photo(chat_id, photo="photo.jpg")
7272
73-
# Set chat photo using an exiting Photo file_id
73+
# Set chat photo using an existing Photo file_id
7474
await app.set_chat_photo(chat_id, photo=photo.file_id)
7575
7676
7777
# Set chat video using a local file
7878
await app.set_chat_photo(chat_id, video="video.mp4")
7979
80-
# Set chat photo using an exiting Video file_id
80+
# Set chat photo using an existing Video file_id
8181
await app.set_chat_photo(chat_id, video=video.file_id)
8282
"""
8383
peer = await self.resolve_peer(chat_id)

pyrogram/types/user_and_chats/chat.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

1919
from datetime import datetime
20-
from typing import Union, List, Optional, AsyncGenerator
20+
from typing import Union, List, Optional, AsyncGenerator, BinaryIO
2121

2222
import pyrogram
2323
from pyrogram import raw, enums
@@ -477,7 +477,13 @@ async def set_description(self, description: str) -> bool:
477477
description=description
478478
)
479479

480-
async def set_photo(self, photo: str) -> bool:
480+
async def set_photo(
481+
self,
482+
*,
483+
photo: Union[str, BinaryIO] = None,
484+
video: Union[str, BinaryIO] = None,
485+
video_start_ts: float = None,
486+
) -> bool:
481487
"""Bound method *set_photo* of :obj:`~pyrogram.types.Chat`.
482488
483489
Use as a shortcut for:
@@ -492,11 +498,32 @@ async def set_photo(self, photo: str) -> bool:
492498
Example:
493499
.. code-block:: python
494500
495-
await chat.set_photo("photo.png")
501+
# Set chat photo using a local file
502+
await chat.set_photo(photo="photo.jpg")
503+
504+
# Set chat photo using an existing Photo file_id
505+
await chat.set_photo(photo=photo.file_id)
506+
507+
508+
# Set chat video using a local file
509+
await chat.set_photo(video="video.mp4")
510+
511+
# Set chat photo using an existing Video file_id
512+
await chat.set_photo(video=video.file_id)
496513
497514
Parameters:
498-
photo (``str``):
499-
New chat photo. You can pass a :obj:`~pyrogram.types.Photo` id or a file path to upload a new photo.
515+
photo (``str`` | ``BinaryIO``, *optional*):
516+
New chat photo. You can pass a :obj:`~pyrogram.types.Photo` file_id, a file path to upload a new photo
517+
from your local machine or a binary file-like object with its attribute
518+
".name" set for in-memory uploads.
519+
520+
video (``str`` | ``BinaryIO``, *optional*):
521+
New chat video. You can pass a :obj:`~pyrogram.types.Video` file_id, a file path to upload a new video
522+
from your local machine or a binary file-like object with its attribute
523+
".name" set for in-memory uploads.
524+
525+
video_start_ts (``float``, *optional*):
526+
The timestamp in seconds of the video frame to use as photo profile preview.
500527
501528
Returns:
502529
``bool``: True on success.
@@ -508,7 +535,9 @@ async def set_photo(self, photo: str) -> bool:
508535

509536
return await self._client.set_chat_photo(
510537
chat_id=self.id,
511-
photo=photo
538+
photo=photo,
539+
video=video,
540+
video_start_ts=video_start_ts
512541
)
513542

514543
async def ban_member(

0 commit comments

Comments
 (0)