from ....tl.mtproto_request import MTProtoRequest


class ForwardMessagesRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.forwardMessages#708e0195 flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true from_peer:InputPeer id:Vector<int> random_id:Vector<long> to_peer:InputPeer = Updates"""

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

    def __init__(self, from_peer, id, random_id, to_peer, silent=None, background=None, with_my_score=None):
        """
        :param silent: Telegram type: «true».
        :param background: Telegram type: «true».
        :param with_my_score: Telegram type: «true».
        :param from_peer: Telegram type: «InputPeer».
        :param id: Telegram type: «int». Must be a list.
        :param random_id: Telegram type: «long». Must be a list.
        :param to_peer: Telegram type: «InputPeer».

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, UpdatesTg, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.silent = silent
        self.background = background
        self.with_my_score = with_my_score
        self.from_peer = from_peer
        self.id = id
        self.random_id = random_id
        self.to_peer = to_peer

    def on_send(self, writer):
        writer.write_int(ForwardMessagesRequest.constructor_id, signed=False)
        # Calculate the flags. This equals to those flag arguments which are NOT None
        flags = 0
        flags |= (1 << 5) if self.silent else 0
        flags |= (1 << 6) if self.background else 0
        flags |= (1 << 8) if self.with_my_score else 0
        writer.write_int(flags)

        self.from_peer.on_send(writer)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.id))
        for id_item in self.id:
            writer.write_int(id_item)

        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.random_id))
        for random_id_item in self.random_id:
            writer.write_long(random_id_item)

        self.to_peer.on_send(writer)

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

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

    def __repr__(self):
        return 'messages.forwardMessages#708e0195 flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true from_peer:InputPeer id:Vector<int> random_id:Vector<long> to_peer:InputPeer = Updates'

    def __str__(self):
        return '(messages.forwardMessages (ID: 0x708e0195) = (silent={}, background={}, with_my_score={}, from_peer={}, id={}, random_id={}, to_peer={}))'.format(str(self.silent), str(self.background), str(self.with_my_score), str(self.from_peer), None if not self.id else [str(_) for _ in self.id], None if not self.random_id else [str(_) for _ in self.random_id], str(self.to_peer))
