o
    -˜Žjœ6  ã                   @   sn   d dl Z d dlZd dlZd dl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
 G dd„ dƒZdS )	é    N)ÚUnion)Úraw)Útypes)Úutils)ÚFileTypec                   @   sL   e Zd Z				ddddeeef deddd	d
dedededdfdd„ZdS )ÚEditMessageMediaNFÚselfzpyrogram.ClientÚchat_idÚ
message_idÚmediaztypes.InputMediaÚreply_markupztypes.InlineKeyboardMarkupÚ	file_nameÚinvert_mediaÚbusiness_connection_idÚreturnztypes.Messagec                 Ã   s�  �|j }|j}	|j}
d\}}|dur!t | ||
|	¡I dH  ¡ \}}t|tjƒr�t|j	t
jƒs5tj |j	¡rp|  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�}�nmt d|j	¡rƒtjj|j	|jd�}�nZt  |j	t!j"¡}�nPt|tj#ƒ�r(t|j	t
jƒs£tj |j	¡�r
|  tjjj|  |¡I dH tjj$|  %|j	¡pºd	|  |j&¡I dH |j|  |j	¡I dH tjj'|j(pÓd|j)|j*|j+d
�tjj,|pætj -|j	¡d�gd�d�¡I dH }tjj.tjj/|j0j|j0j|j0jd�|jd�}�nÓt d|j	¡�rtjj1|j	|jd�}�n¿t  |j	t!j2¡}�nµt|tj3ƒ�r¼t|j	t
jƒ�s?tj |j	¡�r |  tjjj|  |¡I dH tjj$|  %|j	¡�pWd|  |j&¡I dH |  |j	¡I dH tjj4|j)|j5|j6d�tjj,|�p~tj -|j	¡d�gd�d�¡I dH }tjj.tjj/|j0j|j0j|j0jd�d�}�n=t d|j	¡�r²tjj1|j	d�}�n+t  |j	t!j7¡}�n!t|tj8ƒ�rXt|j	t
jƒ�sÓtj |j	¡�r<|  tjjj|  |¡I dH tjj$|  %|j	¡�pëd	|  |j&¡I dH |j|  |j	¡I dH tjj'd|j)|j*|j+d
�tjj,|�ptj -|j	¡d�tj 9¡ gd�d�¡I dH }tjj.tjj/|j0j|j0j|j0jd�|jd�}n¡t d|j	¡�rOtjj1|j	|jd�}nŽt  |j	t!j:¡}n…t|tj.ƒ�rÝt|j	t
jƒ�sot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,|�p£tj -|j	¡d�gd�d�¡I dH }tjj.tjj/|j0j|j0j|j0jd�d�}nt d|j	¡�rÕtjj1|j	d�}nt  |j	t!j;¡}tjjj<|  |¡I dH |||�rõ| =| ¡I dH nd|||d�}|du�r|  tjj>||d�¡I dH }n|  |¡I dH }|j?D ]*}t|tjj@tjjAfƒ�rDtjB C| |jDdd„ |jED ƒdd„ |jFD ƒ¡I dH   S �qdS )a‡	  Edit animation, audio, document, photo or video messages, or replace text with animation, audio, document, photo or video messages.

        If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, the
        message type can be changed arbitrarily.

        .. 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).
                You can also use chat public link in form of *t.me/<username>* (str).

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

            media (:obj:`~pyrogram.types.InputMedia`):
                One of the InputMedia objects describing an animation, audio, document, photo or video.

            reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*):
                An InlineKeyboardMarkup object.

            file_name (``str``, *optional*):
                File name of the media to be sent. Not applicable to photos.
                Defaults to file's path basename.

            invert_media (``bool``, *optional*):
                Inverts the position of the media and caption.

            business_connection_id (``str``, *optional*):
                Unique identifier of the business connection.
                for business bots only.

        Returns:
            :obj:`~pyrogram.types.Message`: On success, the edited message is returned.

        Example:
            .. code-block:: python

                from pyrogram.types import InputMediaPhoto, InputMediaVideo, InputMediaAudio

                # Replace the current media with a local photo
                await app.edit_message_media(chat_id, message_id,
                    InputMediaPhoto("new_photo.jpg"))

                # Replace the current media with a local video
                await app.edit_message_media(chat_id, message_id,
                    InputMediaVideo("new_video.mp4"))

                # Replace the current media with a local audio
                await app.edit_message_media(chat_id, message_id,
                    InputMediaAudio("new_audio.mp3"))
        )NNN)ÚfileÚspoiler)Úpeerr   )ÚidÚaccess_hashÚfile_reference)r   r   z
^https?://)Úurlr   z	video/mp4)Úsupports_streamingÚdurationÚwÚh)r   )Ú	mime_typeÚthumbr   r   Ú
attributesz
audio/mpeg)r   Ú	performerÚtitle)r   r   r   r   ©r   )r   Tzapplication/zip)r   r   r   r   ÚmessageÚentitiesr   )Úconnection_idÚqueryc                 S   ó   i | ]}|j |“qS © r!   ©Ú.0Úir'   r'   úi/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pyrogram/methods/messages/edit_message_media.pyÚ
<dictcomp>1  ó    z7EditMessageMedia.edit_message_media.<locals>.<dictcomp>c                 S   r&   r'   r!   r(   r'   r'   r+   r,   2  r-   )GÚcaptionÚcaption_entitiesÚ
parse_moder   Úparse_text_entitiesÚvaluesÚ
isinstancer   ÚInputMediaPhotor   ÚioÚBytesIOÚosÚpathÚisfileÚinvoker   Ú	functionsÚmessagesÚUploadMediaÚresolve_peerÚInputMediaUploadedPhotoÚ	save_fileÚhas_spoilerÚ
InputPhotoÚphotor   r   r   ÚreÚmatchÚInputMediaPhotoExternalÚget_input_media_from_file_idr   ÚPHOTOÚInputMediaVideoÚInputMediaUploadedDocumentÚguess_mime_typer   ÚDocumentAttributeVideor   r   ÚwidthÚheightÚDocumentAttributeFilenameÚbasenameÚInputMediaDocumentÚInputDocumentÚdocumentÚInputMediaDocumentExternalÚVIDEOÚInputMediaAudioÚDocumentAttributeAudior   r    ÚAUDIOÚInputMediaAnimationÚDocumentAttributeAnimatedÚ	ANIMATIONÚDOCUMENTÚEditMessageÚwriteÚInvokeWithBusinessConnectionÚupdatesÚUpdateEditMessageÚUpdateEditChannelMessageÚMessageÚ_parser"   ÚusersÚchats)r   r	   r
   r   r   r   r   r   r.   r/   r0   r"   r#   Úuploaded_mediaÚrpcÚrr*   r'   r'   r+   Úedit_message_media!   s„  €@þþ
ÿ
ý
ú
þüÿùûþ
ÿý
ú
þ ýÿúüþ
ÿý
ÿ
ÿ üÿöûþ
ÿýúþ ÿÿüþ
ÿýÿÿù
	þÿ
ýÿÿz#EditMessageMedia.edit_message_media)NNFN)Ú__name__Ú
__module__Ú__qualname__r   ÚintÚstrÚboolrj   r'   r'   r'   r+   r       s0    øÿ
þýüûúùø	÷r   )r5   r7   rD   Útypingr   Úpyrogramr   r   r   Úpyrogram.file_idr   r   r'   r'   r'   r+   Ú<module>   s   