from ...tl.tlobject import TLObject


class ChatInviteAlready(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    chatInviteAlready#5a686d7c chat:Chat = ChatInvite"""

    # Telegram's constructor (U)ID for this class
    constructor_id = 0x5a686d7c
    # Also the ID of its resulting type for fast checks
    subclass_of_id = 0x4561736

    def __init__(self, chat):
        """
        :param chat: Telegram type: "Chat".

        Constructor for ChatInvite: Instance of either ChatInviteAlready, ChatInvite.
        """
        super().__init__()

        self.chat = chat

    def to_dict(self):
        return {
            'chat': None if self.chat is None else self.chat.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(ChatInviteAlready.constructor_id, signed=False)
        self.chat.on_send(writer)

    @staticmethod
    def empty():
        """Returns an "empty" instance (attributes=None)"""
        return ChatInviteAlready(None)

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

    def __repr__(self):
        return 'chatInviteAlready#5a686d7c chat:Chat = ChatInvite'

    def __str__(self):
        return TLObject.pretty_format(self)

    def stringify(self):
        return TLObject.pretty_format(self, indent=0)
