from telethon.tl.mtproto_request import MTProtoRequest


class MsgsAllInfo(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    msgs_all_info#8cc0d131 msg_ids:Vector<long> info:string = MsgsAllInfo"""

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

    def __init__(self, msg_ids, info):
        """
        :param msg_ids: Telegram type: «long». Must be a list.
        :param info: Telegram type: «string».
        """
        super().__init__()

        self.msg_ids = msg_ids
        self.info = info

    def on_send(self, writer):
        writer.write_int(MsgsAllInfo.constructor_id, signed=False)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.msg_ids))
        for msg_ids_item in self.msg_ids:
            writer.write_long(msg_ids_item)

        writer.tgwrite_string(self.info)

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

    def on_response(self, reader):
        reader.read_int()  # Vector's constructor ID
        self.msg_ids = []  # Initialize an empty list
        msg_ids_len = reader.read_int()
        for _ in range(msg_ids_len):
            msg_ids_item = reader.read_long()
            self.msg_ids.append(msg_ids_item)

        self.info = reader.tgread_string()

    def __repr__(self):
        return 'msgs_all_info#8cc0d131 msg_ids:Vector<long> info:string = MsgsAllInfo'

    def __str__(self):
        return '(msgs_all_info (ID: 0x8cc0d131) = (msg_ids={}, info={}))'.format(None if not self.msg_ids else [str(_) for _ in self.msg_ids], str(self.info))
