U
    ;gM                     @   s   d dl Z d dlZd dlZd dlm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
 d dlmZ e eZG dd	 d	ZdS )
    N)datetime)UnionList)raw)types)utils)FileTypec                
   @   s>   e Zd Zddeeef eed  eeeeed dddZ	dS )	SendMediaGroupNzpyrogram.Client)ztypes.InputMediaPhotoztypes.InputMediaVideoztypes.InputMediaAudioztypes.InputMediaDocumentztypes.Message)selfchat_idmediadisable_notificationreply_to_message_idschedule_dateprotect_contentreturnc           
         s  g }|D ]l}t |tjrt |jtr6tj|jr| t	j
jj| |I dH t	jj| |jI dH |jddI dH }t	jjt	jj|jj|jj|jjd|jd}ntd|jr$| t	j
jj| |I dH t	jj|j|jddI dH }t	jjt	jj|jj|jj|jjd|jd}nt|jtj}nr| t	j
jj| |I dH t	jj| |jI dH |jddI dH }t	jjt	jj|jj|jj|jjd|jd}nt |tjrt |jtr.tj|jr| t	j
jj| |I dH t	jj| |jI dH | |jI dH |j|  |jp,dt	jj!|j"p<d|j#|j$|j%d	t	jj&tj'|jd
gddI dH }t	jj(t	jj)|j*j|j*j|j*jd|jd}ntd|jr| t	j
jj| |I dH t	jj+|j|jddI dH }t	jj(t	jj)|j*j|j*j|j*jd|jd}nt|jtj,}n| t	j
jj| |I dH t	jj| |jI dH | |jI dH |j|  t-|jddpdt	jj!|j"pd|j#|j$|j%d	t	jj&t-|jddd
gddI dH }t	jj(t	jj)|j*j|j*j|j*jd|jd}n<t |tj.r0t |jtrltj|jr| t	j
jj| |I dH t	jj|  |jp`d| |jI dH | |jI dH t	jj/|j#|j0|j1dt	jj&tj'|jd
gddI dH }t	jj(t	jj)|j*j|j*j|j*jdd}ntd|jrZ| t	j
jj| |I dH t	jj+|jddI dH }t	jj(t	jj)|j*j|j*j|j*jdd}nt|jtj2}n| t	j
jj| |I dH t	jj|  t-|jddpd| |jI dH | |jI dH t	jj/|j#|j0|j1dt	jj&t-|jddd
gddI dH }t	jj(t	jj)|j*j|j*j|j*jdd}nt |tj(r.t |jtrtj|jr | t	j
jj| |I dH t	jj|  |jpd| |jI dH | |jI dH t	jj&tj'|jd
gddI dH }t	jj(t	jj)|j*j|j*j|j*jdd}ntd|jrp| t	j
jj| |I dH t	jj+|jddI dH }t	jj(t	jj)|j*j|j*j|j*jdd}nt|jtj3}n| t	j
jj| |I dH t	jj|  t-|jddpd| |jI dH | |jI dH t	jj&t-|jddd
gddI dH }t	jj(t	jj)|j*j|j*j|j*jdd}nt4|j5j6 d|7t	jj8f || 9 d| j:;|j<|j=I dH  q| jt	j
jj>| |I dH ||pd|t?||dddI dH }	t@| t	jjjAdd tBdd |	jCD |	jD|	jEdI dH S ) us  Send a group of photos or videos as an album.

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

        Parameters:
            chat_id (``int`` | ``str``):
                Unique identifier (int) or username (str) of the target chat.
                For your personal cloud (Saved Messages) you can simply use "me" or "self".
                For a contact that exists in your Telegram address book you can use his phone number (str).

            media (List of :obj:`~pyrogram.types.InputMediaPhoto`, :obj:`~pyrogram.types.InputMediaVideo`, :obj:`~pyrogram.types.InputMediaAudio` and :obj:`~pyrogram.types.InputMediaDocument`):
                A list describing photos and videos to be sent, must include 2–10 items.

            disable_notification (``bool``, *optional*):
                Sends the message silently.
                Users will receive a notification with no sound.

            reply_to_message_id (``int``, *optional*):
                If the message is a reply, ID of the original message.

            schedule_date (:py:obj:`~datetime.datetime`, *optional*):
                Date when the message will be automatically sent.

            protect_content (``bool``, *optional*):
                Protects the contents of the sent message from forwarding and saving.

        Returns:
            List of :obj:`~pyrogram.types.Message`: On success, a list of the sent messages is returned.

        Example:
            .. code-block:: python

                from pyrogram.types import InputMediaPhoto, InputMediaVideo

                await app.send_media_group(
                    "me",
                    [
                        InputMediaPhoto("photo1.jpg"),
                        InputMediaPhoto("photo2.jpg", caption="photo caption"),
                        InputMediaVideo("video.mp4", caption="video caption")
                    ]
                )
        N)filespoiler)peerr   )idaccess_hashfile_reference)r   r   z
^https?://)urlr   z	video/mp4)supports_streamingdurationwh)	file_name)r   thumbr   	mime_type
attributesnamez	video.mp4z
audio/mpeg)r   	performertitle)r   r   r   r    )r   )r   z	audio.mp3zapplication/zipzfile.zipz- is not a supported type for send_media_group)r   Z	random_id)r   multi_mediaZsilentZreply_to_msg_idr   Z
noforwards<   )Zsleep_thresholdc                 S   s   g | ]
}|j qS  )message).0mr&   r&   j/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pyrogram/methods/messages/send_media_group.py
<listcomp>  s     z3SendMediaGroup.send_media_group.<locals>.<listcomp>c                 S   s   t | tjjtjjtjjfS )N)
isinstancer   r   ZUpdateNewMessageZUpdateNewChannelMessageZUpdateNewScheduledMessage)ur&   r&   r*   <lambda>  s   
z1SendMediaGroup.send_media_group.<locals>.<lambda>)messagesuserschats)Fr,   r   ZInputMediaPhotor   strospathisfileZinvoker   Z	functionsr/   ZUploadMediaZresolve_peerZInputMediaUploadedPhotoZ	save_fileZhas_spoilerZ
InputPhotoZphotor   r   r   rematchZInputMediaPhotoExternalr   Zget_input_media_from_file_idr   ZPHOTOZInputMediaVideoZInputMediaUploadedDocumentr   Zguess_mime_typeZDocumentAttributeVideor   r   widthheightZDocumentAttributeFilenamebasenameZInputMediaDocumentZInputDocumentZdocumentZInputMediaDocumentExternalZVIDEOgetattrZInputMediaAudioZDocumentAttributeAudior"   r#   ZAUDIOZDOCUMENT
ValueError	__class____name__appendZInputSingleMediaZrnd_idparserparsecaptionZ
parse_modeZSendMultiMediaZdatetime_to_timestampZparse_messagesZMessagesfilterZupdatesr0   r1   )
r
   r   r   r   r   r   r   r$   irr&   r&   r*   send_media_group$   sL   9




	






	




	



	
zSendMediaGroup.send_media_group)NNNN)
r>   
__module____qualname__r   intr2   r   boolr   rF   r&   r&   r&   r*   r	   "   s        
r	   )loggingr3   r6   r   typingr   r   Zpyrogramr   r   r   Zpyrogram.file_idr   	getLoggerr>   logr	   r&   r&   r&   r*   <module>   s   
