from ....tl.mtproto_request import MTProtoRequest


class RecentStickers(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.recentStickers#5ce20970 hash:int stickers:Vector<Document> = messages.RecentStickers"""

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

    def __init__(self, hash, stickers):
        """
        :param hash: Telegram type: «int».
        :param stickers: Telegram type: «Document». Must be a list.

        Constructor for messages.RecentStickers: Instance of either RecentStickersNotModified, RecentStickers.
        """
        super().__init__()

        self.hash = hash
        self.stickers = stickers

    def on_send(self, writer):
        writer.write_int(RecentStickers.constructor_id, signed=False)
        writer.write_int(self.hash)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.stickers))
        for stickers_item in self.stickers:
            stickers_item.on_send(writer)

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

    def on_response(self, reader):
        self.hash = reader.read_int()
        reader.read_int()  # Vector's constructor ID
        self.stickers = []  # Initialize an empty list
        stickers_len = reader.read_int()
        for _ in range(stickers_len):
            stickers_item = reader.tgread_object()
            self.stickers.append(stickers_item)

    def __repr__(self):
        return 'messages.recentStickers#5ce20970 hash:int stickers:Vector<Document> = messages.RecentStickers'

    def __str__(self):
        return '(messages.recentStickers (ID: 0x5ce20970) = (hash={}, stickers={}))'.format(str(self.hash), None if not self.stickers else [str(_) for _ in self.stickers])
