from telethon.tl.mtproto_request import MTProtoRequest


class EncryptedMessageService(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    encryptedMessageService#23734b06 random_id:long chat_id:int date:date bytes:bytes = EncryptedMessage"""

    # Telegram's constructor ID (and unique identifier) for this class
    constructor_id = 0x23734b06

    def __init__(self, random_id, chat_id, date, bytes):
        """
        :param random_id: Telegram type: «long».
        :param chat_id: Telegram type: «int».
        :param date: Telegram type: «date».
        :param bytes: Telegram type: «bytes».
        """
        super().__init__()

        self.random_id = random_id
        self.chat_id = chat_id
        self.date = date
        self.bytes = bytes

    def on_send(self, writer):
        writer.write_int(EncryptedMessageService.constructor_id, signed=False)
        writer.write_long(self.random_id)
        writer.write_int(self.chat_id)
        writer.tgwrite_date(self.date)
        writer.tgwrite_bytes(self.bytes)

    @staticmethod
    def empty():
        """Returns an "empty" instance (all attributes are None)"""
        return EncryptedMessageService(None, None, None, None)

    def on_response(self, reader):
        self.random_id = reader.read_long()
        self.chat_id = reader.read_int()
        self.date = reader.tgread_date()
        self.bytes = reader.tgread_bytes()

    def __repr__(self):
        return 'encryptedMessageService#23734b06 random_id:long chat_id:int date:date bytes:bytes = EncryptedMessage'

    def __str__(self):
        return '(encryptedMessageService (ID: 0x23734b06) = (random_id={}, chat_id={}, date={}, bytes={}))'.format(str(self.random_id), str(self.chat_id), str(self.date), str(self.bytes))
