
    N[i                         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 j                  e
      Z G d d      Zy)    N)UnionListIterable)raw)types)utilsc                   n    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
Zy)GetMessagesNselfzpyrogram.Clientchat_idmessage_idsreply_to_message_idsrepliesreturnztypes.Messagec                   K   |r|t         j                  j                  fn|r|t         j                  j                  fnd\  }}|t	        d      | j                  |       d{   }t        |t               }|rt        |      n|g}|D 	cg c]  }	 ||	       }}	|dk  rd}t        |t         j                  j                        r,t         j                  j                  j                  ||      }
n*t         j                  j                  j                  |      }
| j                  |
d	       d{   }t        j                   | ||
       d{   }|r|S |r|d   S dS 7 c c}	w 7 97 w)a  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).

            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_ids)idr   i)channelr   )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ids_typepeeris_iterableirpcrr    s                Y/var/www/files/kim/lib/python3.12/site-packages/pyrogram/methods/messages/get_messages.pyget_messageszGetMessages.get_messages"   sM    v 8C[#))223J^&		(E(EF 	X ;dee&&w//$S#..&d3iSE'*+!x1~++Q;#GdCII667--((44Tc4JC--((444<C++c2+66--dAwGG&xM8HQKMM% 0 , 7GsC   A#E6%E*&)E6E-BE68E29E6E4E6-E64E6)NN   )	__name__
__module____qualname__r   r   strr   r   r+        r*   r
   r
   !   s     26:>UNUNsCxUN 3-.UN $C#$67	UN
 UN 
_ 55	6UNr2   r
   )loggingtypingr   r   r   pyrogramr   r   r   	getLoggerr-   logr
   r1   r2   r*   <module>r8      s<   &  ( (    g!VN VNr2   