U
    nh                     @   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   m/var/www/html/peyman_registration/venvv2/lib/python3.8/site-packages/telethonv2/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
|^}| }|dks~td| }|dkstd| }|dkstd| W  5 Q R  S Q R X 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
   Z_get_new_msg_idr   sendstructpacklenrecvr   r   	read_longAssertionErrorread_inttgread_object)r   requestbodymsg_idreaderZ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   Zmtprotostater   errorsr   
extensionsr   r   r   r   r   r   <module>   s
   