Ejemplo n.º 1
0
    def read(data: BytesIO, *args: Any) -> "MessageUserVote":
        # No flags

        user_id = Int.read(data)

        option = Bytes.read(data)

        date = Int.read(data)

        return MessageUserVote(user_id=user_id, option=option, date=date)
Ejemplo n.º 2
0
    def read(data: BytesIO, *args: Any) -> "SaveFilePart":
        # No flags

        file_id = Long.read(data)

        file_part = Int.read(data)

        bytes = Bytes.read(data)

        return SaveFilePart(file_id=file_id, file_part=file_part, bytes=bytes)
 def read(data: BytesIO, *args: Any) -> "DocumentAttributeAudio":
     flags = Int.read(data)
     
     voice = True if flags & (1 << 10) else False
     duration = Int.read(data)
     
     title = String.read(data) if flags & (1 << 0) else None
     performer = String.read(data) if flags & (1 << 1) else None
     waveform = Bytes.read(data) if flags & (1 << 2) else None
     return DocumentAttributeAudio(duration=duration, voice=voice, title=title, performer=performer, waveform=waveform)
Ejemplo n.º 4
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        # No flags

        data.write(Bytes(self.pq))

        data.write(Bytes(self.p))

        data.write(Bytes(self.q))

        data.write(Int128(self.nonce))

        data.write(Int128(self.server_nonce))

        data.write(Int256(self.new_nonce))

        return data.getvalue()
Ejemplo n.º 5
0
 def read(data: BytesIO, *args: Any) -> "Password":
     flags = Int.read(data)
     
     has_recovery = True if flags & (1 << 0) else False
     has_secure_values = True if flags & (1 << 1) else False
     has_password = True if flags & (1 << 2) else False
     current_algo = TLObject.read(data) if flags & (1 << 2) else None
     
     srp_B = Bytes.read(data) if flags & (1 << 2) else None
     srp_id = Long.read(data) if flags & (1 << 2) else None
     hint = String.read(data) if flags & (1 << 3) else None
     email_unconfirmed_pattern = String.read(data) if flags & (1 << 4) else None
     new_algo = TLObject.read(data)
     
     new_secure_algo = TLObject.read(data)
     
     secure_random = Bytes.read(data)
     
     return Password(new_algo=new_algo, new_secure_algo=new_secure_algo, secure_random=secure_random, has_recovery=has_recovery, has_secure_values=has_secure_values, has_password=has_password, current_algo=current_algo, srp_B=srp_B, srp_id=srp_id, hint=hint, email_unconfirmed_pattern=email_unconfirmed_pattern)
Ejemplo n.º 6
0
    def read(data: BytesIO, *args: Any) -> "SecureValueErrorFile":
        # No flags

        type = TLObject.read(data)

        file_hash = Bytes.read(data)

        text = String.read(data)

        return SecureValueErrorFile(type=type, file_hash=file_hash, text=text)
Ejemplo n.º 7
0
    def read(data: BytesIO, *args: Any) -> "FileHash":
        # No flags

        offset = Int.read(data)

        limit = Int.read(data)

        hash = Bytes.read(data)

        return FileHash(offset=offset, limit=limit, hash=hash)
Ejemplo n.º 8
0
    def read(data: BytesIO, *args: Any) -> "RequestEncryption":
        # No flags

        user_id = TLObject.read(data)

        random_id = Int.read(data)

        g_a = Bytes.read(data)

        return RequestEncryption(user_id=user_id, random_id=random_id, g_a=g_a)
Ejemplo n.º 9
0
    def read(data: BytesIO, *args: Any) -> "SecureFile":
        # No flags

        id = Long.read(data)

        access_hash = Long.read(data)

        size = Int.read(data)

        dc_id = Int.read(data)

        date = Int.read(data)

        file_hash = Bytes.read(data)

        secret = Bytes.read(data)

        return SecureFile(id=id, access_hash=access_hash, size=size, dc_id=dc_id, date=date, file_hash=file_hash,
                          secret=secret)
Ejemplo n.º 10
0
    def read(data: BytesIO, *args: Any) -> "IpPortSecret":
        # No flags

        ipv4 = Int.read(data)

        port = Int.read(data)

        secret = Bytes.read(data)

        return IpPortSecret(ipv4=ipv4, port=port, secret=secret)
Ejemplo n.º 11
0
 def read(data: BytesIO, *args: Any) -> "GetCdnFile":
     # No flags
     
     file_token = Bytes.read(data)
     
     offset = Int.read(data)
     
     limit = Int.read(data)
     
     return GetCdnFile(file_token=file_token, offset=offset, limit=limit)
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        # No flags

        data.write(Int128(self.nonce))

        data.write(Int128(self.server_nonce))

        data.write(Int(self.g))

        data.write(Bytes(self.dh_prime))

        data.write(Bytes(self.g_a))

        data.write(Int(self.server_time))

        return data.getvalue()
Ejemplo n.º 13
0
    def read(data: BytesIO, *args: Any) -> "AcceptCall":
        # No flags

        peer = TLObject.read(data)

        g_b = Bytes.read(data)

        protocol = TLObject.read(data)

        return AcceptCall(peer=peer, g_b=g_b, protocol=protocol)
