
    N[i                         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 j                  e
      Z G d d      Zy)    N)Union)raw)utils)PeerIdInvalidc            	           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Zy)ResolvePeerselfzpyrogram.Clientpeer_idreturnc                 Z  K   | j                   st        d      	 | j                  j                  |       d{   S 7 # t        $ r t        |t              r>|dv r t        j                  j                         cY S t        j                  dd|j                               }	 t        |       	 | j                  j                  |       d{  7  cY S # t        $ r t        w xY w# t         $ r 	 | j                  j#                  |       d{  7  cY cY S # t        $ rm | j%                  t        j&                  j(                  j+                  |             d{  7   | j                  j#                  |       d{  7  cY cY cY S w xY ww xY wt-        j.                  |      }|dk(  r{| j1                  | j%                  t        j&                  j2                  j5                  t        j                  j7                  |d	      g
             d{  7         d{  7   n|dk(  rE| j%                  t        j&                  j8                  j;                  | g
             d{  7   nu| j%                  t        j&                  j<                  j?                  t        j                  jA                  t-        jB                  |      d      g
             d{  7   	 | j                  j                  |       d{  7  cY S # t        $ r t        w xY ww xY ww)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   )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get_peer_by_phone_numberr   
ValueErrorget_peer_by_usernameinvoke	functionscontactsResolveUsernamer   get_peer_typefetch_peersusersGetUsers	InputUsermessagesGetChatschannelsGetChannelsInputChannelget_channel_id)r	   r
   	peer_types      Y/var/www/files/kim/lib/python3.12/site-packages/pyrogram/methods/advanced/resolve_peer.pyresolve_peerzResolvePeer.resolve_peer    s    4   !"CDD@	$44W==== >	$'3'n,992244&&B@,L,%)\\%J%J7%SSSS# ,++, " 
P	P%)\\%F%Fw%OOOO# P"kkMM22BB)0 C    &*\\%F%Fw%OOOOP
P" ++G4IF"&&++++44 #		 3 3,301 !4 !"  5 	 	 	   f$kkMM**33$H: 4    kkMM**66II22+0+?+?+H,- 3  7 	 	 	$!\\88AAAA $##${>	$s/  L+A  >A  L+A   =L(=L+?%L(%C*1CCCL(L+C''L(*	F4DDDFL(L+AF!E$
"#FF
FFL(L+FFBL(H
L('H*(A	L(1I42A5L('K*(L(.LLLL(L+L$$L((L+N)__name__
__module____qualname__r   r"   r   r   base	InputPeerr.   r3   r7        r6   r   r      sW    ]$]$sCx]$ 
sxx!!388#5#5sxx7L7LL	M]$r>   r   )loggingr   typingr   pyrogramr   r   pyrogram.errorsr   	getLoggerr8   logr   r=   r>   r6   <module>rE      s:   &  	     )g!^$ ^$r>   