o
    -˜Žj}  ã                   @   sd   d dl Z d dlZd dlmZ d dlZd dlmZ d dlmZ d dlmZ e  	e
¡ZG dd„ dƒZdS )é    N)ÚUnion)Úraw)Úutils)ÚPeerIdInvalidc                	   @   s@   e Zd Zdddeeef deejjejj	ejj
f fdd„ZdS )ÚResolvePeerÚselfzpyrogram.ClientÚpeer_idÚreturnc                 Ã   sö  �| j stdƒ‚z
| j |¡I dH W S  tyú   t|tƒr’|dv r)tj 	¡  Y S t
 dd| ¡ ¡}t
 dd| ¡ ¡}zt|ƒ W n: ty{   z| j |¡I dH W  Y  Y S  tyz   |  tjjj|d�¡I dH  | j |¡I dH  Y  Y  Y S w w z| j |¡I dH W  Y S  ty‘   t‚w t |¡}|dkr·|  |  tjjjtjj|d	d
�gd�¡I dH ¡I dH  n-|dkrÌ|  tjjj| gd�¡I dH  n|  tjjjtjj t !|¡d	d�gd�¡I dH  z| j |¡I dH W  Y S  tyù   t‚w w )a�  Get the InputPeer of a known peer id.
        Useful whenever an InputPeer type is required.

        .. note::

            This is a utility method intended to be used **only** when working with raw
            :obj:`functions <pyrogram.api.functions>` (i.e: a Telegram API method you wish to use which is not
            available yet in the Client class as an easy-to-use method).

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

        Parameters:
            peer_id (``int`` | ``str``):
                The peer id you want to extract the InputPeer from.
                Can be a direct id (int), a username (str) or a phone number (str) or *t.me/<username>* link.

        Returns:
            ``InputPeer``: On success, the resolved peer id is returned in form of an InputPeer object.

        Raises:
            KeyError: In case the peer doesn't exist in the internal database.
        zClient has not been started yetN)r   Úmez[@+\s]Ú zhttps://t.me/)ÚusernameÚuserr   )Úuser_idÚaccess_hash)ÚidÚchat)Ú
channel_idr   )"Úis_connectedÚConnectionErrorÚstorageÚget_peer_by_idÚKeyErrorÚ
isinstanceÚstrr   ÚtypesÚInputPeerSelfÚreÚsubÚlowerÚintÚ
ValueErrorÚget_peer_by_usernameÚinvokeÚ	functionsÚcontactsÚResolveUsernameÚget_peer_by_phone_numberr   r   Úget_peer_typeÚfetch_peersÚusersÚGetUsersÚ	InputUserÚmessagesÚGetChatsÚchannelsÚGetChannelsÚInputChannelÚget_channel_id)r   r   Ú	peer_type© r3   úc/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pyrogram/methods/advanced/resolve_peer.pyÚresolve_peer!   s€   €
ÿ
ÿùýÿ
þÿÿÿÿÿÿþÿÿ
ÿÿÂzResolvePeer.resolve_peerN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   ÚbaseÚ	InputPeerr+   r0   r5   r3   r3   r3   r4   r       s    ÿ
þýr   )Úloggingr   Útypingr   Úpyrogramr   r   Úpyrogram.errorsr   Ú	getLoggerr6   Úlogr   r3   r3   r3   r4   Ú<module>   s   
