U
    ;gE                     @   sB   d dl mZmZmZ d dlZd dlmZmZmZ G dd dZdS )    )UnionAsyncGeneratorOptionalN)typesrawutilsc                   @   s2   e Zd Zddeeef eeed  dddZdS )	GetChatPhotosr   zpyrogram.Client)ztypes.PhotoN)selfchat_idlimitreturnc                   s    |I dH }t|tjjr tjjj|dI dH }tj	
 |jjpPg }t  tjjj|dtj dddd|ddddI dH I dH }dd |D }|r|r|j|d jkr|g| n|}q|}n|r|g}ng }d}|D ] }|V  |d7 }||kr dS qnd}|pd	}	td
|	}d}
 tjjj||
d|dI dH } fdd|jD }|sjdS |
t|7 }
|D ]$}|V  |d7 }||	krz dS qzq*dS )a  Get a chat or a user profile photos sequentially.

        .. 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).

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

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

        Example:
            .. code-block:: python

                async for photo in app.get_chat_photos("me"):
                    print(photo)
        N)Zchannel r   )ZpeerqfilterZmin_dateZmax_dateZ	offset_idZ
add_offsetr   max_idZmin_idhashc                 S   s   g | ]
}|j qS  )Znew_chat_photo).0messager   r   f/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pyrogram/methods/users/get_chat_photos.py
<listcomp>T   s     z1GetChatPhotos.get_chat_photos.<locals>.<listcomp>   l        d   )Zuser_idoffsetr   r   c                    s   g | ]}t j |qS r   )r   Photo_parse)r   photor	   r   r   r   z   s     )Zresolve_peer
isinstancer   r   ZInputPeerChannelZinvokeZ	functionsZchannelsZGetFullChannelr   r   Z	full_chatZ
chat_photor   Zparse_messagesmessagesZSearchZInputMessagesFilterChatPhotosZfile_idminphotosZGetUserPhotoslen)r	   r
   r   Zpeer_idrcurrentextrar!   r   totalr   r   r   r   get_chat_photos   sz    

 



	
zGetChatPhotos.get_chat_photosN)r   )	__name__
__module____qualname__r   intstrr   r   r'   r   r   r   r   r      s    

r   )	typingr   r   r   Zpyrogramr   r   r   r   r   r   r   r   <module>   s   