Ejemplo n.º 14
0
    def read(data: BytesIO, *args: Any) -> "GetDocumentByHash":
        # No flags

        sha256 = Bytes.read(data)

        size = Int.read(data)

        mime_type = String.read(data)

        return GetDocumentByHash(sha256=sha256, size=size, mime_type=mime_type)
Ejemplo n.º 15
0
 def read(data: BytesIO, *args: Any) -> "SecureValueError":
     # No flags
     
     type = TLObject.read(data)
     
     hash = Bytes.read(data)
     
     text = String.read(data)
     
     return SecureValueError(type=type, hash=hash, text=text)
 def read(data: BytesIO, *args: Any) -> "SecureSecretSettings":
     # No flags
     
     secure_algo = TLObject.read(data)
     
     secure_secret = Bytes.read(data)
     
     secure_secret_id = Long.read(data)
     
     return SecureSecretSettings(secure_algo=secure_algo, secure_secret=secure_secret, secure_secret_id=secure_secret_id)
Ejemplo n.º 17
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        # No flags

        data.write(Int128(self.nonce))

        data.write(Int128(self.server_nonce))

        data.write(Bytes(self.p))

        data.write(Bytes(self.q))

        data.write(Long(self.public_key_fingerprint))

        data.write(Bytes(self.encrypted_data))

        return data.getvalue()
 def read(data: BytesIO, *args: Any) -> "SetClientDHParams":
     # No flags
     
     nonce = Int128.read(data)
     
     server_nonce = Int128.read(data)
     
     encrypted_data = Bytes.read(data)
     
     return SetClientDHParams(nonce=nonce, server_nonce=server_nonce, encrypted_data=encrypted_data)
Ejemplo n.º 19
0
 def read(data: BytesIO, *args: Any) -> "File":
     # No flags
     
     type = TLObject.read(data)
     
     mtime = Int.read(data)
     
     bytes = Bytes.read(data)
     
     return File(type=type, mtime=mtime, bytes=bytes)
    def read(data: BytesIO, *args: Any) -> "SendEncryptedService":
        # No flags

        peer = TLObject.read(data)

        random_id = Long.read(data)

        data = Bytes.read(data)

        return SendEncryptedService(peer=peer, random_id=random_id, data=data)
    def read(data: BytesIO, *args: Any) -> "InputPhoto":
        # No flags

        id = Long.read(data)

        access_hash = Long.read(data)

        file_reference = Bytes.read(data)

        return InputPhoto(id=id, access_hash=access_hash, file_reference=file_reference)
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        # No flags

        data.write(Bytes(self.file_token))

        data.write(Int(self.offset))

        return data.getvalue()
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        # No flags

        data.write(Long(self.phone_call_id))

        data.write(Bytes(self.data))

        return data.getvalue()
    def read(data: BytesIO, *args: Any) -> "KeyboardButtonCallback":
        flags = Int.read(data)

        requires_password = True if flags & (1 << 0) else False
        text = String.read(data)

        data = Bytes.read(data)

        return KeyboardButtonCallback(text=text,
                                      data=data,
                                      requires_password=requires_password)
Ejemplo n.º 25
0
 def read(data: BytesIO, *args: Any) -> "PasswordInputSettings":
     flags = Int.read(data)
     
     new_algo = TLObject.read(data) if flags & (1 << 0) else None
     
     new_password_hash = Bytes.read(data) if flags & (1 << 0) else None
     hint = String.read(data) if flags & (1 << 0) else None
     email = String.read(data) if flags & (1 << 1) else None
     new_secure_settings = TLObject.read(data) if flags & (1 << 2) else None
     
     return PasswordInputSettings(new_algo=new_algo, new_password_hash=new_password_hash, hint=hint, email=email, new_secure_settings=new_secure_settings)
Ejemplo n.º 26
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        # No flags

        data.write(Int(self.id))

        data.write(Bytes(self.bytes))

        return data.getvalue()
Ejemplo n.º 27
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        # No flags

        data.write(String(self.text))

        data.write(Bytes(self.option))

        return data.getvalue()
Ejemplo n.º 28
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        # No flags

        data.write(Bytes(self.tmp_password))

        data.write(Int(self.valid_until))

        return data.getvalue()
Ejemplo n.º 29
0
 def read(data: BytesIO, *args: Any) -> "SendEncrypted":
     flags = Int.read(data)
     
     silent = True if flags & (1 << 0) else False
     peer = TLObject.read(data)
     
     random_id = Long.read(data)
     
     data = Bytes.read(data)
     
     return SendEncrypted(peer=peer, random_id=random_id, data=data, silent=silent)
Ejemplo n.º 30
0
 def read(data: BytesIO, *args: Any) -> "ClientDHInnerData":
     # No flags
     
     nonce = Int128.read(data)
     
     server_nonce = Int128.read(data)
     
     retry_id = Long.read(data)
     
     g_b = Bytes.read(data)
     
     return ClientDHInnerData(nonce=nonce, server_nonce=server_nonce, retry_id=retry_id, g_b=g_b)