
    G˝i9                     z    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z  ez  ez  ZdZ G d d      Zy)    )AnyLiteraloverload)InputMediaType)UNSET_PARSE_MODE	InputFile
InputMediaInputMediaAudioInputMediaDocumentInputMediaPhotoInputMediaVideoMessageEntity
   c                      e Zd Z	 	 	 d#dee   dz  dedz  dee   dz  ddfdZdeddfdZdee   ddfdZ	e
deddddd	d
eej                     deez  dedz  dedz  dee   dz  dedz  dedz  dedz  deddfd       Ze
dedddd
eej&                     deez  dedz  dedz  dee   dz  dedz  deddfd       Ze
ddeddddddd	d
eej*                     deez  deez  dz  dedz  dedz  dee   dz  dedz  dedz  dedz  dedz  dedz  deddfd       Ze
ddedddd
eej,                     deez  deez  dz  dedz  dedz  dee   dz  dedz  deddfd       ZdeddfdZddeddddfdeez  dedz  dedz  dedz  dee   dz  dedz  dedz  dedz  deddfdZdeddfdeez  dedz  dedz  dee   dz  dedz  deddfdZddeddddddf	deez  dedz  dedz  dedz  dee   dz  dedz  dedz  dedz  dedz  dedz  deddfd Zddeddfdeez  dedz  dedz  dedz  dee   dz  dedz  deddfd!Zdee   fd"Zy)$MediaGroupBuilderNmediacaptioncaption_entitiesreturnc                 X    g | _         || _        || _        | j                  |xs g        y)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   s       R/home/leshdev/mybot/venv/lib/python3.12/site-packages/aiogram/utils/media_group.py__init__zMediaGroupBuilder.__init__   s*     (* 0U[b!    c                     t        |t              sd}t        |      t        | j                        t
        k\  rd}t        |      | j                  j                  |       y )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   msgs      r   _addzMediaGroupBuilder._add+   sN    %,8CS/!t{{33CCS/!5!r   c                 4    |D ]  }| j                  |        y N)r$   )r   r   ms      r   r   zMediaGroupBuilder._extend6   s     	AIIaL	r   )r   
parse_moder   duration	performertitletyper(   r)   r*   r+   kwargsc                     y r&    )
r   r,   r   r   r(   r   r)   r*   r+   r-   s
             r   addzMediaGroupBuilder.add:   s     	r   )r   r(   r   has_spoilerr1   c                     y r&   r/   )r   r,   r   r   r(   r   r1   r-   s           r   r0   zMediaGroupBuilder.addJ   s     	r   )		thumbnailr   r(   r   widthheightr)   supports_streamingr1   r3   r4   r5   r6   c                     y r&   r/   )r   r,   r   r3   r   r(   r   r4   r5   r)   r6   r1   r-   s                r   r0   zMediaGroupBuilder.addX   s    " 	r   )r3   r   r(   r   disable_content_type_detectionr8   c                     y r&   r/   )	r   r,   r   r3   r   r(   r   r8   r-   s	            r   r0   zMediaGroupBuilder.addk   s     	r   c                 v   |j                  dd      }|t        j                  k(  r | j                  di | y|t        j                  k(  r | j
                  di | y|t        j                  k(  r | j                  di | y|t        j                  k(  r | j                  di | y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#   s       r   r0   zMediaGroupBuilder.addz   s     

64(N(((DNN$V$n***DNN$V$n***DNN$V$n---D''(	2CS/!r   c	                 J    | j                  t        d||||||||d|	       y)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   r3   r   r(   r   r)   r*   r+   Nr/   )r$   r
   )
r   r   r3   r   r(   r   r)   r*   r+   r-   s
             r   r=   zMediaGroupBuilder.add_audio   s@    H 			 
#%!1!#
 
	
r   c                 D    | j                  t        d|||||d|       y)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   r1   Nr/   )r$   r   )r   r   r   r(   r   r1   r-   s          r   r?   zMediaGroupBuilder.add_photo   s6    8 			 %!1' 		
r   c                 N    | j                  t        d|||||||||	|
d
|       y)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   r3   r   r(   r   r4   r5   r)   r6   r1   Nr/   )r$   r   )r   r   r3   r   r(   r   r4   r5   r)   r6   r1   r-   s               r   rA   zMediaGroupBuilder.add_video   sF    \ 			 #%!1!#5' 	
r   c                 F    | j                  t        d||||||d|       y)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   r3   r   r(   r   r8   Nr/   )r$   r   )r   r   r3   r   r(   r   r8   r-   s           r   rC   zMediaGroupBuilder.add_document&  s:    P 			 #%!1/M 
	
r   c                     d| j                   i}| j                  | j                  |d<   d|d<   t        | j                        D cg c]*  \  }}|dk(  r| j                   |j	                  |      n|, c}}S c c}}w )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(   r   )update)r   r   	enumerater   
model_copy)r   update_first_mediaindexr   s       r   buildzMediaGroupBuilder.buildZ  s     /8-F  ,595J5J12/3|, !*$++ 6
 u A:$,,":   (: ;
 	
 
s   /A:)NNN)__name__
__module____qualname__list	MediaTypestrr   r   r$   r   r   r   r   r   r<   r   intr   r0   r>   boolr@   rB   r=   r?   rA   rC   rO   r/   r   r   r   r      s   
 )-"7;	"I%" t" }-4	"
 
"(	") 	" 	"T)_    #!17;# $  n**+ Y	
 t $J }-4 * : Tz  
   #!17;#' n**+ Y	
 t $J }-4 D[  
   -1"!17; !#*.#' n**+ Y	
 s?T) t $J }-4 Tz d
 * !4K D[  
 $  -1"!17;6: n--. Y	
 s?T) t $J }-4 )-t  
 "C "D "0 '+"!17;# $ 0
Y0
 t#0
 t	0

 $J0
 }-40
 *0
 :0
 Tz0
 0
 
0
j #!17;#'%
Y%
 t%
 $J	%

 }-4%
 D[%
 %
 
%
T '+"!17; !#*.#'<
Y<
 t#<
 t	<

 $J<
 }-4<
 Tz<
 d
<
 *<
 !4K<
 D[<
 <
 
<
B '+"!17;6:2
Y2
 t#2
 t	2

 $J2
 }-42
 )-t2
 2
 
2
h
tI 
r   r   N)typingr   r   r   aiogram.enumsr   aiogram.typesr   r   r	   r
   r   r   r   r   rT   r!   r   r/   r   r   <module>r[      sF    ) ) (	 	 	 o-?BTT	 Z
 Z
r   