U
    ;g                     @   sV   d dl Z d dlmZmZ d dlZd dlmZ d dlmZ d dlmZ G dd dZ	dS )    N)UnionBinaryIO)raw)utils)FileTypec                   @   sF   e Zd Zdddddeeef eeef eeef eedddZ	dS )SetChatPhotoN)photovideovideo_start_tszpyrogram.Client)selfchat_idr   r	   r
   returnc                   s  |  |I dH }t|trrtj|rRtjj| 	|I dH | 	|I dH |d}qt
|tj}tjj|jd}n*tjj| 	|I dH | 	|I dH |d}t|tjjr| tjjj|j|dI dH  n>t|tjjr| tjjj||dI dH  ntd| ddS )	a  Set a new chat photo or video (H.264/MPEG-4 AVC video, max 5 seconds).

        The ``photo`` and ``video`` arguments are mutually exclusive.
        Pass either one as named argument (see examples below).

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

        .. include:: /_includes/usable-by/users-bots.rst

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

            photo (``str`` | ``BinaryIO``, *optional*):
                New chat photo. You can pass a :obj:`~pyrogram.types.Photo` file_id, a file path to upload a new photo
                from your local machine or a binary file-like object with its attribute
                ".name" set for in-memory uploads.

            video (``str`` | ``BinaryIO``, *optional*):
                New chat video. You can pass a :obj:`~pyrogram.types.Video` file_id, a file path to upload a new video
                from your local machine or a binary file-like object with its attribute
                ".name" set for in-memory uploads.

            video_start_ts (``float``, *optional*):
                The timestamp in seconds of the video frame to use as photo profile preview.

        Returns:
            ``bool``: True on success.

        Raises:
            ValueError: if a chat_id belongs to user.

        Example:
            .. code-block:: python

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

                # Set chat photo using an existing Photo file_id
                await app.set_chat_photo(chat_id, photo=photo.file_id)


                # Set chat video using a local file
                await app.set_chat_photo(chat_id, video="video.mp4")

                # Set chat photo using an existing Video file_id
                await app.set_chat_photo(chat_id, video=video.file_id)
        N)filer	   r
   )id)r   r   )Zchannelr   zThe chat_id "z" belongs to a userT)Zresolve_peer
isinstancestrospathisfiler   typesZInputChatUploadedPhotoZ	save_filer   Zget_input_media_from_file_idr   ZPHOTOZInputChatPhotor   ZInputPeerChatZinvokeZ	functionsmessagesZEditChatPhotor   ZInputPeerChannelZchannelsZ	EditPhoto
ValueError)r   r   r   r	   r
   Zpeer r   e/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pyrogram/methods/chats/set_chat_photo.pyset_chat_photo   s>    8
zSetChatPhoto.set_chat_photo)
__name__
__module____qualname__r   intr   r   floatboolr   r   r   r   r   r      s   


r   )
r   typingr   r   Zpyrogramr   r   Zpyrogram.file_idr   r   r   r   r   r   <module>   s   