a
    y{Jh9                     @   s~   d dl mZmZmZmZmZmZmZ d dlm	Z	 d dl
mZmZmZmZmZmZmZmZ eeeeef ZdZG dd dZdS )    )AnyDictListLiteralOptionalUnionoverload)InputMediaType)UNSET_PARSE_MODE	InputFile
InputMediaInputMediaAudioInputMediaDocumentInputMediaPhotoInputMediaVideoMessageEntity
   c                   @   sL  e Zd Zd(eee  ee eee  ddddZeddddZ	ee dddd	Z
ededdddd
eej eeef ee ee eee  ee ee ee edd
ddZededddeej eeef ee ee eee  ee eddddZeddeddddddd	eej eeef eeeef  ee ee eee  ee ee ee ee ee eddddZeddedddeej eeef eeeef  ee ee eee  ee edd	ddZeddddZddeddddfeeef ee ee ee eee  ee ee ee edd
ddZdeddfeeef ee ee eee  ee eddddZddeddddddf	eeef ee ee ee eee  ee ee ee ee ee eddd d!Zddeddfeeef ee ee ee eee  ee edd"d#d$Zee d%d&d'ZdS ))MediaGroupBuilderN)mediacaptioncaption_entitiesreturnc                 C   s$   g | _ || _|| _| |pg  dS )aK  
        Helper class for building media groups.

        :param media: A list of media elements to add to the media group. (optional)
        :param caption: Caption for the media group. (optional)
        :param caption_entities: List of special entities in the caption,
            like usernames, URLs, etc. (optional)
        N)_mediar   r   _extend)selfr   r   r    r   K/var/www/shaz/venv/lib/python3.9/site-packages/aiogram/utils/media_group.py__init__   s    zMediaGroupBuilder.__init__)r   r   c                 C   s8   t |tstdt| jtkr(td| j| d S )Nz$Media must be instance of InputMediaz/Media group can't contain more than 10 elements)
isinstancer   
ValueErrorlenr   MAX_MEDIA_GROUP_SIZEappend)r   r   r   r   r   _add0   s
    
zMediaGroupBuilder._addc                 C   s   |D ]}|  | qd S N)r#   )r   r   mr   r   r   r   9   s    zMediaGroupBuilder._extend)r   
parse_moder   duration	performertitle)
typer   r   r&   r   r'   r(   r)   kwargsr   c          
      K   s   d S r$   r   )
