
    N[i                     p    d dl Z d dlmZ d dlZd dlmZ d dlmZ  e j                  e      Z G d d      Z	y)    N)Union)raw)typesc                   4    e Zd Zdddededededdef   f
d	Zy
)SignInselfzpyrogram.Clientphone_numberphone_code_hash
phone_codereturnz
types.Userztypes.TermsOfServicec                   K   |j                  d      }| j                  t        j                  j                  j                  |||             d{   }t        |t        j                  j                  j                        r7|j                  r*t        j                  j                  |j                        S y| j                  j                  |j                  j                         d{    | j                  j!                  d       d{    t        j"                  j                  | |j                        S 7 7 S7 2w)a  Authorize a user in Telegram with a valid confirmation code.

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

        Parameters:
            phone_number (``str``):
                Phone number in international format (includes the country prefix).

            phone_code_hash (``str``):
                Code identifier taken from the result of :meth:`~pyrogram.Client.send_code`.

            phone_code (``str``):
                The valid confirmation code you received (either as Telegram message or as SMS in your phone number).

        Returns:
            :obj:`~pyrogram.types.User` | :obj:`~pyrogram.types.TermsOfService` | bool: On success, in case the
            authorization completed, the user is returned. In case the phone number needs to be registered first AND the
            terms of services accepted (with :meth:`~pyrogram.Client.accept_terms_of_service`), an object containing
            them is returned. In case the phone number needs to be registered, but the terms of services don't need to
            be accepted, False is returned instead.

        Raises:
            BadRequest: In case the arguments are invalid.
            SessionPasswordNeeded: In case a password is needed to sign in.
        z +)r	   r
   r   N)terms_of_serviceF)stripinvoker   	functionsauthr   
isinstancer   AuthorizationSignUpRequiredr   TermsOfService_parsestorageuser_iduseridis_botUser)r   r	   r
   r   rs        P/var/www/files/kim/lib/python3.12/site-packages/pyrogram/methods/auth/sign_in.pysign_inzSignIn.sign_in   s     > $))$/++MM%%) /% & 
 
 aCCD!!++22ADVDV2WW,,&&qvvyy111,,%%e,,,::$$T16622#
 2,s7   AEE BE.E/"EE/EEEN)__name__
__module____qualname__strr   boolr        r   r   r      sB    232323 23 	23
 
|3T9	:23r&   r   )
loggingtypingr   pyrogramr   r   	getLoggerr    logr   r%   r&   r   <module>r,      s2   &     g!33 33r&   