o
    LDi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   e/var/www/www-root/data/www/77.83.87.30/venv/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    (