from ...tl.tlobject import TLObject


class ChannelAdminLogEvent(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    channelAdminLogEvent#3b5a3e40 id:long date:int user_id:int action:ChannelAdminLogEventAction = ChannelAdminLogEvent"""

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

    def __init__(self, id, date, user_id, action):
        """
        :param id: Telegram type: "long".
        :param date: Telegram type: "date".
        :param user_id: Telegram type: "int".
        :param action: Telegram type: "ChannelAdminLogEventAction".

        Constructor for ChannelAdminLogEvent: Instance of ChannelAdminLogEvent.
        """
        super().__init__()

        self.id = id
        self.date = date
        self.user_id = user_id
        self.action = action

    def to_dict(self):
        return {
            'id': self.id,
            'date': self.date,
            'user_id': self.user_id,
            'action': None if self.action is None else self.action.to_dict(),
        }

    def on_send(self, writer):
        writer.write_int(ChannelAdminLogEvent.constructor_id, signed=False)
        writer.write_long(self.id)
        writer.tgwrite_date(self.date)
        writer.write_int(self.user_id)
        self.action.on_send(writer)

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

    def on_response(self, reader):
        self.id = reader.read_long()
        self.date = reader.tgread_date()
        self.user_id = reader.read_int()
        self.action = reader.tgread_object()

    def __repr__(self):
        return 'channelAdminLogEvent#3b5a3e40 id:long date:int user_id:int action:ChannelAdminLogEventAction = ChannelAdminLogEvent'

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

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