from ...tl.tlobject import TLObject


class ChannelAdminLogEventsFilter(TLObject):
    """Class generated by TLObjects' generator. All changes will be ERASED. TL definition below.
    channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true = ChannelAdminLogEventsFilter"""

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

    def __init__(self, join=None, leave=None, invite=None, ban=None, unban=None, kick=None, unkick=None, promote=None, demote=None, info=None, settings=None, pinned=None, edit=None, delete=None):
        """
        :param join: Telegram type: "true".
        :param leave: Telegram type: "true".
        :param invite: Telegram type: "true".
        :param ban: Telegram type: "true".
        :param unban: Telegram type: "true".
        :param kick: Telegram type: "true".
        :param unkick: Telegram type: "true".
        :param promote: Telegram type: "true".
        :param demote: Telegram type: "true".
        :param info: Telegram type: "true".
        :param settings: Telegram type: "true".
        :param pinned: Telegram type: "true".
        :param edit: Telegram type: "true".
        :param delete: Telegram type: "true".

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

        self.join = join
        self.leave = leave
        self.invite = invite
        self.ban = ban
        self.unban = unban
        self.kick = kick
        self.unkick = unkick
        self.promote = promote
        self.demote = demote
        self.info = info
        self.settings = settings
        self.pinned = pinned
        self.edit = edit
        self.delete = delete

    def to_dict(self):
        return {
            'join': self.join,
            'leave': self.leave,
            'invite': self.invite,
            'ban': self.ban,
            'unban': self.unban,
            'kick': self.kick,
            'unkick': self.unkick,
            'promote': self.promote,
            'demote': self.demote,
            'info': self.info,
            'settings': self.settings,
            'pinned': self.pinned,
            'edit': self.edit,
            'delete': self.delete,
        }

    def on_send(self, writer):
        writer.write_int(ChannelAdminLogEventsFilter.constructor_id, signed=False)
        # Calculate the flags. This equals to those flag arguments which are NOT None
        flags = 0
        flags |= (1 << 0) if self.join else 0
        flags |= (1 << 1) if self.leave else 0
        flags |= (1 << 2) if self.invite else 0
        flags |= (1 << 3) if self.ban else 0
        flags |= (1 << 4) if self.unban else 0
        flags |= (1 << 5) if self.kick else 0
        flags |= (1 << 6) if self.unkick else 0
        flags |= (1 << 7) if self.promote else 0
        flags |= (1 << 8) if self.demote else 0
        flags |= (1 << 9) if self.info else 0
        flags |= (1 << 10) if self.settings else 0
        flags |= (1 << 11) if self.pinned else 0
        flags |= (1 << 12) if self.edit else 0
        flags |= (1 << 13) if self.delete else 0
        writer.write_int(flags)


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

    def on_response(self, reader):
        flags = reader.read_int()

        if (flags & (1 << 0)) != 0:
            self.join = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 1)) != 0:
            self.leave = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 2)) != 0:
            self.invite = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 3)) != 0:
            self.ban = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 4)) != 0:
            self.unban = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 5)) != 0:
            self.kick = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 6)) != 0:
            self.unkick = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 7)) != 0:
            self.promote = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 8)) != 0:
            self.demote = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 9)) != 0:
            self.info = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 10)) != 0:
            self.settings = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 11)) != 0:
            self.pinned = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 12)) != 0:
            self.edit = True  # Arbitrary not-None value, no need to read since it is a flag

        if (flags & (1 << 13)) != 0:
            self.delete = True  # Arbitrary not-None value, no need to read since it is a flag

    def __repr__(self):
        return 'channelAdminLogEventsFilter#ea107ae4 flags:# join:flags.0?true leave:flags.1?true invite:flags.2?true ban:flags.3?true unban:flags.4?true kick:flags.5?true unkick:flags.6?true promote:flags.7?true demote:flags.8?true info:flags.9?true settings:flags.10?true pinned:flags.11?true edit:flags.12?true delete:flags.13?true = ChannelAdminLogEventsFilter'

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

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