U
    ;g                     @   s~   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	 ddee
ef e
e
e
e ddd	ZG d
d dZdS )    )datetime)UnionOptionalAsyncGeneratorN)typesrawutils)limitoffsetfrom_message_id	from_datepyrogram.Clientclientchat_idr	   r
   r   r   c                    sV   | j tjjj| |I d H |t|||ddddddI d H }tj| |ddI d H S )Nr   )Zpeer	offset_idoffset_dateZ
add_offsetr	   Zmax_idZmin_idhash<   )Zsleep_threshold)Zreplies)	Zinvoker   Z	functionsmessagesZ
GetHistoryZresolve_peerr   Zdatetime_to_timestampZparse_messages)r   r   r	   r
   r   r   r    r   j/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pyrogram/methods/messages/get_chat_history.py	get_chunk   s    	
r   c                
   @   sD   e Zd Zddde fdeeef eeeee	e
d  dddZdS )GetChatHistoryr   r   )ztypes.MessageN)selfr   r	   r
   r   r   returnc           
      C  sn   d}|p
d}t d|}t| |||||dI dH }|s8dS |d j}|D ] }	|	V  |d7 }||krF dS qFqdS )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   N   )minr   id)
r   r   r	   r
   r   r   currenttotalr   messager   r   r   get_chat_history5   s&    +
	
zGetChatHistory.get_chat_historyN)__name__
__module____qualname__r   zero_datetimer   intstrr   r   r   r$   r   r   r   r   r   4   s   

r   )r   typingr   r   r   Zpyrogramr   r   r   r(   r)   r*   r   r   r   r   r   r   <module>   s    
