from telethon.tl.mtproto_request import MTProtoRequest


class ReadHistoryRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    channels.readHistory#cc104937 channel:InputChannel max_id:int = Bool"""

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

    def __init__(self, channel, max_id):
        """
        :param channel: Telegram type: «InputChannel».
        :param max_id: Telegram type: «int».
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.channel = channel
        self.max_id = max_id

    def on_send(self, writer):
        writer.write_int(ReadHistoryRequest.constructor_id, signed=False)
        self.channel.on_send(writer)
        writer.write_int(self.max_id)

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

    def on_response(self, reader):
        self.result = reader.tgread_object()

    def __repr__(self):
        return 'channels.readHistory#cc104937 channel:InputChannel max_id:int = Bool'

    def __str__(self):
        return '(channels.readHistory (ID: 0xcc104937) = (channel={}, max_id={}))'.format(str(self.channel), str(self.max_id))
