B
    fda	                 @   sJ   d dl mZ d dlZd dlmZ d dlmZ d dlmZ G dd dZdS )    )ListN)raw)types)utilsc               @   s$   e Zd Zdeeed dddZdS )GetNearbyChatszpyrogram.Clientz
types.Chat)selflatitude	longitudereturnc       	         s     tjjjtjj||ddI dH }|js2g S t fdd|j	D }|jd j
}xL|D ]D}t|jtjjr^t|jj}x |D ]}|j|kr|j|_P qW q^W |S )a  Get nearby chats.

        .. include:: /_includes/usable-by/users.rst

        Parameters:
            latitude (``float``):
                Latitude of the location.

            longitude (``float``):
                Longitude of the location.

        Returns:
            List of :obj:`~pyrogram.types.Chat`: On success, a list of nearby chats is returned.

        Example:
            .. code-block:: python

                chats = await app.get_nearby_chats(latitude, longitude)
                print(chats)
        )Zlatlong)Z	geo_pointNc                s   g | ]}t j |qS  )r   ZChatZ_parse_chat).0chat)r   r   K/tmp/pip-unpacked-wheel-rcokkf2l/pyrogram/methods/chats/get_nearby_chats.py
<listcomp>B   s    z3GetNearbyChats.get_nearby_chats.<locals>.<listcomp>r   )Zinvoker   Z	functionsZcontactsZ
GetLocatedr   ZInputGeoPointZupdatesr   chatspeers
isinstancepeerZPeerChannelr   Zget_channel_idZ
channel_ididZdistance)	r   r   r	   rr   r   r   Zchat_idr   r   )r   r   get_nearby_chats   s"    



zGetNearbyChats.get_nearby_chatsN)__name__
__module____qualname__floatr   r   r   r   r   r   r      s   r   )typingr   Zpyrogramr   r   r   r   r   r   r   r   <module>   s
   