
    N[i7	                     H    d dl mZmZ d dlZd dlmZ d dlmZ  G d d      Zy)    )UnionListN)raw)typesc                   0    e Zd Zdddeeef   ded   fdZy)GetCommonChatsselfzpyrogram.Clientuser_idreturnz
types.Chatc           	        K   | j                  |       d{   }t        |t        j                  j                        r| j                  t        j                  j                  j                  |dd             d{   }t        j                  |j                  D cg c]"  }t        j                  j                  | |      $ c}      S t        d| d      7 7 `c c}w w)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
   max_idlimitzThe user_id "z" doesn't belong to a user)resolve_peer
isinstancer   r   InputPeerUserinvoke	functionsmessagesr   r   chatsChat_parse_chat
ValueError)r	   r
   peerrxs        Z/var/www/files/kim/lib/python3.12/site-packages/pyrogram/methods/users/get_common_chats.pyget_common_chatszGetCommonChats.get_common_chats   s     6 &&w//dCII334kk&&55  6  A ::P1uzz55dA>PQQ=	1LMNN 0 Qs4   C&CA&C&>C?!C& 'C!C&C&!C&N)__name__
__module____qualname__r   intstrr   r        r   r   r      s2    (O(OsCx(O 
l	(Or%   r   )typingr   r   pyrogramr   r   r   r$   r%   r   <module>r(      s   &    )O )Or%   