o
    5˜Žj9  ã                   @   sn   d dl 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B eB eB ZdZG dd„ dƒZdS )é    )ÚAnyÚLiteralÚoverload)ÚInputMediaType)ÚUNSET_PARSE_MODEÚ	InputFileÚ
InputMediaÚInputMediaAudioÚInputMediaDocumentÚInputMediaPhotoÚInputMediaVideoÚMessageEntityé
   c                   @   sÀ  e Zd Z			d,dee dB dedB dee dB ddfdd„Zdeddfdd	„Zdee ddfd
d„Z	e
dedddddœdeej deeB dedB dedB dee dB dedB dedB dedB deddfdd„ƒZe
dedddœdeej deeB dedB dedB dee dB dedB deddfdd„ƒZe
ddedddddddœ	deej deeB deeB dB dedB dedB dee dB dedB dedB dedB dedB dedB deddfdd„ƒZe
ddedddœdeej deeB deeB dB dedB dedB dee dB dedB deddfd d„ƒZdeddfd!d„ZddeddddfdeeB dedB dedB dedB dee dB dedB dedB dedB deddfd"d#„ZdeddfdeeB dedB dedB dee dB dedB deddfd$d%„Zddeddddddf	deeB dedB dedB dedB dee dB dedB dedB dedB dedB dedB deddfd&d'„ZddeddfdeeB dedB dedB dedB dee dB dedB deddfd(d)„Zdee f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   úV/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/aiogram/utils/media_group.pyÚ__init__   s   zMediaGroupBuilder.__init__c                 C   s@   t |tƒsd}t|ƒ‚t| jƒtkrd}t|ƒ‚| 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   Úmsgr   r   r   Ú_add+   s   
zMediaGroupBuilder._addc                 C   s   |D ]}|   |¡ qd S ©N)r    )r   r   Úmr   r   r   r   6   s   ÿzMediaGroupBuilder._extend)r   Ú
parse_moder   ÚdurationÚ	performerÚtitleÚtyper#   r$   r%   r&   Úkwargsc          
      K   ó   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_spoilerr+   c                K   r)   r!   r   )r   r'   r   r   r#   r   r+   r(   r   r   r   r*   J   s   )	Ú	thumbnailr   r#   r   ÚwidthÚheightr$   Úsupports_streamingr+   r,   r-   r.   r/   c                K   r)   r!   r   )r   r'   r   r,   r   r#   r   r-   r.   r$   r/   r+   r(   r   r   r   r*   X   s   )r,   r   r#   r   Údisable_content_type_detectionr0   c          	      K   r)   r!   r   )	r   r'   r   r,   r   r#   r   r0   r(   r   r   r   r*   k   s   c                 K   s–   |  dd¡}|tjkr| jdi |¤Ž dS |tjkr$| jdi |¤Ž dS |tjkr3| jdi |¤Ž dS |tjkrB| j	di |¤Ž dS d|›�}t
|ƒ‚)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: r   )Úpopr   ÚAUDIOÚ	add_audioÚPHOTOÚ	add_photoÚVIDEOÚ	add_videoÚDOCUMENTÚadd_documentr   )r   r(   Útype_r   r   r   r   r*   z   s   




c	           
      K   s*   |   td||||||||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&   Nr   )r    r	   )
r   r   r,   r   r#   r   r$   r%   r&   r(   r   r   r   r3   �   s   $ø	÷ÿzMediaGroupBuilder.add_audioc              
   K   s$   |   td|||||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+   Nr   )r    r   )r   r   r   r#   r   r+   r(   r   r   r   r5   Á   s   ûúÿzMediaGroupBuilder.add_photoc                 K   s.   |   td|||||||||	|
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-   r.   r$   r/   r+   Nr   )r    r   )r   r   r,   r   r#   r   r-   r.   r$   r/   r+   r(   r   r   r   r7   è   s    .öõÿzMediaGroupBuilder.add_videoc                 K   s&   |   td||||||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   r0   Nr   )r    r
   )r   r   r,   r   r#   r   r0   r(   r   r   r   r9   &  s   (úùÿzMediaGroupBuilder.add_documentc                    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   Ú
model_copy)Ú.0Úindexr   ©r   Úupdate_first_mediar   r   Ú
<listcomp>g  s    ýÿüz+MediaGroupBuilder.build.<locals>.<listcomp>)r   r   Ú	enumerater   )r   r   r?   r   ÚbuildZ  s   


úzMediaGroupBuilder.build)NNN)Ú__name__Ú
__module__Ú__qualname__ÚlistÚ	MediaTypeÚstrr   r   r    r   r   r   r   r   r2   r   Úintr   r*   r4   Úboolr6   r8   r3   r5   r7   r9   rC   r   r   r   r   r      sÐ   ü
þý
ü
ûöýüûú
ùø	÷
öõôøýüûú
ùø	÷
öóýü
ûúù
ø	÷
öõôóòñ÷ýü
ûúù
ø	÷
öõ÷þýüû
úùø	÷
ö
õ5úþýü
ûúù
ø*õþýüû
úùø	÷
öõô
óAùþýüû
úùø	
÷4r   N)Útypingr   r   r   Úaiogram.enumsr   Úaiogram.typesr   r   r   r	   r
   r   r   r   rH   r   r   r   r   r   r   Ú<module>   s    (