from telethon.tl.mtproto_request import MTProtoRequest


class InvokeAfterMsgRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X"""

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

    def __init__(self, msg_id, query):
        """
        :param msg_id: Telegram type: «long».
        :param query: Telegram type: «X». This should be another MTProtoRequest.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.msg_id = msg_id
        self.query = query

    def on_send(self, writer):
        writer.write_int(InvokeAfterMsgRequest.constructor_id, signed=False)
        writer.write_long(self.msg_id)
        self.query.on_send(writer)

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

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

    def __repr__(self):
        return 'invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X'

    def __str__(self):
        return '(invokeAfterMsg (ID: 0xcb9f372d) = (msg_id={}, query={}))'.format(str(self.msg_id), str(self.query))
