
    N[i                         d dl m Z  d dlmZmZmZ d dlZd dlmZmZmZ d d d  ej                         ddddee
ef   d	e
d
e
de
de fdZ G d d      Zy)    )datetime)UnionOptionalAsyncGeneratorN)typesrawutils)limitoffsetfrom_message_id	from_dateclientpyrogram.Clientchat_idr
   r   r   r   c                 >  K   | j                  t        j                  j                  j	                  | j                  |       d {   |t        j                  |      ||ddd      d       d {   }t        j                  | |d       d {   S 7 Q7 &7 w)Nr   )peer	offset_idoffset_date
add_offsetr
   max_idmin_idhash<   )sleep_threshold)replies)	invoker   	functionsmessages
GetHistoryresolve_peerr	   datetime_to_timestampparse_messages)r   r   r
   r   r   r   r   s          ]/var/www/files/kim/lib/python3.12/site-packages/pyrogram/methods/messages/get_chat_history.py	get_chunkr$      s      ]]))**733%33I> 	* 		
  #  H %%fhBBB 4 Cs6   ABB,B2B3BBBBBc                   n    e Zd Zddd ej                         fdddeeef   dedededed	e	e
d
      fdZy)GetChatHistoryr   selfr   r   r
   r   r   r   return)ztypes.MessageNc                   K   d}|xs d}t        d|      }	 t        | |||||       d{   }|sy|d   j                  }|D ]  }	|	 |dz  }||k\  s y D7 /w)a  Get messages from a chat history.

        The messages are returned in reverse chronological order.

        .. include:: /_includes/usable-by/users.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).

            limit (``int``, *optional*):
                Limits the number of messages to be retrieved.
                By default, no limit is applied and all messages are returned.

            offset (``int``, *optional*):
                Sequential number of the first message to be returned..
                Negative values are also accepted and become useful in case you set offset_id or offset_date.

            offset_id (``int``, *optional*):
                Identifier of the first message to be returned.

            offset_date (:py:obj:`~datetime.datetime`, *optional*):
                Pass a date as offset to retrieve only older messages starting from that date.

        Returns:
            ``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects.

        Example:
            .. code-block:: python

                async for message in app.get_chat_history(chat_id):
                    print(message.text)
        r   id   )r   r   r
   r   r   r   N   )minr$   id)
r'   r   r
   r   r   r   currenttotalr   messages
             r#   get_chat_historyzGetChatHistory.get_chat_history5   s     V &C& )% H  I# 1e# s   *AA*AAN)__name__
__module____qualname__r	   zero_datetimer   intstrr   r   r   r2        r#   r&   r&   4   s}      3 3 3 5DDsCxD D 	D
 D D 
.!67	8Dr:   r&   )r   typingr   r   r   pyrogramr   r   r	   r6   r7   r8   r$   r&   r9   r:   r#   <module>r=      s   &  2 2  & & -%--/CC 38_C 	C
 C C C4E Er:   