o
    -˜ŽjÙ	  ã                   @   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ddeeef ded fdd„ZdS )	ÚGetCommonChatsÚselfzpyrogram.ClientÚuser_idÚreturnz
types.Chatc                 ƒ   sj   �ˆ   |¡I dH }t|tjjƒr-ˆ  tjjj|ddd�¡I dH }t 	‡ fdd„|j
D ƒ¡S td|› d�ƒ‚)	am  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).
                You can also use user profile link in form of *t.me/<username>* (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   Úmax_idÚlimitc                    s   g | ]	}t j ˆ |¡‘qS © )r   ÚChatÚ_parse_chat)Ú.0Úx©r   r   úd/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pyrogram/methods/users/get_common_chats.pyÚ
<listcomp>C   s    z3GetCommonChats.get_common_chats.<locals>.<listcomp>zThe user_id "z" doesn't belong to a user)Úresolve_peerÚ
isinstancer   r   ÚInputPeerUserÚinvokeÚ	functionsÚmessagesr   r   ÚchatsÚ
ValueError)r   r   Ú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   Úpyrogramr   r   r   r   r   r   r   Ú<module>   s
   