r   r*   r   r   r&   r   r'   r(   r)   r+   r   r   r   add=   s    zMediaGroupBuilder.add)r   r&   r   has_spoiler)r*   r   r   r&   r   r-   r+   r   c                K   s   d S r$   r   )r   r*   r   r   r&   r   r-   r+   r   r   r   r,   M   s    )		thumbnailr   r&   r   widthheightr'   supports_streamingr-   )r*   r   r.   r   r&   r   r/   r0   r'   r1   r-   r+   r   c                K   s   d S r$   r   )r   r*   r   r.   r   r&   r   r/   r0   r'   r1   r-   r+   r   r   r   r,   [   s    )r.   r   r&   r   disable_content_type_detection)	r*   r   r.   r   r&   r   r2   r+   r   c          	      K   s   d S r$   r   )	r   r*   r   r.   r   r&   r   r2   r+   r   r   r   r,   n   s    )r+   r   c                 K   s   | dd}|tjkr(| jf i | nb|tjkrD| jf i | nF|tjkr`| jf i | n*|tjkr|| j	f i | nt
d|dS )z
        Add a media object to the media group.

        :param kwargs: Keyword arguments for the media object.
                The available keyword arguments depend on the media type.
        :return: None
        r*   NzUnknown media type: )popr	   AUDIO	add_audioPHOTO	add_photoVIDEO	add_videoDOCUMENTadd_documentr   )r   r+   type_r   r   r   r,   }   s    



)
r   r.   r   r&   r   r'   r(   r)   r+   r   c	           
      K   s*   |  tf ||||||||d|	 dS )u  
        Add an audio file to the media group.

        :param media: File to send. Pass a file_id to send a file that exists on the
            Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from
            the Internet, or pass 'attach://<file_attach_name>' to upload a new one using
            multipart/form-data under <file_attach_name> name.
             :ref:`More information on Sending Files » <sending-files>`
        :param thumbnail: *Optional*. Thumbnail of the file sent; can be ignored if
            thumbnail generation for the file is supported server-side. The thumbnail should
            be in JPEG format and less than 200 kB in size. A thumbnail's width and height
            should not exceed 320.
        :param caption: *Optional*. Caption of the audio to be sent, 0-1024 characters
            after entities parsing
        :param parse_mode: *Optional*. Mode for parsing entities in the audio caption.
            See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_
            for more details.
        :param caption_entities: *Optional*. List of special entities that appear in the caption,
            which can be specified instead of *parse_mode*
        :param duration: *Optional*. Duration of the audio in seconds
        :param performer: *Optional*. Performer of the audio
        :param title: *Optional*. Title of the audio
        :return: None
        )r   r.   r   r&   r   r'   r(   r)   N)r#   r   )
r   r   r.   r   r&   r   r'   r(   r)   r+   r   r   r   r5      s    $	zMediaGroupBuilder.add_audio)r   r   r&   r   r-   r+   r   c              
   K   s$   |  tf |||||d| dS )uF  
        Add a photo to the media group.

        :param media: File to send. Pass a file_id to send a file that exists on the
            Telegram servers (recommended), pass an HTTP URL for Telegram to get a file
            from the Internet, or pass 'attach://<file_attach_name>' to upload a new
            one using multipart/form-data under <file_attach_name> name.
             :ref:`More information on Sending Files » <sending-files>`
        :param caption: *Optional*. Caption of the photo to be sent, 0-1024 characters
            after entities parsing
        :param parse_mode: *Optional*. Mode for parsing entities in the photo caption.
            See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_
            for more details.
        :param caption_entities: *Optional*. List of special entities that appear in the caption,
            which can be specified instead of *parse_mode*
        :param has_spoiler: *Optional*. Pass :code:`True` if the photo needs to be covered
            with a spoiler animation
        :return: None
        )r   r   r&   r   r-   N)r#   r   )r   r   r   r&   r   r-   r+   r   r   r   r7      s    zMediaGroupBuilder.add_photo)r   r.   r   r&   r   r/   r0   r'   r1   r-   r+   r   c                 K   s.   |  tf |||||||||	|
d
| dS )u  
        Add a video to the media group.

        :param media: File to send. Pass a file_id to send a file that exists on the
            Telegram servers (recommended), pass an HTTP URL for Telegram to get a file
            from the Internet, or pass 'attach://<file_attach_name>' to upload a new one
            using multipart/form-data under <file_attach_name> name.
            :ref:`More information on Sending Files » <sending-files>`
        :param thumbnail: *Optional*. Thumbnail of the file sent; can be ignored if thumbnail
            generation for the file is supported server-side. The thumbnail should be in JPEG
            format and less than 200 kB in size. A thumbnail's width and height should
            not exceed 320. Ignored if the file is not uploaded using multipart/form-data.
            Thumbnails can't be reused and can be only uploaded as a new file, so you
            can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using
            multipart/form-data under <file_attach_name>.
            :ref:`More information on Sending Files » <sending-files>`
        :param caption: *Optional*. Caption of the video to be sent,
            0-1024 characters after entities parsing
        :param parse_mode: *Optional*. Mode for parsing entities in the video caption.
            See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_
            for more details.
        :param caption_entities: *Optional*. List of special entities that appear in the caption,
            which can be specified instead of *parse_mode*
        :param width: *Optional*. Video width
        :param height: *Optional*. Video height
        :param duration: *Optional*. Video duration in seconds
        :param supports_streaming: *Optional*. Pass :code:`True` if the uploaded video is
            suitable for streaming
        :param has_spoiler: *Optional*. Pass :code:`True` if the video needs to be covered
            with a spoiler animation
        :return: None
        )
r   r.   r   r&   r   r/   r0   r'   r1   r-   N)r#   r   )r   r   r.   r   r&   r   r/   r0   r'   r1   r-   r+   r   r   r   r9      s     .zMediaGroupBuilder.add_video)r   r.   r   r&   r   r2   r+   r   c                 K   s&   |  tf ||||||d| dS )uq  
        Add a document to the media group.

        :param media: File to send. Pass a file_id to send a file that exists on the
            Telegram servers (recommended), pass an HTTP URL for Telegram to get a file
            from the Internet, or pass 'attach://<file_attach_name>' to upload a new one using
            multipart/form-data under <file_attach_name> name.
            :ref:`More information on Sending Files » <sending-files>`
        :param thumbnail: *Optional*. Thumbnail of the file sent; can be ignored
            if thumbnail generation for the file is supported server-side.
            The thumbnail should be in JPEG format and less than 200 kB in size.
            A thumbnail's width and height should not exceed 320.
            Ignored if the file is not uploaded using multipart/form-data.
            Thumbnails can't be reused and can be only uploaded as a new file,
            so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded
            using multipart/form-data under <file_attach_name>.
            :ref:`More information on Sending Files » <sending-files>`
        :param caption: *Optional*. Caption of the document to be sent,
            0-1024 characters after entities parsing
        :param parse_mode: *Optional*. Mode for parsing entities in the document caption.
            See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_
            for more details.
        :param caption_entities: *Optional*. List of special entities that appear
            in the caption, which can be specified instead of *parse_mode*
        :param disable_content_type_detection: *Optional*. Disables automatic server-side
            content type detection for files uploaded using multipart/form-data.
            Always :code:`True`, if the document is sent as part of an album.
        :return: None

        )r   r.   r   r&   r   r2   N)r#   r   )r   r   r.   r   r&   r   r2   r+   r   r   r   r;   (  s    (zMediaGroupBuilder.add_document)r   c                    s@   d j i jdur& jd< dd<  fddt jD S )z
        Builds a list of media objects for a media group.

        Adds the caption to the first media object if it is present.

        :return: List of media objects.
        r   Nr   r&   c                    s2   g | ]*\}}|d kr* j dur*|jdn|qS )r   N)update)r   Z
model_copy).0indexr   r   Zupdate_first_mediar   r   
<listcomp>i  s   z+MediaGroupBuilder.build.<locals>.<listcomp>)r   r   	enumerater   )r   r   r@   r   build\  s    


zMediaGroupBuilder.build)NNN)__name__
__module____qualname__r   r   	MediaTypestrr   r   r#   r   r   r
   r   r	   r4   r   r   intr   r,   r6   boolr8   r:   r5   r7   r9   r;   rC   r   r   r   r   r      s>     

	









5

*

A

4r   N)typingr   r   r   r   r   r   r   Zaiogram.enumsr	   Zaiogram.typesr
   r   r   r   r   r   r   r   rG   r!   r   r   r   r   r   <module>   s   $(