U
    ;g                     @   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eeef eejjejj	ejj
f dddZdS )ResolvePeerzpyrogram.Client)selfpeer_idreturnc                    s  | j stdz| j|I dH W S  tk
r   t|tr&|dkrVtj	  Y S t
dd| }zt| W n| tk
r   z| j|I dH W  Y  Y S  tk
r   | tjjj|dI dH  | j|I dH  Y  Y  Y S X Y n6X z| j|I dH W  Y S  tk
r$   tY nX t|}|dkrr| | 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  n0| tjjjtjj t!|ddgd
I dH  z| j|I dH W  Y S  tk
r    tY nX Y nX dS )as  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).

        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] )usernameuserr   )Zuser_idaccess_hash)idZchat)Z
channel_idr   )"Zis_connectedConnectionErrorZstorageZget_peer_by_idKeyError
isinstancestrr   typesZInputPeerSelfresublowerint
ValueErrorZget_peer_by_usernameZinvokeZ	functionsZcontactsZResolveUsernameZget_peer_by_phone_numberr   r   Zget_peer_typeZfetch_peersZusersZGetUsers	InputUsermessagesZGetChatsZchannelsZGetChannelsInputChannelZget_channel_id)r   r   Z	peer_type r   f/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pyrogram/methods/advanced/resolve_peer.pyresolve_peer    sr    
&




zResolvePeer.resolve_peerN)__name__
__module____qualname__r   r   r   r   baseZ	InputPeerr   r   r   r   r   r   r   r      s   
r   )loggingr   typingr   Zpyrogramr   r   Zpyrogram.errorsr   	getLoggerr    logr   r   r   r   r   <module>   s   
