o
    -˜Žj7  ã                   @   sl   d dl Z d dlm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	m
Z
 e  e¡ZG dd„ dƒZdS )	é    N)Ú	b64encode)ÚUnion)Úraw)Útypes)ÚSessionÚAuthc                   @   s"   e Zd Zddded fdd„ZdS )ÚSignInQrcodeÚselfzpyrogram.ClientÚreturn)z
types.Userztypes.LoginTokenc                 Ã   s:  �zddl }W n ty   tdƒ‚w | j tjjj| j| j	g d�¡I dH }t
|tjjjƒr_t|jƒ d¡}d|› �}|jd|jjdd	d
�}| |¡ |jdd� tdƒ | ¡  tj |¡S t
|tjjjƒr…| j |jjj¡I dH  | j d¡I dH  tj | |jj¡S t
|tjjj ƒ�r| j !¡ I dH  | j "|j"¡I dH  | j #t$| | j "¡ I dH | j %¡ I dH ƒ &¡ I dH ¡I dH  t'| | j "¡ I dH | j #¡ I dH | j %¡ I dH ƒ| _| j (¡ I dH  | j tjjj)|jd�¡I dH }t
|tjjjƒ�r| j |jjj¡I dH  | j d¡I dH  tj | |jj¡S t*j+ ,d¡‚)aý  Authorize a user in Telegram with a QR code.

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

        Returns:
            :obj:`~pyrogram.types.User` | :obj:`pyrogram.types.LoginToken`, in case the
            authorization completed, the user is returned. In case the QR code is
            not scanned, a login token is returned.

        Raises:
            ImportError: In case the qrcode library is not installed.
            SessionPasswordNeeded: In case a password is needed to sign in.
        r   Nz>qrcode is missing! Please install it with `pip install qrcode`)Úapi_idÚapi_hashÚ
except_idszutf-8ztg://login?token=é   é
   é   )ÚversionÚerror_correctionÚbox_sizeÚborderT)Úfitz(Scan the QR code with your Telegram app.F)Útokenz'Unknown response type from Telegram API)-ÚqrcodeÚImportErrorÚsessionÚinvoker   Ú	functionsÚauthÚExportLoginTokenr   r   Ú
isinstancer   Ú
LoginTokenr   r   ÚdecodeÚQRCodeÚ	constantsÚERROR_CORRECT_LÚadd_dataÚmakeÚprintÚprint_asciiÚ_parseÚLoginTokenSuccessÚstorageÚuser_idÚauthorizationÚuserÚidÚis_botÚUserÚLoginTokenMigrateToÚstopÚdc_idÚauth_keyr   Ú	test_modeÚcreater   ÚstartÚImportLoginTokenÚpyrogramÚ
exceptionsÚRPCError)r	   r   ÚrÚbase64_tokenÚ	login_urlÚqr© r@   úa/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pyrogram/methods/auth/sign_in_qrcode.pyÚsign_in_qrcode    sv   €ÿý
ÿ
ü
þý
ÿþÿ
ÿÿzSignInQrcode.sign_in_qrcodeN)Ú__name__Ú
__module__Ú__qualname__r   rB   r@   r@   r@   rA   r      s    ÿþr   )ÚloggingÚbase64r   Útypingr   r9   r   r   Úpyrogram.sessionr   r   Ú	getLoggerrC   Úlogr   r@   r@   r@   rA   Ú<module>   s   
