U
    ;g7	                     @   sB   d dl mZmZ d dlZd dlmZ d dlmZ G dd dZdS )    )UnionListN)raw)typesc                   @   s*   e Zd Zdeeef ed dddZdS )GetCommonChatszpyrogram.Clientz
types.Chat)selfuser_idreturnc                    sl     |I dH }t|tjjrX tjjj|dddI dH }t	 fdd|j
D S td| ddS )	a  Get the common chats you have with a user.

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

        Parameters:
            user_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).

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

        Raises:
            ValueError: If the user_id doesn't belong to a user.

        Example:
            .. code-block:: python

                common = await app.get_common_chats(user_id)
                print(common)
        Nr   d   )r   Zmax_idlimitc                    s   g | ]}t j |qS  )r   ZChatZ_parse_chat).0xr   r   g/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pyrogram/methods/users/get_common_chats.py
<listcomp>A   s     z3GetCommonChats.get_common_chats.<locals>.<listcomp>zThe user_id "z" doesn't belong to a user)Zresolve_peer
isinstancer   r   ZInputPeerUserZinvokeZ	functionsmessagesr   r   Zchats
ValueError)r   r   Zpeerrr   r   r   get_common_chats   s    
zGetCommonChats.get_common_chatsN)__name__
__module____qualname__r   intstrr   r   r   r   r   r   r      s   
r   )typingr   r   Zpyrogramr   r   r   r   r   r   r   <module>   s   