o
    Xzjã  ã                   @   sB   d Z ddlZddlmZ ddlmZ ddlmZ G dd	„ d	ƒZdS )
z‹
This module contains the class used to communicate with Telegram's servers
in plain text, when no authorization key has been created yet.
é    Né   )ÚMTProtoStateé   )ÚInvalidBufferError)ÚBinaryReaderc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚMTProtoPlainSenderzw
    MTProto Mobile Protocol plain sender
    (https://core.telegram.org/mtproto/description#unencrypted-messages)
    c                C   s   t d|d�| _|| _dS )zn
        Initializes the MTProto plain sender.

        :param connection: the Connection to be used.
        N)Úauth_keyÚloggers)r   Ú_stateÚ_connection)ÚselfÚ
connectionr	   © r   ú^/var/www/kodo/tsheker/venv/lib/python3.10/site-packages/telethon/network/mtprotoplainsender.pyÚ__init__   s   
zMTProtoPlainSender.__init__c              	   Ã   sÚ   �t |ƒ}| j ¡ }| j t dd|t|ƒ¡| ¡I dH  | j ¡ I dH }t|ƒdk r/t	|ƒ‚t
|ƒ�0}| ¡ }|dks@J dƒ‚| ¡ }|dksLJ dƒ‚| ¡ }|dksXJ dƒ‚| ¡ W  d  ƒ S 1 sfw   Y  dS )zF
        Sends and receives the result for the given request.
        z<qqir   Né   zBad auth_key_idz
Bad msg_idz
Bad length)Úbytesr
   Ú_get_new_msg_idr   ÚsendÚstructÚpackÚlenÚrecvr   r   Ú	read_longÚread_intÚtgread_object)r   ÚrequestÚbodyÚmsg_idÚreaderÚauth_key_idÚlengthr   r   r   r      s$   €

ÿ
$ðzMTProtoPlainSender.sendN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r      s    	r   )	r%   r   Úmtprotostater   Úerrorsr   Ú
extensionsr   r   r   r   r   r   Ú<module>   s    