"""File generated by TLObjects' generator. All changes will be ERASED"""
from ...tl.tlobject import TLObject
import os
import struct


class AdminLogResults(TLObject):
    CONSTRUCTOR_ID = 0xed8af74d
    SUBCLASS_OF_ID = 0x51f076bc

    def __init__(self, events, chats, users):
        """
        :param list[TLObject] events:
        :param list[TLObject] chats:
        :param list[TLObject] users:

        Constructor for channels.AdminLogResults: Instance of AdminLogResults.
        """
        super().__init__()

        self.events = events
        self.chats = chats
        self.users = users

    def to_dict(self, recursive=True):
        return {
            'events': ([] if self.events is None else [None if x is None else x.to_dict() for x in self.events]) if recursive else self.events,
            'chats': ([] if self.chats is None else [None if x is None else x.to_dict() for x in self.chats]) if recursive else self.chats,
            'users': ([] if self.users is None else [None if x is None else x.to_dict() for x in self.users]) if recursive else self.users,
        }

    def to_bytes(self):
        return b''.join((
            b'M\xf7\x8a\xed',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.events)),b''.join(x.to_bytes() for x in self.events),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.chats)),b''.join(x.to_bytes() for x in self.chats),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x.to_bytes() for x in self.users),
        ))

    @staticmethod
    def from_reader(reader):
        reader.read_int()
        _events = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _events.append(_x)

        reader.read_int()
        _chats = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _chats.append(_x)

        reader.read_int()
        _users = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _users.append(_x)

        return AdminLogResults(events=_events, chats=_chats, users=_users)

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

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


class ChannelParticipant(TLObject):
    CONSTRUCTOR_ID = 0xd0d9b163
    SUBCLASS_OF_ID = 0x6658151a

    def __init__(self, participant, users):
        """
        :param TLObject participant:
        :param list[TLObject] users:

        Constructor for channels.ChannelParticipant: Instance of ChannelParticipant.
        """
        super().__init__()

        self.participant = participant
        self.users = users

    def to_dict(self, recursive=True):
        return {
            'participant': (None if self.participant is None else self.participant.to_dict()) if recursive else self.participant,
            'users': ([] if self.users is None else [None if x is None else x.to_dict() for x in self.users]) if recursive else self.users,
        }

    def to_bytes(self):
        return b''.join((
            b'c\xb1\xd9\xd0',
            self.participant.to_bytes(),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x.to_bytes() for x in self.users),
        ))

    @staticmethod
    def from_reader(reader):
        _participant = reader.tgread_object()
        reader.read_int()
        _users = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _users.append(_x)

        return ChannelParticipant(participant=_participant, users=_users)

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

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


class ChannelParticipants(TLObject):
    CONSTRUCTOR_ID = 0xf56ee2a8
    SUBCLASS_OF_ID = 0xe60a6e64

    def __init__(self, count, participants, users):
        """
        :param int count:
        :param list[TLObject] participants:
        :param list[TLObject] users:

        Constructor for channels.ChannelParticipants: Instance of ChannelParticipants.
        """
        super().__init__()

        self.count = count
        self.participants = participants
        self.users = users

    def to_dict(self, recursive=True):
        return {
            'count': self.count,
            'participants': ([] if self.participants is None else [None if x is None else x.to_dict() for x in self.participants]) if recursive else self.participants,
            'users': ([] if self.users is None else [None if x is None else x.to_dict() for x in self.users]) if recursive else self.users,
        }

    def to_bytes(self):
        return b''.join((
            b'\xa8\xe2n\xf5',
            struct.pack('<i', self.count),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.participants)),b''.join(x.to_bytes() for x in self.participants),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x.to_bytes() for x in self.users),
        ))

    @staticmethod
    def from_reader(reader):
        _count = reader.read_int()
        reader.read_int()
        _participants = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _participants.append(_x)

        reader.read_int()
        _users = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _users.append(_x)

        return ChannelParticipants(count=_count, participants=_participants, users=_users)

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

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