U
    ;gK                     @   sJ   d dl m Z  d dlmZmZ d dlZd dlmZmZmZ G dd dZdS )    )datetime)UnionListN)typesutilsrawc                   @   sL   e Zd Zddeeef eeef eeee ef eeeed d	ddZ	dS )CopyMediaGroupNzpyrogram.Clientztypes.Message)	selfchat_idfrom_chat_id
message_idcaptionsdisable_notificationreply_to_message_idschedule_datereturnc                    s  |  ||I dH }g }	t|D ]\}
}|jr6|jj}n8|jrF|jj}n(|jrV|jj}n|jrf|jj}ntdtj	|d}|	
tjjf ||  d| jt|tr|
t|k r||
 r||
 n:t|tr|
dkr|n$|jr|jdkrt|tk	r|jndI dH  q| jtjjj| |I dH |	|p.d|t|dd	d
I dH }t| tjjjdd tdd |j D |j!|j"dI dH S )a	  Copy a media group by providing one of the message ids.

        .. 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).

            from_chat_id (``int`` | ``str``):
                Unique identifier (int) or username (str) of the source chat where the original media group was sent.
                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).

            message_id (``int``):
                Message identifier in the chat specified in *from_chat_id*.

            captions (``str`` | List of ``str`` , *optional*):
                New caption for media, 0-1024 characters after entities parsing for each media.
                If not specified, the original caption is kept.
                Pass "" (empty string) to remove the caption.

                If a ``string`` is passed, it becomes a caption only for the first media.
                If a list of ``string`` passed, each element becomes caption for each media element.
                You can pass ``None`` in list to keep the original caption (see examples below).

            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.

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

        Example:
            .. code-block:: python

                # Copy a media group
                await app.copy_media_group(to_chat, from_chat, 123)

                await app.copy_media_group(to_chat, from_chat, 123, captions="single caption")
                
                await app.copy_media_group(to_chat, from_chat, 123,
                    captions=["caption 1", None, ""])
        Nz'Message with this type can't be copied.)file_id)mediaZ	random_idr   None )Zpeermulti_mediaZsilentZreply_to_msg_idr   <   )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/copy_media_group.py
<listcomp>   s     z3CopyMediaGroup.copy_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   
z1CopyMediaGroup.copy_media_group.<locals>.<lambda>)messagesuserschats)#Zget_media_group	enumerateZphotor   ZaudioZdocumentZvideo
ValueErrorr   Zget_input_media_from_file_idappendr   r   ZInputSingleMediaZrnd_idparserparser   listlenstrcaptiontypeZinvokeZ	functionsr!   ZSendMultiMediaZresolve_peerZdatetime_to_timestampZparse_messagesZMessagesfilterZupdatesr"   r#   )r	   r
   r   r   r   r   r   r   Zmedia_groupr   ir   r   r   rr   r   r   copy_media_group   sf    >



&
zCopyMediaGroup.copy_media_group)NNNN)
__name__
__module____qualname__r   intr+   r   boolr   r1   r   r   r   r   r      s       

r   )	r   typingr   r   Zpyrogramr   r   r   r   r   r   r   r   <module>   s   