
    N[iK                     P    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      Zy)    )datetime)UnionListN)typesutilsrawc                   l    e Zd Z	 	 	 	 ddddeeef   deeef   dedeee   ef   ded	ed
eded   fdZ	y)CopyMediaGroupNselfzpyrogram.Clientchat_idfrom_chat_id
message_idcaptionsdisable_notificationreply_to_message_idschedule_datereturnztypes.Messagec                   K   | j                  ||       d{   }g }	t        |      D ]  \  }
}|j                  r|j                  j                  }nt|j                  r|j                  j                  }nQ|j
                  r|j
                  j                  }n.|j                  r|j                  j                  }nt        d      t        j                  |      }|	j                  t        j                  j                  d|| j                         d| j                  j!                  t#        |t$              r|
t'        |      k  r
||
   r||
   nPt#        |t(              r|
dk(  r|n9|j*                  r,|j*                  dk7  rt-        |      t(        ur|j*                  nd       d{           | j/                  t        j0                  j2                  j5                  | j7                  |       d{   |	|xs d|t        j8                  |            d	
       d{   }t        j:                  | t        j                  j2                  j=                  t?        d |j@                        D cg c]  }|jB                   c}|jD                  |jF                               d{   S 7 7 7 7 c c}w 7 w)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)media	random_idr   None )peermulti_mediasilentreply_to_msg_idr   <   )sleep_thresholdc                     t        | t        j                  j                  t        j                  j                  t        j                  j
                  f      S )N)
isinstancer   r   UpdateNewMessageUpdateNewChannelMessageUpdateNewScheduledMessage)us    ]/var/www/files/kim/lib/python3.12/site-packages/pyrogram/methods/messages/copy_media_group.py<lambda>z1CopyMediaGroup.copy_media_group.<locals>.<lambda>   s:    jSYY-G-G-0YY-N-N-0YY-P-P-R S     )messagesuserschats )$get_media_group	enumeratephotor   audiodocumentvideo
ValueErrorr   get_input_media_from_file_idappendr   r   InputSingleMediarnd_idparserparser!   listlenstrcaptiontypeinvoke	functionsr)   SendMultiMediaresolve_peerdatetime_to_timestampparse_messagesMessagesfilterupdatesmessager*   r+   )r   r   r   r   r   r   r   r   media_groupr   irH   r   r   rms                   r&   copy_media_groupzCopyMediaGroup.copy_media_group   si    | !00zJJ#K0 	JAw}}!--//!--//!!!**22!--// !JKK66wGE		** "kkm !KK--'1(D'Aa#h-FW\def\g$.x$=!q&+2??wRX?Xae$b&),b-24	6 6
	2 ++MM""11,,W55'+3t 3#99-H 2    	
 	
 ))II''-3S II	. !))  gggg ( 	
 
 	
O K(6 6	

sf   KJ6FK*J9+AK:J<;-K(J>)AK9K %K1K2K9K<K>K K)NNNN)
__name__
__module____qualname__r   intr<   r   boolr   rM   r,   r(   r&   r
   r
      s     +/%)#'"&q
q
sCxq
 CHoq
 	q

 S	3'q
 #q
 !q
  q
 
o	q
r(   r
   )	r   typingr   r   pyrogramr   r   r   r
   r,   r(   r&   <module>rU      s"   &    & &r
 r
r(   