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


class AppUpdate(TLObject):
    CONSTRUCTOR_ID = 0x8987f311
    SUBCLASS_OF_ID = 0x5897069e

    def __init__(self, id, critical, url, text):
        """
        :param int id:
        :param TLObject critical:
        :param str url:
        :param str text:

        Constructor for help.AppUpdate: Instance of either AppUpdate, NoAppUpdate.
        """
        super().__init__()

        self.id = id
        self.critical = critical
        self.url = url
        self.text = text

    def to_dict(self, recursive=True):
        return {
            'id': self.id,
            'critical': self.critical,
            'url': self.url,
            'text': self.text,
        }

    def __bytes__(self):
        return b''.join((
            b'\x11\xf3\x87\x89',
            struct.pack('<i', self.id),
            b'\xb5ur\x99' if self.critical else b'7\x97y\xbc',
            TLObject.serialize_bytes(self.url),
            TLObject.serialize_bytes(self.text),
        ))

    @staticmethod
    def from_reader(reader):
        _id = reader.read_int()
        _critical = reader.tgread_bool()
        _url = reader.tgread_string()
        _text = reader.tgread_string()
        return AppUpdate(id=_id, critical=_critical, url=_url, text=_text)

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

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


class ConfigSimple(TLObject):
    CONSTRUCTOR_ID = 0xd997c3c5
    SUBCLASS_OF_ID = 0x29183ac4

    def __init__(self, date, expires, dc_id, ip_port_list):
        """
        :param datetime.datetime | None date:
        :param datetime.datetime | None expires:
        :param int dc_id:
        :param list[TLObject] ip_port_list:

        Constructor for help.ConfigSimple: Instance of ConfigSimple.
        """
        super().__init__()

        self.date = date
        self.expires = expires
        self.dc_id = dc_id
        self.ip_port_list = ip_port_list

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

    def __bytes__(self):
        return b''.join((
            b'\xc5\xc3\x97\xd9',
            b'\0\0\0\0' if self.date is None else struct.pack('<I', int(self.date.timestamp())),
            b'\0\0\0\0' if self.expires is None else struct.pack('<I', int(self.expires.timestamp())),
            struct.pack('<i', self.dc_id),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.ip_port_list)),b''.join(bytes(x) for x in self.ip_port_list),
        ))

    @staticmethod
    def from_reader(reader):
        _date = reader.tgread_date()
        _expires = reader.tgread_date()
        _dc_id = reader.read_int()
        reader.read_int()
        _ip_port_list = []
        for _ in range(reader.read_int()):
            from . import IpPort
            _x = IpPort.from_reader(reader)
            _ip_port_list.append(_x)

        return ConfigSimple(date=_date, expires=_expires, dc_id=_dc_id, ip_port_list=_ip_port_list)

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

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


class InviteText(TLObject):
    CONSTRUCTOR_ID = 0x18cb9f78
    SUBCLASS_OF_ID = 0xcf70aa35

    def __init__(self, message):
        """
        :param str message:

        Constructor for help.InviteText: Instance of InviteText.
        """
        super().__init__()

        self.message = message

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

    def __bytes__(self):
        return b''.join((
            b'x\x9f\xcb\x18',
            TLObject.serialize_bytes(self.message),
        ))

    @staticmethod
    def from_reader(reader):
        _message = reader.tgread_string()
        return InviteText(message=_message)

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

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


class NoAppUpdate(TLObject):
    CONSTRUCTOR_ID = 0xc45a6536
    SUBCLASS_OF_ID = 0x5897069e

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

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

    def __bytes__(self):
        return b''.join((
            b'6eZ\xc4',
        ))

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

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

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


class RecentMeUrls(TLObject):
    CONSTRUCTOR_ID = 0xe0310d7
    SUBCLASS_OF_ID = 0xf269c477

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

        Constructor for help.RecentMeUrls: Instance of RecentMeUrls.
        """
        super().__init__()

        self.urls = urls
        self.chats = chats
        self.users = users

    def to_dict(self, recursive=True):
        return {
            'urls': ([] if self.urls is None else [None if x is None else x.to_dict() for x in self.urls]) if recursive else self.urls,
            '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'\xd7\x10\x03\x0e',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.urls)),b''.join(bytes(x) for x in self.urls),
            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()
        _urls = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _urls.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 RecentMeUrls(urls=_urls, chats=_chats, users=_users)

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

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


class Support(TLObject):
    CONSTRUCTOR_ID = 0x17c6b5f6
    SUBCLASS_OF_ID = 0x7159bceb

    def __init__(self, phone_number, user):
        """
        :param str phone_number:
        :param TLObject user:

        Constructor for help.Support: Instance of Support.
        """
        super().__init__()

        self.phone_number = phone_number
        self.user = user

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

    def __bytes__(self):
        return b''.join((
            b'\xf6\xb5\xc6\x17',
            TLObject.serialize_bytes(self.phone_number),
            bytes(self.user),
        ))

    @staticmethod
    def from_reader(reader):
        _phone_number = reader.tgread_string()
        _user = reader.tgread_object()
        return Support(phone_number=_phone_number, user=_user)

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

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


class TermsOfService(TLObject):
    CONSTRUCTOR_ID = 0xf1ee3e90
    SUBCLASS_OF_ID = 0x20ee8312

    def __init__(self, text):
        """
        :param str text:

        Constructor for help.TermsOfService: Instance of TermsOfService.
        """
        super().__init__()

        self.text = text

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

    def __bytes__(self):
        return b''.join((
            b'\x90>\xee\xf1',
            TLObject.serialize_bytes(self.text),
        ))

    @staticmethod
    def from_reader(reader):
        _text = reader.tgread_string()
        return TermsOfService(text=_text)

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

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