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


class Blocked(TLObject):
    CONSTRUCTOR_ID = 0x1c138d15
    SUBCLASS_OF_ID = 0xffba4f4f

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

        Constructor for contacts.Blocked: Instance of either Blocked, BlockedSlice.
        """
        super().__init__()

        self.blocked = blocked
        self.users = users

    def to_dict(self, recursive=True):
        return {
            'blocked': ([] if self.blocked is None else [None if x is None else x.to_dict() for x in self.blocked]) if recursive else self.blocked,
            '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 __bytes__(self):
        return b''.join((
            b'\x15\x8d\x13\x1c',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.blocked)),b''.join(bytes(x) for x in self.blocked),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(bytes(x) for x in self.users),
        ))

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

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

        return Blocked(blocked=_blocked, users=_users)

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

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


class BlockedSlice(TLObject):
    CONSTRUCTOR_ID = 0x900802a1
    SUBCLASS_OF_ID = 0xffba4f4f

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

        Constructor for contacts.Blocked: Instance of either Blocked, BlockedSlice.
        """
        super().__init__()

        self.count = count
        self.blocked = blocked
        self.users = users

    def to_dict(self, recursive=True):
        return {
            'count': self.count,
            'blocked': ([] if self.blocked is None else [None if x is None else x.to_dict() for x in self.blocked]) if recursive else self.blocked,
            '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 __bytes__(self):
        return b''.join((
            b'\xa1\x02\x08\x90',
            struct.pack('<i', self.count),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.blocked)),b''.join(bytes(x) for x in self.blocked),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(bytes(x) for x in self.users),
        ))

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

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

        return BlockedSlice(count=_count, blocked=_blocked, users=_users)

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

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


class Contacts(TLObject):
    CONSTRUCTOR_ID = 0xeae87e42
    SUBCLASS_OF_ID = 0x38be25f6

    def __init__(self, contacts, saved_count, users):
        """
        :param list[TLObject] contacts:
        :param int saved_count:
        :param list[TLObject] users:

        Constructor for contacts.Contacts: Instance of either ContactsNotModified, Contacts.
        """
        super().__init__()

        self.contacts = contacts
        self.saved_count = saved_count
        self.users = users

    def to_dict(self, recursive=True):
        return {
            'contacts': ([] if self.contacts is None else [None if x is None else x.to_dict() for x in self.contacts]) if recursive else self.contacts,
            'saved_count': self.saved_count,
            '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 __bytes__(self):
        return b''.join((
            b'B~\xe8\xea',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.contacts)),b''.join(bytes(x) for x in self.contacts),
            struct.pack('<i', self.saved_count),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(bytes(x) for x in self.users),
        ))

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

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

        return Contacts(contacts=_contacts, saved_count=_saved_count, users=_users)

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

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


class ContactsNotModified(TLObject):
    CONSTRUCTOR_ID = 0xb74ba9d2
    SUBCLASS_OF_ID = 0x38be25f6

    def __init__(self):
        super().__init__()

    def to_dict(self, recursive=True):
        return {}

    def __bytes__(self):
        return b''.join((
            b'\xd2\xa9K\xb7',
        ))

    @staticmethod
    def from_reader(reader):
        return ContactsNotModified()

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

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


