from telethon.tl.mtproto_request import MTProtoRequest


class MessageEditData(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.messageEditData#26b5dde6 flags:None caption:flags.0?true = messages.MessageEditData"""

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

    def __init__(self, caption=None):
        """
        :param caption: Telegram type: «true».
        """
        super().__init__()

        self.caption = caption

    def on_send(self, writer):
        writer.write_int(MessageEditData.constructor_id, signed=False)
        # Calculate the flags. This equals to those flag arguments which are NOT None
        flags = 0
        flags |= (1 << 0) if self.caption else 0
        writer.write_int(flags)


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

    def on_response(self, reader):
        flags = reader.read_int()

        if (flags & (1 << 0)) != 0:
            self.caption = True  # Arbitrary not-None value, no need to read since it is a flag

    def __repr__(self):
        return 'messages.messageEditData#26b5dde6 flags:None caption:flags.0?true = messages.MessageEditData'

    def __str__(self):
        return '(messages.messageEditData (ID: 0x26b5dde6) = (caption={}))'.format(str(self.caption))
