o
    -˜ŽjF  ã                   @   sd   d dl Z d dlmZmZmZ d dl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)ÚUnionÚListÚIterable)Úraw)Útypes)Úutilsc                   @   sb   e Zd Z			ddddeeef deeee f deeee f ded	ed
ed
 f fdd„ZdS )ÚGetMessagesNé   Úselfzpyrogram.ClientÚchat_idÚmessage_idsÚreply_to_message_idsÚrepliesÚreturnztypes.Messagec                 ƒ   sú   �|r	|t jjfn	|r|t jjfnd\}‰ |du rtdƒ‚|  |¡I dH }t|tƒ }|r1t|ƒn|g}‡ fdd„|D ƒ}|dk rCd}t|t jj	ƒrTt j
jj||d�}nt j
jj|d	�}| j|d
d�I dH }	tj| |	|d�I dH }
|ru|
S |
r{|
d S dS )aM	  Get one or more messages from a chat by using message identifiers.

        You can retrieve up to 200 messages at once.

        .. 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_ids (``int`` | Iterable of ``int``, *optional*):
                Pass a single message identifier or an iterable of message ids (as integers) to get the content of the
                message themselves.

            reply_to_message_ids (``int`` | Iterable of ``int``, *optional*):
                Pass a single message identifier or an iterable of message ids (as integers) to get the content of
                the previous message you replied to using this message.
                If *message_ids* is set, this argument will be ignored.

            replies (``int``, *optional*):
                The number of subsequent replies to get for each message.
                Pass 0 for no reply at all or -1 for unlimited replies.
                Defaults to 1.

        Returns:
            :obj:`~pyrogram.types.Message` | List of :obj:`~pyrogram.types.Message`: In case *message_ids* was not
            a list, a single message is returned, otherwise a list of messages is returned.

        Example:
            .. code-block:: python

                # Get one message
                await app.get_messages(chat_id, 12345)

                # Get more than one message (list of messages)
                await app.get_messages(chat_id, [12345, 12346])

                # Get message by ignoring any replied-to message
                await app.get_messages(chat_id, message_id, replies=0)

                # Get message with all chained replied-to messages
                await app.get_messages(chat_id, message_id, replies=-1)

                # Get the replied-to message of a message
                await app.get_messages(chat_id, reply_to_message_ids=message_id)

        Raises:
            ValueError: In case of invalid arguments.
        )NNNzENo argument supplied. Either pass message_ids or reply_to_message_idsc                    s   g | ]}ˆ |d �‘qS )©Úid© )Ú.0Úi©Úids_typer   úc/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pyrogram/methods/messages/get_messages.pyÚ
<listcomp>k   s    z,GetMessages.get_messages.<locals>.<listcomp>r   iÿÿÿ)Úchannelr   r   éÿÿÿÿ)Úsleep_threshold)r   )r   r   ÚInputMessageIDÚInputMessageReplyToÚ
ValueErrorÚresolve_peerÚ
isinstanceÚintÚlistÚInputPeerChannelÚ	functionsÚchannelsr   ÚmessagesÚinvoker   Úparse_messages)r
   r   r   r   r   ÚidsÚpeerÚis_iterableÚrpcÚrr&   r   r   r   Úget_messages#   s&   €<ýzGetMessages.get_messages)NNr	   )	Ú__name__Ú
__module__Ú__qualname__r   r!   Ústrr   r   r.   r   r   r   r   r   "   s"    ûÿ
þýüûúr   )ÚloggingÚtypingr   r   r   Úpyrogramr   r   r   Ú	getLoggerr/   Úlogr   r   r   r   r   Ú<module>   s   