class Found(TLObject):
    CONSTRUCTOR_ID = 0x1aa1f784
    SUBCLASS_OF_ID = 0x4386a2e3

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

        Constructor for contacts.Found: Instance of Found.
        """
        super().__init__()

        self.results = results
        self.chats = chats
        self.users = users

    def to_dict(self, recursive=True):
        return {
            'results': ([] if self.results is None else [None if x is None else x.to_dict() for x in self.results]) if recursive else self.results,
            '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 __bytes__(self):
        return b''.join((
            b'\x84\xf7\xa1\x1a',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.results)),b''.join(bytes(x) for x in self.results),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.chats)),b''.join(bytes(x) for x in self.chats),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(bytes(x) for x in self.users),
        ))

    @staticmethod
    def from_reader(reader):
        reader.read_int()
        _results = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _results.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 Found(results=_results, chats=_chats, users=_users)

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

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


class ImportedContacts(TLObject):
    CONSTRUCTOR_ID = 0x77d01c3b
    SUBCLASS_OF_ID = 0x8172ad93

    def __init__(self, imported, popular_invites, retry_contacts, users):
        """
        :param list[TLObject] imported:
        :param list[TLObject] popular_invites:
        :param list[int] retry_contacts:
        :param list[TLObject] users:

        Constructor for contacts.ImportedContacts: Instance of ImportedContacts.
        """
        super().__init__()

        self.imported = imported
        self.popular_invites = popular_invites
        self.retry_contacts = retry_contacts
        self.users = users

    def to_dict(self, recursive=True):
        return {
            'imported': ([] if self.imported is None else [None if x is None else x.to_dict() for x in self.imported]) if recursive else self.imported,
            'popular_invites': ([] if self.popular_invites is None else [None if x is None else x.to_dict() for x in self.popular_invites]) if recursive else self.popular_invites,
            'retry_contacts': [] if self.retry_contacts is None else self.retry_contacts[:],
            '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 __bytes__(self):
        return b''.join((
            b';\x1c\xd0w',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.imported)),b''.join(bytes(x) for x in self.imported),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.popular_invites)),b''.join(bytes(x) for x in self.popular_invites),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.retry_contacts)),b''.join(struct.pack('<q', x) for x in self.retry_contacts),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(bytes(x) for x in self.users),
        ))

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

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

        reader.read_int()
        _retry_contacts = []
        for _ in range(reader.read_int()):
            _x = reader.read_long()
            _retry_contacts.append(_x)

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

        return ImportedContacts(imported=_imported, popular_invites=_popular_invites, retry_contacts=_retry_contacts, users=_users)

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

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


class Link(TLObject):
    CONSTRUCTOR_ID = 0x3ace484c
    SUBCLASS_OF_ID = 0x524d5ae9

    def __init__(self, my_link, foreign_link, user):
        """
        :param TLObject my_link:
        :param TLObject foreign_link:
        :param TLObject user:

        Constructor for contacts.Link: Instance of Link.
        """
        super().__init__()

        self.my_link = my_link
        self.foreign_link = foreign_link
        self.user = user

    def to_dict(self, recursive=True):
        return {
            'my_link': (None if self.my_link is None else self.my_link.to_dict()) if recursive else self.my_link,
            'foreign_link': (None if self.foreign_link is None else self.foreign_link.to_dict()) if recursive else self.foreign_link,
            'user': (None if self.user is None else self.user.to_dict()) if recursive else self.user,
        }

    def __bytes__(self):
        return b''.join((
            b'LH\xce:',
            bytes(self.my_link),
            bytes(self.foreign_link),
            bytes(self.user),
        ))

    @staticmethod
    def from_reader(reader):
        _my_link = reader.tgread_object()
        _foreign_link = reader.tgread_object()
        _user = reader.tgread_object()
        return Link(my_link=_my_link, foreign_link=_foreign_link, user=_user)

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

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


class ResolvedPeer(TLObject):
    CONSTRUCTOR_ID = 0x7f077ad9
    SUBCLASS_OF_ID = 0xf065b3a8

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

        Constructor for contacts.ResolvedPeer: Instance of ResolvedPeer.
        """
        super().__init__()

        self.peer = peer
        self.chats = chats
        self.users = users

    def to_dict(self, recursive=True):
        return {
            'peer': (None if self.peer is None else self.peer.to_dict()) if recursive else self.peer,
            '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 __bytes__(self):
        return b''.join((
            b'\xd9z\x07\x7f',
            bytes(self.peer),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.chats)),b''.join(bytes(x) for x in self.chats),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(bytes(x) for x in self.users),
        ))

    @staticmethod
    def from_reader(reader):
        _peer = reader.tgread_object()
        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 ResolvedPeer(peer=_peer, chats=_chats, users=_users)

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

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


class TopPeers(TLObject):
    CONSTRUCTOR_ID = 0x70b772a8
    SUBCLASS_OF_ID = 0x9ee8bb88

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

        Constructor for contacts.TopPeers: Instance of either TopPeersNotModified, TopPeers.
        """
        super().__init__()

        self.categories = categories
        self.chats = chats
        self.users = users

    def to_dict(self, recursive=True):
        return {
            'categories': ([] if self.categories is None else [None if x is None else x.to_dict() for x in self.categories]) if recursive else self.categories,
            '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 __bytes__(self):
        return b''.join((
            b'\xa8r\xb7p',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.categories)),b''.join(bytes(x) for x in self.categories),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.chats)),b''.join(bytes(x) for x in self.chats),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(bytes(x) for x in self.users),
        ))

    @staticmethod
    def from_reader(reader):
        reader.read_int()
        _categories = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _categories.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 TopPeers(categories=_categories, chats=_chats, users=_users)

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

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


class TopPeersNotModified(TLObject):
    CONSTRUCTOR_ID = 0xde266ef5
    SUBCLASS_OF_ID = 0x9ee8bb88

    def __init__(self):
        super().__init__()

    def to_dict(self, recursive=True):
        return {}

    def __bytes__(self):
        return b''.join((
            b'\xf5n&\xde',
        ))

    @staticmethod
    def from_reader(reader):
        return TopPeersNotModified()

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

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