"""File auto-generated by tglib TL generator. Do not edit manually."""
from ..tlobject import TLObject
from typing import Optional, List, Union
import os
import struct
from datetime import datetime


class AccountDaysTtl(TLObject):
    """TL type: accountDaysTTL"""
    CONSTRUCTOR_ID = 0xb8d0afdf
    SUBCLASS_OF_ID = 0xbaa39d88

    def __init__(self, days: int):
        self.days = days

    def to_dict(self):
        return {
            '_': 'AccountDaysTtl',
            'days': self.days,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.days))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_days = reader.read_int()
        _args['days'] = _val_days
        return cls(**_args)


class AttachMenuBot(TLObject):
    """TL type: attachMenuBot"""
    CONSTRUCTOR_ID = 0xd90d8dfe
    SUBCLASS_OF_ID = 0x9f087446

    def __init__(self, bot_id: int, short_name: str, icons: List['TypeAttachMenuBotIcon'], inactive: Optional[bool] = None, has_settings: Optional[bool] = None, request_write_access: Optional[bool] = None, show_in_attach_menu: Optional[bool] = None, show_in_side_menu: Optional[bool] = None, side_menu_disclaimer_needed: Optional[bool] = None, peer_types: Optional[List['TypeAttachMenuPeerType']] = None):
        self.bot_id = bot_id
        self.short_name = short_name
        self.icons = icons
        self.inactive = inactive
        self.has_settings = has_settings
        self.request_write_access = request_write_access
        self.show_in_attach_menu = show_in_attach_menu
        self.show_in_side_menu = show_in_side_menu
        self.side_menu_disclaimer_needed = side_menu_disclaimer_needed
        self.peer_types = peer_types

    def to_dict(self):
        return {
            '_': 'AttachMenuBot',
            'bot_id': self.bot_id,
            'short_name': self.short_name,
            'icons': self.icons,
            'inactive': self.inactive,
            'has_settings': self.has_settings,
            'request_write_access': self.request_write_access,
            'show_in_attach_menu': self.show_in_attach_menu,
            'show_in_side_menu': self.show_in_side_menu,
            'side_menu_disclaimer_needed': self.side_menu_disclaimer_needed,
            'peer_types': self.peer_types,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.inactive:
            flags |= (1 << 0)
        if self.has_settings:
            flags |= (1 << 1)
        if self.request_write_access:
            flags |= (1 << 2)
        if self.peer_types is not None:
            flags |= (1 << 3)
        if self.show_in_side_menu:
            flags |= (1 << 4)
        if self.side_menu_disclaimer_needed:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.bot_id))
        buf.write(TLObject.serialize_bytes(self.short_name))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.icons)))
        for item in self.icons:
            buf.write(bytes(self.item))
        if self.peer_types is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.peer_types)))
            for item in self.peer_types:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['inactive'] = bool(flags & (1 << 0))
        _args['has_settings'] = bool(flags & (1 << 1))
        _args['request_write_access'] = bool(flags & (1 << 2))
        _args['show_in_attach_menu'] = bool(flags & (1 << 3))
        _args['show_in_side_menu'] = bool(flags & (1 << 4))
        _args['side_menu_disclaimer_needed'] = bool(flags & (1 << 5))
        _val_bot_id = reader.read_long()
        _args['bot_id'] = _val_bot_id
        _val_short_name = reader.tgread_string()
        _args['short_name'] = _val_short_name
        if flags & (1 << 3):
            reader.read_int(signed=False)  # skip vector id
            _count_peer_types = reader.read_int()
            _list_peer_types = []
            for _ in range(_count_peer_types):
                _item_peer_types = reader.tgread_object()
                _list_peer_types.append(_item_peer_types)
            _args['peer_types'] = _list_peer_types
        else:
            _args['peer_types'] = None
        reader.read_int(signed=False)  # skip vector id
        _count_icons = reader.read_int()
        _list_icons = []
        for _ in range(_count_icons):
            _item_icons = reader.tgread_object()
            _list_icons.append(_item_icons)
        _args['icons'] = _list_icons
        return cls(**_args)


class AttachMenuBotIcon(TLObject):
    """TL type: attachMenuBotIcon"""
    CONSTRUCTOR_ID = 0xb2a7386b
    SUBCLASS_OF_ID = 0x80484555

    def __init__(self, name: str, icon: 'TypeDocument', colors: Optional[List['TypeAttachMenuBotIconColor']] = None):
        self.name = name
        self.icon = icon
        self.colors = colors

    def to_dict(self):
        return {
            '_': 'AttachMenuBotIcon',
            'name': self.name,
            'icon': self.icon,
            'colors': self.colors,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.colors is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.name))
        buf.write(bytes(self.icon))
        if self.colors is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.colors)))
            for item in self.colors:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        _val_icon = reader.tgread_object()
        _args['icon'] = _val_icon
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_colors = reader.read_int()
            _list_colors = []
            for _ in range(_count_colors):
                _item_colors = reader.tgread_object()
                _list_colors.append(_item_colors)
            _args['colors'] = _list_colors
        else:
            _args['colors'] = None
        return cls(**_args)


class AttachMenuBotIconColor(TLObject):
    """TL type: attachMenuBotIconColor"""
    CONSTRUCTOR_ID = 0x4576f3f0
    SUBCLASS_OF_ID = 0xbea4cb6a

    def __init__(self, name: str, color: int):
        self.name = name
        self.color = color

    def to_dict(self):
        return {
            '_': 'AttachMenuBotIconColor',
            'name': self.name,
            'color': self.color,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.name))
        buf.write(struct.pack('<i', self.color))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        _val_color = reader.read_int()
        _args['color'] = _val_color
        return cls(**_args)


class AttachMenuBots(TLObject):
    """TL type: attachMenuBots"""
    CONSTRUCTOR_ID = 0x3c4301c0
    SUBCLASS_OF_ID = 0x842e23da

    def __init__(self, hash: int, bots: List['TypeAttachMenuBot'], users: List['TypeUser']):
        self.hash = hash
        self.bots = bots
        self.users = users

    def to_dict(self):
        return {
            '_': 'AttachMenuBots',
            'hash': self.hash,
            'bots': self.bots,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.hash))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.bots)))
        for item in self.bots:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        reader.read_int(signed=False)  # skip vector id
        _count_bots = reader.read_int()
        _list_bots = []
        for _ in range(_count_bots):
            _item_bots = reader.tgread_object()
            _list_bots.append(_item_bots)
        _args['bots'] = _list_bots
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class AttachMenuBotsBot(TLObject):
    """TL type: attachMenuBotsBot"""
    CONSTRUCTOR_ID = 0x93bf667f
    SUBCLASS_OF_ID = 0xdb33883d

    def __init__(self, bot: 'TypeAttachMenuBot', users: List['TypeUser']):
        self.bot = bot
        self.users = users

    def to_dict(self):
        return {
            '_': 'AttachMenuBotsBot',
            'bot': self.bot,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.bot))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class AttachMenuBotsNotModified(TLObject):
    """TL type: attachMenuBotsNotModified"""
    CONSTRUCTOR_ID = 0xf1d88a5c
    SUBCLASS_OF_ID = 0x842e23da

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'AttachMenuBotsNotModified',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class AttachMenuPeerTypeBotPm(TLObject):
    """TL type: attachMenuPeerTypeBotPM"""
    CONSTRUCTOR_ID = 0xc32bfa1a
    SUBCLASS_OF_ID = 0xd1d886d0

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'AttachMenuPeerTypeBotPm',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class AttachMenuPeerTypeBroadcast(TLObject):
    """TL type: attachMenuPeerTypeBroadcast"""
    CONSTRUCTOR_ID = 0x7bfbdefc
    SUBCLASS_OF_ID = 0xd1d886d0

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'AttachMenuPeerTypeBroadcast',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class AttachMenuPeerTypeChat(TLObject):
    """TL type: attachMenuPeerTypeChat"""
    CONSTRUCTOR_ID = 0x0509113f
    SUBCLASS_OF_ID = 0xd1d886d0

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'AttachMenuPeerTypeChat',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class AttachMenuPeerTypePm(TLObject):
    """TL type: attachMenuPeerTypePM"""
    CONSTRUCTOR_ID = 0xf146d31f
    SUBCLASS_OF_ID = 0xd1d886d0

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'AttachMenuPeerTypePm',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class AttachMenuPeerTypeSameBotPm(TLObject):
    """TL type: attachMenuPeerTypeSameBotPM"""
    CONSTRUCTOR_ID = 0x7d6be90e
    SUBCLASS_OF_ID = 0xd1d886d0

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'AttachMenuPeerTypeSameBotPm',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class AuctionBidLevel(TLObject):
    """TL type: auctionBidLevel"""
    CONSTRUCTOR_ID = 0x310240cc
    SUBCLASS_OF_ID = 0xba444ad7

    def __init__(self, pos: int, amount: int, date: Optional[datetime]):
        self.pos = pos
        self.amount = amount
        self.date = date

    def to_dict(self):
        return {
            '_': 'AuctionBidLevel',
            'pos': self.pos,
            'amount': self.amount,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.pos))
        buf.write(struct.pack('<q', self.amount))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_pos = reader.read_int()
        _args['pos'] = _val_pos
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class Authorization(TLObject):
    """TL type: authorization"""
    CONSTRUCTOR_ID = 0xad01d61d
    SUBCLASS_OF_ID = 0xc913c01a

    def __init__(self, hash: int, device_model: str, platform: str, system_version: str, api_id: int, app_name: str, app_version: str, date_created: Optional[datetime], date_active: Optional[datetime], ip: str, country: str, region: str, current: Optional[bool] = None, official_app: Optional[bool] = None, password_pending: Optional[bool] = None, encrypted_requests_disabled: Optional[bool] = None, call_requests_disabled: Optional[bool] = None, unconfirmed: Optional[bool] = None):
        self.hash = hash
        self.device_model = device_model
        self.platform = platform
        self.system_version = system_version
        self.api_id = api_id
        self.app_name = app_name
        self.app_version = app_version
        self.date_created = date_created
        self.date_active = date_active
        self.ip = ip
        self.country = country
        self.region = region
        self.current = current
        self.official_app = official_app
        self.password_pending = password_pending
        self.encrypted_requests_disabled = encrypted_requests_disabled
        self.call_requests_disabled = call_requests_disabled
        self.unconfirmed = unconfirmed

    def to_dict(self):
        return {
            '_': 'Authorization',
            'hash': self.hash,
            'device_model': self.device_model,
            'platform': self.platform,
            'system_version': self.system_version,
            'api_id': self.api_id,
            'app_name': self.app_name,
            'app_version': self.app_version,
            'date_created': self.date_created,
            'date_active': self.date_active,
            'ip': self.ip,
            'country': self.country,
            'region': self.region,
            'current': self.current,
            'official_app': self.official_app,
            'password_pending': self.password_pending,
            'encrypted_requests_disabled': self.encrypted_requests_disabled,
            'call_requests_disabled': self.call_requests_disabled,
            'unconfirmed': self.unconfirmed,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.current:
            flags |= (1 << 0)
        if self.official_app:
            flags |= (1 << 1)
        if self.password_pending:
            flags |= (1 << 2)
        if self.encrypted_requests_disabled:
            flags |= (1 << 3)
        if self.call_requests_disabled:
            flags |= (1 << 4)
        if self.unconfirmed:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.hash))
        buf.write(TLObject.serialize_bytes(self.device_model))
        buf.write(TLObject.serialize_bytes(self.platform))
        buf.write(TLObject.serialize_bytes(self.system_version))
        buf.write(struct.pack('<i', self.api_id))
        buf.write(TLObject.serialize_bytes(self.app_name))
        buf.write(TLObject.serialize_bytes(self.app_version))
        buf.write(struct.pack('<i', self.date_created))
        buf.write(struct.pack('<i', self.date_active))
        buf.write(TLObject.serialize_bytes(self.ip))
        buf.write(TLObject.serialize_bytes(self.country))
        buf.write(TLObject.serialize_bytes(self.region))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['current'] = bool(flags & (1 << 0))
        _args['official_app'] = bool(flags & (1 << 1))
        _args['password_pending'] = bool(flags & (1 << 2))
        _args['encrypted_requests_disabled'] = bool(flags & (1 << 3))
        _args['call_requests_disabled'] = bool(flags & (1 << 4))
        _args['unconfirmed'] = bool(flags & (1 << 5))
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        _val_device_model = reader.tgread_string()
        _args['device_model'] = _val_device_model
        _val_platform = reader.tgread_string()
        _args['platform'] = _val_platform
        _val_system_version = reader.tgread_string()
        _args['system_version'] = _val_system_version
        _val_api_id = reader.read_int()
        _args['api_id'] = _val_api_id
        _val_app_name = reader.tgread_string()
        _args['app_name'] = _val_app_name
        _val_app_version = reader.tgread_string()
        _args['app_version'] = _val_app_version
        _val_date_created = reader.read_int()
        _args['date_created'] = _val_date_created
        _val_date_active = reader.read_int()
        _args['date_active'] = _val_date_active
        _val_ip = reader.tgread_string()
        _args['ip'] = _val_ip
        _val_country = reader.tgread_string()
        _args['country'] = _val_country
        _val_region = reader.tgread_string()
        _args['region'] = _val_region
        return cls(**_args)


class AutoDownloadSettings(TLObject):
    """TL type: autoDownloadSettings"""
    CONSTRUCTOR_ID = 0xbaa57628
    SUBCLASS_OF_ID = 0x512819c7

    def __init__(self, photo_size_max: int, video_size_max: int, file_size_max: int, video_upload_maxbitrate: int, small_queue_active_operations_max: int, large_queue_active_operations_max: int, disabled: Optional[bool] = None, video_preload_large: Optional[bool] = None, audio_preload_next: Optional[bool] = None, phonecalls_less_data: Optional[bool] = None, stories_preload: Optional[bool] = None):
        self.photo_size_max = photo_size_max
        self.video_size_max = video_size_max
        self.file_size_max = file_size_max
        self.video_upload_maxbitrate = video_upload_maxbitrate
        self.small_queue_active_operations_max = small_queue_active_operations_max
        self.large_queue_active_operations_max = large_queue_active_operations_max
        self.disabled = disabled
        self.video_preload_large = video_preload_large
        self.audio_preload_next = audio_preload_next
        self.phonecalls_less_data = phonecalls_less_data
        self.stories_preload = stories_preload

    def to_dict(self):
        return {
            '_': 'AutoDownloadSettings',
            'photo_size_max': self.photo_size_max,
            'video_size_max': self.video_size_max,
            'file_size_max': self.file_size_max,
            'video_upload_maxbitrate': self.video_upload_maxbitrate,
            'small_queue_active_operations_max': self.small_queue_active_operations_max,
            'large_queue_active_operations_max': self.large_queue_active_operations_max,
            'disabled': self.disabled,
            'video_preload_large': self.video_preload_large,
            'audio_preload_next': self.audio_preload_next,
            'phonecalls_less_data': self.phonecalls_less_data,
            'stories_preload': self.stories_preload,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.disabled:
            flags |= (1 << 0)
        if self.video_preload_large:
            flags |= (1 << 1)
        if self.audio_preload_next:
            flags |= (1 << 2)
        if self.phonecalls_less_data:
            flags |= (1 << 3)
        if self.stories_preload:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.photo_size_max))
        buf.write(struct.pack('<q', self.video_size_max))
        buf.write(struct.pack('<q', self.file_size_max))
        buf.write(struct.pack('<i', self.video_upload_maxbitrate))
        buf.write(struct.pack('<i', self.small_queue_active_operations_max))
        buf.write(struct.pack('<i', self.large_queue_active_operations_max))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['disabled'] = bool(flags & (1 << 0))
        _args['video_preload_large'] = bool(flags & (1 << 1))
        _args['audio_preload_next'] = bool(flags & (1 << 2))
        _args['phonecalls_less_data'] = bool(flags & (1 << 3))
        _args['stories_preload'] = bool(flags & (1 << 4))
        _val_photo_size_max = reader.read_int()
        _args['photo_size_max'] = _val_photo_size_max
        _val_video_size_max = reader.read_long()
        _args['video_size_max'] = _val_video_size_max
        _val_file_size_max = reader.read_long()
        _args['file_size_max'] = _val_file_size_max
        _val_video_upload_maxbitrate = reader.read_int()
        _args['video_upload_maxbitrate'] = _val_video_upload_maxbitrate
        _val_small_queue_active_operations_max = reader.read_int()
        _args['small_queue_active_operations_max'] = _val_small_queue_active_operations_max
        _val_large_queue_active_operations_max = reader.read_int()
        _args['large_queue_active_operations_max'] = _val_large_queue_active_operations_max
        return cls(**_args)


class AutoSaveException(TLObject):
    """TL type: autoSaveException"""
    CONSTRUCTOR_ID = 0x81602d47
    SUBCLASS_OF_ID = 0xdd868129

    def __init__(self, peer: 'TypePeer', settings: 'TypeAutoSaveSettings'):
        self.peer = peer
        self.settings = settings

    def to_dict(self):
        return {
            '_': 'AutoSaveException',
            'peer': self.peer,
            'settings': self.settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_settings = reader.tgread_object()
        _args['settings'] = _val_settings
        return cls(**_args)


class AutoSaveSettings(TLObject):
    """TL type: autoSaveSettings"""
    CONSTRUCTOR_ID = 0xc84834ce
    SUBCLASS_OF_ID = 0xcd3b96e6

    def __init__(self, photos: Optional[bool] = None, videos: Optional[bool] = None, video_max_size: Optional[int] = None):
        self.photos = photos
        self.videos = videos
        self.video_max_size = video_max_size

    def to_dict(self):
        return {
            '_': 'AutoSaveSettings',
            'photos': self.photos,
            'videos': self.videos,
            'video_max_size': self.video_max_size,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.photos:
            flags |= (1 << 0)
        if self.videos:
            flags |= (1 << 1)
        if self.video_max_size is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.video_max_size is not None:
            buf.write(struct.pack('<q', self.video_max_size))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['photos'] = bool(flags & (1 << 0))
        _args['videos'] = bool(flags & (1 << 1))
        if flags & (1 << 2):
            _val_video_max_size = reader.read_long()
            _args['video_max_size'] = _val_video_max_size
        else:
            _args['video_max_size'] = None
        return cls(**_args)


class AvailableEffect(TLObject):
    """TL type: availableEffect"""
    CONSTRUCTOR_ID = 0x93c3e27e
    SUBCLASS_OF_ID = 0x985a2f81

    def __init__(self, id: int, emoticon: str, effect_sticker_id: int, premium_required: Optional[bool] = None, static_icon_id: Optional[int] = None, effect_animation_id: Optional[int] = None):
        self.id = id
        self.emoticon = emoticon
        self.effect_sticker_id = effect_sticker_id
        self.premium_required = premium_required
        self.static_icon_id = static_icon_id
        self.effect_animation_id = effect_animation_id

    def to_dict(self):
        return {
            '_': 'AvailableEffect',
            'id': self.id,
            'emoticon': self.emoticon,
            'effect_sticker_id': self.effect_sticker_id,
            'premium_required': self.premium_required,
            'static_icon_id': self.static_icon_id,
            'effect_animation_id': self.effect_animation_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.premium_required:
            flags |= (1 << 2)
        if self.static_icon_id is not None:
            flags |= (1 << 0)
        if self.effect_animation_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(TLObject.serialize_bytes(self.emoticon))
        buf.write(struct.pack('<q', self.effect_sticker_id))
        if self.static_icon_id is not None:
            buf.write(struct.pack('<q', self.static_icon_id))
        if self.effect_animation_id is not None:
            buf.write(struct.pack('<q', self.effect_animation_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['premium_required'] = bool(flags & (1 << 2))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        if flags & (1 << 0):
            _val_static_icon_id = reader.read_long()
            _args['static_icon_id'] = _val_static_icon_id
        else:
            _args['static_icon_id'] = None
        _val_effect_sticker_id = reader.read_long()
        _args['effect_sticker_id'] = _val_effect_sticker_id
        if flags & (1 << 1):
            _val_effect_animation_id = reader.read_long()
            _args['effect_animation_id'] = _val_effect_animation_id
        else:
            _args['effect_animation_id'] = None
        return cls(**_args)


class AvailableReaction(TLObject):
    """TL type: availableReaction"""
    CONSTRUCTOR_ID = 0xc077ec01
    SUBCLASS_OF_ID = 0x8c1c9d73

    def __init__(self, reaction: str, title: str, static_icon: 'TypeDocument', appear_animation: 'TypeDocument', select_animation: 'TypeDocument', activate_animation: 'TypeDocument', effect_animation: 'TypeDocument', inactive: Optional[bool] = None, premium: Optional[bool] = None, around_animation: Optional['TypeDocument'] = None, center_icon: Optional['TypeDocument'] = None):
        self.reaction = reaction
        self.title = title
        self.static_icon = static_icon
        self.appear_animation = appear_animation
        self.select_animation = select_animation
        self.activate_animation = activate_animation
        self.effect_animation = effect_animation
        self.inactive = inactive
        self.premium = premium
        self.around_animation = around_animation
        self.center_icon = center_icon

    def to_dict(self):
        return {
            '_': 'AvailableReaction',
            'reaction': self.reaction,
            'title': self.title,
            'static_icon': self.static_icon,
            'appear_animation': self.appear_animation,
            'select_animation': self.select_animation,
            'activate_animation': self.activate_animation,
            'effect_animation': self.effect_animation,
            'inactive': self.inactive,
            'premium': self.premium,
            'around_animation': self.around_animation,
            'center_icon': self.center_icon,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.inactive:
            flags |= (1 << 0)
        if self.premium:
            flags |= (1 << 2)
        if self.center_icon is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.reaction))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(bytes(self.static_icon))
        buf.write(bytes(self.appear_animation))
        buf.write(bytes(self.select_animation))
        buf.write(bytes(self.activate_animation))
        buf.write(bytes(self.effect_animation))
        if self.around_animation is not None:
            buf.write(bytes(self.around_animation))
        if self.center_icon is not None:
            buf.write(bytes(self.center_icon))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['inactive'] = bool(flags & (1 << 0))
        _args['premium'] = bool(flags & (1 << 2))
        _val_reaction = reader.tgread_string()
        _args['reaction'] = _val_reaction
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_static_icon = reader.tgread_object()
        _args['static_icon'] = _val_static_icon
        _val_appear_animation = reader.tgread_object()
        _args['appear_animation'] = _val_appear_animation
        _val_select_animation = reader.tgread_object()
        _args['select_animation'] = _val_select_animation
        _val_activate_animation = reader.tgread_object()
        _args['activate_animation'] = _val_activate_animation
        _val_effect_animation = reader.tgread_object()
        _args['effect_animation'] = _val_effect_animation
        if flags & (1 << 1):
            _val_around_animation = reader.tgread_object()
            _args['around_animation'] = _val_around_animation
        else:
            _args['around_animation'] = None
        if flags & (1 << 1):
            _val_center_icon = reader.tgread_object()
            _args['center_icon'] = _val_center_icon
        else:
            _args['center_icon'] = None
        return cls(**_args)


class BankCardOpenUrl(TLObject):
    """TL type: bankCardOpenUrl"""
    CONSTRUCTOR_ID = 0xf568028a
    SUBCLASS_OF_ID = 0xf2e2460e

    def __init__(self, url: str, name: str):
        self.url = url
        self.name = name

    def to_dict(self):
        return {
            '_': 'BankCardOpenUrl',
            'url': self.url,
            'name': self.name,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(TLObject.serialize_bytes(self.name))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        return cls(**_args)


class BaseThemeArctic(TLObject):
    """TL type: baseThemeArctic"""
    CONSTRUCTOR_ID = 0x5b11125a
    SUBCLASS_OF_ID = 0x1f03f444

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BaseThemeArctic',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BaseThemeClassic(TLObject):
    """TL type: baseThemeClassic"""
    CONSTRUCTOR_ID = 0xc3a12462
    SUBCLASS_OF_ID = 0x1f03f444

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BaseThemeClassic',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BaseThemeDay(TLObject):
    """TL type: baseThemeDay"""
    CONSTRUCTOR_ID = 0xfbd81688
    SUBCLASS_OF_ID = 0x1f03f444

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BaseThemeDay',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BaseThemeNight(TLObject):
    """TL type: baseThemeNight"""
    CONSTRUCTOR_ID = 0xb7b31ea8
    SUBCLASS_OF_ID = 0x1f03f444

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BaseThemeNight',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BaseThemeTinted(TLObject):
    """TL type: baseThemeTinted"""
    CONSTRUCTOR_ID = 0x6d5f77ee
    SUBCLASS_OF_ID = 0x1f03f444

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BaseThemeTinted',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class Birthday(TLObject):
    """TL type: birthday"""
    CONSTRUCTOR_ID = 0x6c8e1e06
    SUBCLASS_OF_ID = 0xbe7fd664

    def __init__(self, day: int, month: int, year: Optional[int] = None):
        self.day = day
        self.month = month
        self.year = year

    def to_dict(self):
        return {
            '_': 'Birthday',
            'day': self.day,
            'month': self.month,
            'year': self.year,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.year is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.day))
        buf.write(struct.pack('<i', self.month))
        if self.year is not None:
            buf.write(struct.pack('<i', self.year))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_day = reader.read_int()
        _args['day'] = _val_day
        _val_month = reader.read_int()
        _args['month'] = _val_month
        if flags & (1 << 0):
            _val_year = reader.read_int()
            _args['year'] = _val_year
        else:
            _args['year'] = None
        return cls(**_args)


class Boost(TLObject):
    """TL type: boost"""
    CONSTRUCTOR_ID = 0x4b3e14d6
    SUBCLASS_OF_ID = 0x97a5086c

    def __init__(self, id: str, date: Optional[datetime], expires: Optional[datetime], gift: Optional[bool] = None, giveaway: Optional[bool] = None, unclaimed: Optional[bool] = None, user_id: Optional[int] = None, giveaway_msg_id: Optional[int] = None, used_gift_slug: Optional[str] = None, multiplier: Optional[int] = None, stars: Optional[int] = None):
        self.id = id
        self.date = date
        self.expires = expires
        self.gift = gift
        self.giveaway = giveaway
        self.unclaimed = unclaimed
        self.user_id = user_id
        self.giveaway_msg_id = giveaway_msg_id
        self.used_gift_slug = used_gift_slug
        self.multiplier = multiplier
        self.stars = stars

    def to_dict(self):
        return {
            '_': 'Boost',
            'id': self.id,
            'date': self.date,
            'expires': self.expires,
            'gift': self.gift,
            'giveaway': self.giveaway,
            'unclaimed': self.unclaimed,
            'user_id': self.user_id,
            'giveaway_msg_id': self.giveaway_msg_id,
            'used_gift_slug': self.used_gift_slug,
            'multiplier': self.multiplier,
            'stars': self.stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.gift:
            flags |= (1 << 1)
        if self.giveaway_msg_id is not None:
            flags |= (1 << 2)
        if self.unclaimed:
            flags |= (1 << 3)
        if self.user_id is not None:
            flags |= (1 << 0)
        if self.used_gift_slug is not None:
            flags |= (1 << 4)
        if self.multiplier is not None:
            flags |= (1 << 5)
        if self.stars is not None:
            flags |= (1 << 6)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.expires))
        if self.user_id is not None:
            buf.write(struct.pack('<q', self.user_id))
        if self.giveaway_msg_id is not None:
            buf.write(struct.pack('<i', self.giveaway_msg_id))
        if self.used_gift_slug is not None:
            buf.write(TLObject.serialize_bytes(self.used_gift_slug))
        if self.multiplier is not None:
            buf.write(struct.pack('<i', self.multiplier))
        if self.stars is not None:
            buf.write(struct.pack('<q', self.stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['gift'] = bool(flags & (1 << 1))
        _args['giveaway'] = bool(flags & (1 << 2))
        _args['unclaimed'] = bool(flags & (1 << 3))
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        if flags & (1 << 0):
            _val_user_id = reader.read_long()
            _args['user_id'] = _val_user_id
        else:
            _args['user_id'] = None
        if flags & (1 << 2):
            _val_giveaway_msg_id = reader.read_int()
            _args['giveaway_msg_id'] = _val_giveaway_msg_id
        else:
            _args['giveaway_msg_id'] = None
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_expires = reader.read_int()
        _args['expires'] = _val_expires
        if flags & (1 << 4):
            _val_used_gift_slug = reader.tgread_string()
            _args['used_gift_slug'] = _val_used_gift_slug
        else:
            _args['used_gift_slug'] = None
        if flags & (1 << 5):
            _val_multiplier = reader.read_int()
            _args['multiplier'] = _val_multiplier
        else:
            _args['multiplier'] = None
        if flags & (1 << 6):
            _val_stars = reader.read_long()
            _args['stars'] = _val_stars
        else:
            _args['stars'] = None
        return cls(**_args)


class BotApp(TLObject):
    """TL type: botApp"""
    CONSTRUCTOR_ID = 0x95fcd1d6
    SUBCLASS_OF_ID = 0x020f32ae

    def __init__(self, id: int, access_hash: int, short_name: str, title: str, description: str, photo: 'TypePhoto', hash: int, document: Optional['TypeDocument'] = None):
        self.id = id
        self.access_hash = access_hash
        self.short_name = short_name
        self.title = title
        self.description = description
        self.photo = photo
        self.hash = hash
        self.document = document

    def to_dict(self):
        return {
            '_': 'BotApp',
            'id': self.id,
            'access_hash': self.access_hash,
            'short_name': self.short_name,
            'title': self.title,
            'description': self.description,
            'photo': self.photo,
            'hash': self.hash,
            'document': self.document,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.document is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.short_name))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.description))
        buf.write(bytes(self.photo))
        buf.write(struct.pack('<q', self.hash))
        if self.document is not None:
            buf.write(bytes(self.document))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_short_name = reader.tgread_string()
        _args['short_name'] = _val_short_name
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_description = reader.tgread_string()
        _args['description'] = _val_description
        _val_photo = reader.tgread_object()
        _args['photo'] = _val_photo
        if flags & (1 << 0):
            _val_document = reader.tgread_object()
            _args['document'] = _val_document
        else:
            _args['document'] = None
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class BotAppNotModified(TLObject):
    """TL type: botAppNotModified"""
    CONSTRUCTOR_ID = 0x5da674b7
    SUBCLASS_OF_ID = 0x020f32ae

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BotAppNotModified',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BotAppSettings(TLObject):
    """TL type: botAppSettings"""
    CONSTRUCTOR_ID = 0xc99b1950
    SUBCLASS_OF_ID = 0x179e62e3

    def __init__(self, placeholder_path: Optional[bytes] = None, background_color: Optional[int] = None, background_dark_color: Optional[int] = None, header_color: Optional[int] = None, header_dark_color: Optional[int] = None):
        self.placeholder_path = placeholder_path
        self.background_color = background_color
        self.background_dark_color = background_dark_color
        self.header_color = header_color
        self.header_dark_color = header_dark_color

    def to_dict(self):
        return {
            '_': 'BotAppSettings',
            'placeholder_path': self.placeholder_path,
            'background_color': self.background_color,
            'background_dark_color': self.background_dark_color,
            'header_color': self.header_color,
            'header_dark_color': self.header_dark_color,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.placeholder_path is not None:
            flags |= (1 << 0)
        if self.background_color is not None:
            flags |= (1 << 1)
        if self.background_dark_color is not None:
            flags |= (1 << 2)
        if self.header_color is not None:
            flags |= (1 << 3)
        if self.header_dark_color is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        if self.placeholder_path is not None:
            buf.write(TLObject.serialize_bytes(self.placeholder_path))
        if self.background_color is not None:
            buf.write(struct.pack('<i', self.background_color))
        if self.background_dark_color is not None:
            buf.write(struct.pack('<i', self.background_dark_color))
        if self.header_color is not None:
            buf.write(struct.pack('<i', self.header_color))
        if self.header_dark_color is not None:
            buf.write(struct.pack('<i', self.header_dark_color))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_placeholder_path = reader.tgread_bytes()
            _args['placeholder_path'] = _val_placeholder_path
        else:
            _args['placeholder_path'] = None
        if flags & (1 << 1):
            _val_background_color = reader.read_int()
            _args['background_color'] = _val_background_color
        else:
            _args['background_color'] = None
        if flags & (1 << 2):
            _val_background_dark_color = reader.read_int()
            _args['background_dark_color'] = _val_background_dark_color
        else:
            _args['background_dark_color'] = None
        if flags & (1 << 3):
            _val_header_color = reader.read_int()
            _args['header_color'] = _val_header_color
        else:
            _args['header_color'] = None
        if flags & (1 << 4):
            _val_header_dark_color = reader.read_int()
            _args['header_dark_color'] = _val_header_dark_color
        else:
            _args['header_dark_color'] = None
        return cls(**_args)


class BotBusinessConnection(TLObject):
    """TL type: botBusinessConnection"""
    CONSTRUCTOR_ID = 0x8f34b2f5
    SUBCLASS_OF_ID = 0x9b130546

    def __init__(self, connection_id: str, user_id: int, dc_id: int, date: Optional[datetime], disabled: Optional[bool] = None, rights: Optional['TypeBusinessBotRights'] = None):
        self.connection_id = connection_id
        self.user_id = user_id
        self.dc_id = dc_id
        self.date = date
        self.disabled = disabled
        self.rights = rights

    def to_dict(self):
        return {
            '_': 'BotBusinessConnection',
            'connection_id': self.connection_id,
            'user_id': self.user_id,
            'dc_id': self.dc_id,
            'date': self.date,
            'disabled': self.disabled,
            'rights': self.rights,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.disabled:
            flags |= (1 << 1)
        if self.rights is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.connection_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.dc_id))
        buf.write(struct.pack('<i', self.date))
        if self.rights is not None:
            buf.write(bytes(self.rights))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['disabled'] = bool(flags & (1 << 1))
        _val_connection_id = reader.tgread_string()
        _args['connection_id'] = _val_connection_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_dc_id = reader.read_int()
        _args['dc_id'] = _val_dc_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 2):
            _val_rights = reader.tgread_object()
            _args['rights'] = _val_rights
        else:
            _args['rights'] = None
        return cls(**_args)


class BotCommand(TLObject):
    """TL type: botCommand"""
    CONSTRUCTOR_ID = 0xc27ac8c7
    SUBCLASS_OF_ID = 0x0e1e62c2

    def __init__(self, command: str, description: str):
        self.command = command
        self.description = description

    def to_dict(self):
        return {
            '_': 'BotCommand',
            'command': self.command,
            'description': self.description,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.command))
        buf.write(TLObject.serialize_bytes(self.description))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_command = reader.tgread_string()
        _args['command'] = _val_command
        _val_description = reader.tgread_string()
        _args['description'] = _val_description
        return cls(**_args)


class BotCommandScopeChatAdmins(TLObject):
    """TL type: botCommandScopeChatAdmins"""
    CONSTRUCTOR_ID = 0xb9aa606a
    SUBCLASS_OF_ID = 0x4baf5d10

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BotCommandScopeChatAdmins',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BotCommandScopeChats(TLObject):
    """TL type: botCommandScopeChats"""
    CONSTRUCTOR_ID = 0x6fe1a881
    SUBCLASS_OF_ID = 0x4baf5d10

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BotCommandScopeChats',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BotCommandScopeDefault(TLObject):
    """TL type: botCommandScopeDefault"""
    CONSTRUCTOR_ID = 0x2f6cb2ab
    SUBCLASS_OF_ID = 0x4baf5d10

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BotCommandScopeDefault',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BotCommandScopePeer(TLObject):
    """TL type: botCommandScopePeer"""
    CONSTRUCTOR_ID = 0xdb9d897d
    SUBCLASS_OF_ID = 0x4baf5d10

    def __init__(self, peer: 'TypeInputPeer'):
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'BotCommandScopePeer',
            'peer': self.peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class BotCommandScopePeerAdmins(TLObject):
    """TL type: botCommandScopePeerAdmins"""
    CONSTRUCTOR_ID = 0x3fd863d1
    SUBCLASS_OF_ID = 0x4baf5d10

    def __init__(self, peer: 'TypeInputPeer'):
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'BotCommandScopePeerAdmins',
            'peer': self.peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class BotCommandScopePeerUser(TLObject):
    """TL type: botCommandScopePeerUser"""
    CONSTRUCTOR_ID = 0x0a1321f3
    SUBCLASS_OF_ID = 0x4baf5d10

    def __init__(self, peer: 'TypeInputPeer', user_id: 'TypeInputUser'):
        self.peer = peer
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'BotCommandScopePeerUser',
            'peer': self.peer,
            'user_id': self.user_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class BotCommandScopeUsers(TLObject):
    """TL type: botCommandScopeUsers"""
    CONSTRUCTOR_ID = 0x3c4f04d8
    SUBCLASS_OF_ID = 0x4baf5d10

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BotCommandScopeUsers',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BotInfo(TLObject):
    """TL type: botInfo"""
    CONSTRUCTOR_ID = 0x4d8a0299
    SUBCLASS_OF_ID = 0xf1f701db

    def __init__(self, has_preview_medias: Optional[bool] = None, user_id: Optional[int] = None, description: Optional[str] = None, description_photo: Optional['TypePhoto'] = None, description_document: Optional['TypeDocument'] = None, commands: Optional[List['TypeBotCommand']] = None, menu_button: Optional['TypeBotMenuButton'] = None, privacy_policy_url: Optional[str] = None, app_settings: Optional['TypeBotAppSettings'] = None, verifier_settings: Optional['TypeBotVerifierSettings'] = None):
        self.has_preview_medias = has_preview_medias
        self.user_id = user_id
        self.description = description
        self.description_photo = description_photo
        self.description_document = description_document
        self.commands = commands
        self.menu_button = menu_button
        self.privacy_policy_url = privacy_policy_url
        self.app_settings = app_settings
        self.verifier_settings = verifier_settings

    def to_dict(self):
        return {
            '_': 'BotInfo',
            'has_preview_medias': self.has_preview_medias,
            'user_id': self.user_id,
            'description': self.description,
            'description_photo': self.description_photo,
            'description_document': self.description_document,
            'commands': self.commands,
            'menu_button': self.menu_button,
            'privacy_policy_url': self.privacy_policy_url,
            'app_settings': self.app_settings,
            'verifier_settings': self.verifier_settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.has_preview_medias:
            flags |= (1 << 6)
        if self.user_id is not None:
            flags |= (1 << 0)
        if self.description is not None:
            flags |= (1 << 1)
        if self.description_photo is not None:
            flags |= (1 << 4)
        if self.description_document is not None:
            flags |= (1 << 5)
        if self.commands is not None:
            flags |= (1 << 2)
        if self.menu_button is not None:
            flags |= (1 << 3)
        if self.privacy_policy_url is not None:
            flags |= (1 << 7)
        if self.app_settings is not None:
            flags |= (1 << 8)
        if self.verifier_settings is not None:
            flags |= (1 << 9)
        buf.write(struct.pack('<I', flags))
        if self.user_id is not None:
            buf.write(struct.pack('<q', self.user_id))
        if self.description is not None:
            buf.write(TLObject.serialize_bytes(self.description))
        if self.description_photo is not None:
            buf.write(bytes(self.description_photo))
        if self.description_document is not None:
            buf.write(bytes(self.description_document))
        if self.commands is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.commands)))
            for item in self.commands:
                buf.write(bytes(self.item))
        if self.menu_button is not None:
            buf.write(bytes(self.menu_button))
        if self.privacy_policy_url is not None:
            buf.write(TLObject.serialize_bytes(self.privacy_policy_url))
        if self.app_settings is not None:
            buf.write(bytes(self.app_settings))
        if self.verifier_settings is not None:
            buf.write(bytes(self.verifier_settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['has_preview_medias'] = bool(flags & (1 << 6))
        if flags & (1 << 0):
            _val_user_id = reader.read_long()
            _args['user_id'] = _val_user_id
        else:
            _args['user_id'] = None
        if flags & (1 << 1):
            _val_description = reader.tgread_string()
            _args['description'] = _val_description
        else:
            _args['description'] = None
        if flags & (1 << 4):
            _val_description_photo = reader.tgread_object()
            _args['description_photo'] = _val_description_photo
        else:
            _args['description_photo'] = None
        if flags & (1 << 5):
            _val_description_document = reader.tgread_object()
            _args['description_document'] = _val_description_document
        else:
            _args['description_document'] = None
        if flags & (1 << 2):
            reader.read_int(signed=False)  # skip vector id
            _count_commands = reader.read_int()
            _list_commands = []
            for _ in range(_count_commands):
                _item_commands = reader.tgread_object()
                _list_commands.append(_item_commands)
            _args['commands'] = _list_commands
        else:
            _args['commands'] = None
        if flags & (1 << 3):
            _val_menu_button = reader.tgread_object()
            _args['menu_button'] = _val_menu_button
        else:
            _args['menu_button'] = None
        if flags & (1 << 7):
            _val_privacy_policy_url = reader.tgread_string()
            _args['privacy_policy_url'] = _val_privacy_policy_url
        else:
            _args['privacy_policy_url'] = None
        if flags & (1 << 8):
            _val_app_settings = reader.tgread_object()
            _args['app_settings'] = _val_app_settings
        else:
            _args['app_settings'] = None
        if flags & (1 << 9):
            _val_verifier_settings = reader.tgread_object()
            _args['verifier_settings'] = _val_verifier_settings
        else:
            _args['verifier_settings'] = None
        return cls(**_args)


class BotInlineMediaResult(TLObject):
    """TL type: botInlineMediaResult"""
    CONSTRUCTOR_ID = 0x17db940b
    SUBCLASS_OF_ID = 0x3832b3d5

    def __init__(self, id: str, type: str, send_message: 'TypeBotInlineMessage', photo: Optional['TypePhoto'] = None, document: Optional['TypeDocument'] = None, title: Optional[str] = None, description: Optional[str] = None):
        self.id = id
        self.type = type
        self.send_message = send_message
        self.photo = photo
        self.document = document
        self.title = title
        self.description = description

    def to_dict(self):
        return {
            '_': 'BotInlineMediaResult',
            'id': self.id,
            'type': self.type,
            'send_message': self.send_message,
            'photo': self.photo,
            'document': self.document,
            'title': self.title,
            'description': self.description,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.photo is not None:
            flags |= (1 << 0)
        if self.document is not None:
            flags |= (1 << 1)
        if self.title is not None:
            flags |= (1 << 2)
        if self.description is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(bytes(self.send_message))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        if self.document is not None:
            buf.write(bytes(self.document))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.description is not None:
            buf.write(TLObject.serialize_bytes(self.description))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        if flags & (1 << 0):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        if flags & (1 << 1):
            _val_document = reader.tgread_object()
            _args['document'] = _val_document
        else:
            _args['document'] = None
        if flags & (1 << 2):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 3):
            _val_description = reader.tgread_string()
            _args['description'] = _val_description
        else:
            _args['description'] = None
        _val_send_message = reader.tgread_object()
        _args['send_message'] = _val_send_message
        return cls(**_args)


class BotInlineMessageMediaAuto(TLObject):
    """TL type: botInlineMessageMediaAuto"""
    CONSTRUCTOR_ID = 0x764cf810
    SUBCLASS_OF_ID = 0xc4910f88

    def __init__(self, message: str, invert_media: Optional[bool] = None, entities: Optional[List['TypeMessageEntity']] = None, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.message = message
        self.invert_media = invert_media
        self.entities = entities
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'BotInlineMessageMediaAuto',
            'message': self.message,
            'invert_media': self.invert_media,
            'entities': self.entities,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.invert_media:
            flags |= (1 << 3)
        if self.entities is not None:
            flags |= (1 << 1)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.message))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['invert_media'] = bool(flags & (1 << 3))
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class BotInlineMessageMediaContact(TLObject):
    """TL type: botInlineMessageMediaContact"""
    CONSTRUCTOR_ID = 0x18d1cdc2
    SUBCLASS_OF_ID = 0xc4910f88

    def __init__(self, phone_number: str, first_name: str, last_name: str, vcard: str, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.phone_number = phone_number
        self.first_name = first_name
        self.last_name = last_name
        self.vcard = vcard
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'BotInlineMessageMediaContact',
            'phone_number': self.phone_number,
            'first_name': self.first_name,
            'last_name': self.last_name,
            'vcard': self.vcard,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.first_name))
        buf.write(TLObject.serialize_bytes(self.last_name))
        buf.write(TLObject.serialize_bytes(self.vcard))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_first_name = reader.tgread_string()
        _args['first_name'] = _val_first_name
        _val_last_name = reader.tgread_string()
        _args['last_name'] = _val_last_name
        _val_vcard = reader.tgread_string()
        _args['vcard'] = _val_vcard
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class BotInlineMessageMediaGeo(TLObject):
    """TL type: botInlineMessageMediaGeo"""
    CONSTRUCTOR_ID = 0x051846fd
    SUBCLASS_OF_ID = 0xc4910f88

    def __init__(self, geo: 'TypeGeoPoint', heading: Optional[int] = None, period: Optional[int] = None, proximity_notification_radius: Optional[int] = None, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.geo = geo
        self.heading = heading
        self.period = period
        self.proximity_notification_radius = proximity_notification_radius
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'BotInlineMessageMediaGeo',
            'geo': self.geo,
            'heading': self.heading,
            'period': self.period,
            'proximity_notification_radius': self.proximity_notification_radius,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.heading is not None:
            flags |= (1 << 0)
        if self.period is not None:
            flags |= (1 << 1)
        if self.proximity_notification_radius is not None:
            flags |= (1 << 3)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.geo))
        if self.heading is not None:
            buf.write(struct.pack('<i', self.heading))
        if self.period is not None:
            buf.write(struct.pack('<i', self.period))
        if self.proximity_notification_radius is not None:
            buf.write(struct.pack('<i', self.proximity_notification_radius))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_geo = reader.tgread_object()
        _args['geo'] = _val_geo
        if flags & (1 << 0):
            _val_heading = reader.read_int()
            _args['heading'] = _val_heading
        else:
            _args['heading'] = None
        if flags & (1 << 1):
            _val_period = reader.read_int()
            _args['period'] = _val_period
        else:
            _args['period'] = None
        if flags & (1 << 3):
            _val_proximity_notification_radius = reader.read_int()
            _args['proximity_notification_radius'] = _val_proximity_notification_radius
        else:
            _args['proximity_notification_radius'] = None
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class BotInlineMessageMediaInvoice(TLObject):
    """TL type: botInlineMessageMediaInvoice"""
    CONSTRUCTOR_ID = 0x354a9b09
    SUBCLASS_OF_ID = 0xc4910f88

    def __init__(self, title: str, description: str, currency: str, total_amount: int, shipping_address_requested: Optional[bool] = None, test: Optional[bool] = None, photo: Optional['TypeWebDocument'] = None, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.title = title
        self.description = description
        self.currency = currency
        self.total_amount = total_amount
        self.shipping_address_requested = shipping_address_requested
        self.test = test
        self.photo = photo
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'BotInlineMessageMediaInvoice',
            'title': self.title,
            'description': self.description,
            'currency': self.currency,
            'total_amount': self.total_amount,
            'shipping_address_requested': self.shipping_address_requested,
            'test': self.test,
            'photo': self.photo,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.shipping_address_requested:
            flags |= (1 << 1)
        if self.test:
            flags |= (1 << 3)
        if self.photo is not None:
            flags |= (1 << 0)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.description))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.total_amount))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['shipping_address_requested'] = bool(flags & (1 << 1))
        _args['test'] = bool(flags & (1 << 3))
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_description = reader.tgread_string()
        _args['description'] = _val_description
        if flags & (1 << 0):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_total_amount = reader.read_long()
        _args['total_amount'] = _val_total_amount
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class BotInlineMessageMediaVenue(TLObject):
    """TL type: botInlineMessageMediaVenue"""
    CONSTRUCTOR_ID = 0x8a86659c
    SUBCLASS_OF_ID = 0xc4910f88

    def __init__(self, geo: 'TypeGeoPoint', title: str, address: str, provider: str, venue_id: str, venue_type: str, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.geo = geo
        self.title = title
        self.address = address
        self.provider = provider
        self.venue_id = venue_id
        self.venue_type = venue_type
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'BotInlineMessageMediaVenue',
            'geo': self.geo,
            'title': self.title,
            'address': self.address,
            'provider': self.provider,
            'venue_id': self.venue_id,
            'venue_type': self.venue_type,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.geo))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.address))
        buf.write(TLObject.serialize_bytes(self.provider))
        buf.write(TLObject.serialize_bytes(self.venue_id))
        buf.write(TLObject.serialize_bytes(self.venue_type))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_geo = reader.tgread_object()
        _args['geo'] = _val_geo
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_address = reader.tgread_string()
        _args['address'] = _val_address
        _val_provider = reader.tgread_string()
        _args['provider'] = _val_provider
        _val_venue_id = reader.tgread_string()
        _args['venue_id'] = _val_venue_id
        _val_venue_type = reader.tgread_string()
        _args['venue_type'] = _val_venue_type
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class BotInlineMessageMediaWebPage(TLObject):
    """TL type: botInlineMessageMediaWebPage"""
    CONSTRUCTOR_ID = 0x809ad9a6
    SUBCLASS_OF_ID = 0xc4910f88

    def __init__(self, message: str, url: str, invert_media: Optional[bool] = None, force_large_media: Optional[bool] = None, force_small_media: Optional[bool] = None, manual: Optional[bool] = None, safe: Optional[bool] = None, entities: Optional[List['TypeMessageEntity']] = None, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.message = message
        self.url = url
        self.invert_media = invert_media
        self.force_large_media = force_large_media
        self.force_small_media = force_small_media
        self.manual = manual
        self.safe = safe
        self.entities = entities
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'BotInlineMessageMediaWebPage',
            'message': self.message,
            'url': self.url,
            'invert_media': self.invert_media,
            'force_large_media': self.force_large_media,
            'force_small_media': self.force_small_media,
            'manual': self.manual,
            'safe': self.safe,
            'entities': self.entities,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.invert_media:
            flags |= (1 << 3)
        if self.force_large_media:
            flags |= (1 << 4)
        if self.force_small_media:
            flags |= (1 << 5)
        if self.manual:
            flags |= (1 << 7)
        if self.safe:
            flags |= (1 << 8)
        if self.entities is not None:
            flags |= (1 << 1)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.message))
        buf.write(TLObject.serialize_bytes(self.url))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['invert_media'] = bool(flags & (1 << 3))
        _args['force_large_media'] = bool(flags & (1 << 4))
        _args['force_small_media'] = bool(flags & (1 << 5))
        _args['manual'] = bool(flags & (1 << 7))
        _args['safe'] = bool(flags & (1 << 8))
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class BotInlineMessageText(TLObject):
    """TL type: botInlineMessageText"""
    CONSTRUCTOR_ID = 0x8c7f65e2
    SUBCLASS_OF_ID = 0xc4910f88

    def __init__(self, message: str, no_webpage: Optional[bool] = None, invert_media: Optional[bool] = None, entities: Optional[List['TypeMessageEntity']] = None, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.message = message
        self.no_webpage = no_webpage
        self.invert_media = invert_media
        self.entities = entities
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'BotInlineMessageText',
            'message': self.message,
            'no_webpage': self.no_webpage,
            'invert_media': self.invert_media,
            'entities': self.entities,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.no_webpage:
            flags |= (1 << 0)
        if self.invert_media:
            flags |= (1 << 3)
        if self.entities is not None:
            flags |= (1 << 1)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.message))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['no_webpage'] = bool(flags & (1 << 0))
        _args['invert_media'] = bool(flags & (1 << 3))
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class BotInlineResult(TLObject):
    """TL type: botInlineResult"""
    CONSTRUCTOR_ID = 0x11965f3a
    SUBCLASS_OF_ID = 0x3832b3d5

    def __init__(self, id: str, type: str, send_message: 'TypeBotInlineMessage', title: Optional[str] = None, description: Optional[str] = None, url: Optional[str] = None, thumb: Optional['TypeWebDocument'] = None, content: Optional['TypeWebDocument'] = None):
        self.id = id
        self.type = type
        self.send_message = send_message
        self.title = title
        self.description = description
        self.url = url
        self.thumb = thumb
        self.content = content

    def to_dict(self):
        return {
            '_': 'BotInlineResult',
            'id': self.id,
            'type': self.type,
            'send_message': self.send_message,
            'title': self.title,
            'description': self.description,
            'url': self.url,
            'thumb': self.thumb,
            'content': self.content,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.title is not None:
            flags |= (1 << 1)
        if self.description is not None:
            flags |= (1 << 2)
        if self.url is not None:
            flags |= (1 << 3)
        if self.thumb is not None:
            flags |= (1 << 4)
        if self.content is not None:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(bytes(self.send_message))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.description is not None:
            buf.write(TLObject.serialize_bytes(self.description))
        if self.url is not None:
            buf.write(TLObject.serialize_bytes(self.url))
        if self.thumb is not None:
            buf.write(bytes(self.thumb))
        if self.content is not None:
            buf.write(bytes(self.content))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        if flags & (1 << 1):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 2):
            _val_description = reader.tgread_string()
            _args['description'] = _val_description
        else:
            _args['description'] = None
        if flags & (1 << 3):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        if flags & (1 << 4):
            _val_thumb = reader.tgread_object()
            _args['thumb'] = _val_thumb
        else:
            _args['thumb'] = None
        if flags & (1 << 5):
            _val_content = reader.tgread_object()
            _args['content'] = _val_content
        else:
            _args['content'] = None
        _val_send_message = reader.tgread_object()
        _args['send_message'] = _val_send_message
        return cls(**_args)


class BotMenuButton(TLObject):
    """TL type: botMenuButton"""
    CONSTRUCTOR_ID = 0xc7b57ce6
    SUBCLASS_OF_ID = 0x4c71bd3c

    def __init__(self, text: str, url: str):
        self.text = text
        self.url = url

    def to_dict(self):
        return {
            '_': 'BotMenuButton',
            'text': self.text,
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class BotMenuButtonCommands(TLObject):
    """TL type: botMenuButtonCommands"""
    CONSTRUCTOR_ID = 0x4258c205
    SUBCLASS_OF_ID = 0x4c71bd3c

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BotMenuButtonCommands',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BotMenuButtonDefault(TLObject):
    """TL type: botMenuButtonDefault"""
    CONSTRUCTOR_ID = 0x7533a588
    SUBCLASS_OF_ID = 0x4c71bd3c

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BotMenuButtonDefault',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BotPreviewMedia(TLObject):
    """TL type: botPreviewMedia"""
    CONSTRUCTOR_ID = 0x23e91ba3
    SUBCLASS_OF_ID = 0x562abc2d

    def __init__(self, date: Optional[datetime], media: 'TypeMessageMedia'):
        self.date = date
        self.media = media

    def to_dict(self):
        return {
            '_': 'BotPreviewMedia',
            'date': self.date,
            'media': self.media,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.date))
        buf.write(bytes(self.media))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_media = reader.tgread_object()
        _args['media'] = _val_media
        return cls(**_args)


class BotVerification(TLObject):
    """TL type: botVerification"""
    CONSTRUCTOR_ID = 0xf93cd45c
    SUBCLASS_OF_ID = 0x2cbf3c5a

    def __init__(self, bot_id: int, icon: int, description: str):
        self.bot_id = bot_id
        self.icon = icon
        self.description = description

    def to_dict(self):
        return {
            '_': 'BotVerification',
            'bot_id': self.bot_id,
            'icon': self.icon,
            'description': self.description,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.bot_id))
        buf.write(struct.pack('<q', self.icon))
        buf.write(TLObject.serialize_bytes(self.description))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot_id = reader.read_long()
        _args['bot_id'] = _val_bot_id
        _val_icon = reader.read_long()
        _args['icon'] = _val_icon
        _val_description = reader.tgread_string()
        _args['description'] = _val_description
        return cls(**_args)


class BotVerifierSettings(TLObject):
    """TL type: botVerifierSettings"""
    CONSTRUCTOR_ID = 0xb0cd6617
    SUBCLASS_OF_ID = 0xf1d6034c

    def __init__(self, icon: int, company: str, can_modify_custom_description: Optional[bool] = None, custom_description: Optional[str] = None):
        self.icon = icon
        self.company = company
        self.can_modify_custom_description = can_modify_custom_description
        self.custom_description = custom_description

    def to_dict(self):
        return {
            '_': 'BotVerifierSettings',
            'icon': self.icon,
            'company': self.company,
            'can_modify_custom_description': self.can_modify_custom_description,
            'custom_description': self.custom_description,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.can_modify_custom_description:
            flags |= (1 << 1)
        if self.custom_description is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.icon))
        buf.write(TLObject.serialize_bytes(self.company))
        if self.custom_description is not None:
            buf.write(TLObject.serialize_bytes(self.custom_description))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['can_modify_custom_description'] = bool(flags & (1 << 1))
        _val_icon = reader.read_long()
        _args['icon'] = _val_icon
        _val_company = reader.tgread_string()
        _args['company'] = _val_company
        if flags & (1 << 0):
            _val_custom_description = reader.tgread_string()
            _args['custom_description'] = _val_custom_description
        else:
            _args['custom_description'] = None
        return cls(**_args)


class BusinessAwayMessage(TLObject):
    """TL type: businessAwayMessage"""
    CONSTRUCTOR_ID = 0xef156a5c
    SUBCLASS_OF_ID = 0xf1d3ae24

    def __init__(self, shortcut_id: int, schedule: 'TypeBusinessAwayMessageSchedule', recipients: 'TypeBusinessRecipients', offline_only: Optional[bool] = None):
        self.shortcut_id = shortcut_id
        self.schedule = schedule
        self.recipients = recipients
        self.offline_only = offline_only

    def to_dict(self):
        return {
            '_': 'BusinessAwayMessage',
            'shortcut_id': self.shortcut_id,
            'schedule': self.schedule,
            'recipients': self.recipients,
            'offline_only': self.offline_only,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.offline_only:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.shortcut_id))
        buf.write(bytes(self.schedule))
        buf.write(bytes(self.recipients))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['offline_only'] = bool(flags & (1 << 0))
        _val_shortcut_id = reader.read_int()
        _args['shortcut_id'] = _val_shortcut_id
        _val_schedule = reader.tgread_object()
        _args['schedule'] = _val_schedule
        _val_recipients = reader.tgread_object()
        _args['recipients'] = _val_recipients
        return cls(**_args)


class BusinessAwayMessageScheduleAlways(TLObject):
    """TL type: businessAwayMessageScheduleAlways"""
    CONSTRUCTOR_ID = 0xc9b9e2b9
    SUBCLASS_OF_ID = 0x2818a05e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BusinessAwayMessageScheduleAlways',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BusinessAwayMessageScheduleCustom(TLObject):
    """TL type: businessAwayMessageScheduleCustom"""
    CONSTRUCTOR_ID = 0xcc4d9ecc
    SUBCLASS_OF_ID = 0x2818a05e

    def __init__(self, start_date: Optional[datetime], end_date: Optional[datetime]):
        self.start_date = start_date
        self.end_date = end_date

    def to_dict(self):
        return {
            '_': 'BusinessAwayMessageScheduleCustom',
            'start_date': self.start_date,
            'end_date': self.end_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.start_date))
        buf.write(struct.pack('<i', self.end_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_start_date = reader.read_int()
        _args['start_date'] = _val_start_date
        _val_end_date = reader.read_int()
        _args['end_date'] = _val_end_date
        return cls(**_args)


class BusinessAwayMessageScheduleOutsideWorkHours(TLObject):
    """TL type: businessAwayMessageScheduleOutsideWorkHours"""
    CONSTRUCTOR_ID = 0xc3f2f501
    SUBCLASS_OF_ID = 0x2818a05e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'BusinessAwayMessageScheduleOutsideWorkHours',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class BusinessBotRecipients(TLObject):
    """TL type: businessBotRecipients"""
    CONSTRUCTOR_ID = 0xb88cf373
    SUBCLASS_OF_ID = 0xf09283ca

    def __init__(self, existing_chats: Optional[bool] = None, new_chats: Optional[bool] = None, contacts: Optional[bool] = None, non_contacts: Optional[bool] = None, exclude_selected: Optional[bool] = None, users: Optional[List[int]] = None, exclude_users: Optional[List[int]] = None):
        self.existing_chats = existing_chats
        self.new_chats = new_chats
        self.contacts = contacts
        self.non_contacts = non_contacts
        self.exclude_selected = exclude_selected
        self.users = users
        self.exclude_users = exclude_users

    def to_dict(self):
        return {
            '_': 'BusinessBotRecipients',
            'existing_chats': self.existing_chats,
            'new_chats': self.new_chats,
            'contacts': self.contacts,
            'non_contacts': self.non_contacts,
            'exclude_selected': self.exclude_selected,
            'users': self.users,
            'exclude_users': self.exclude_users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.existing_chats:
            flags |= (1 << 0)
        if self.new_chats:
            flags |= (1 << 1)
        if self.contacts:
            flags |= (1 << 2)
        if self.non_contacts:
            flags |= (1 << 3)
        if self.exclude_selected:
            flags |= (1 << 5)
        if self.users is not None:
            flags |= (1 << 4)
        if self.exclude_users is not None:
            flags |= (1 << 6)
        buf.write(struct.pack('<I', flags))
        if self.users is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.users)))
            for item in self.users:
                buf.write(struct.pack('<q', self.item))
        if self.exclude_users is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.exclude_users)))
            for item in self.exclude_users:
                buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['existing_chats'] = bool(flags & (1 << 0))
        _args['new_chats'] = bool(flags & (1 << 1))
        _args['contacts'] = bool(flags & (1 << 2))
        _args['non_contacts'] = bool(flags & (1 << 3))
        _args['exclude_selected'] = bool(flags & (1 << 5))
        if flags & (1 << 4):
            reader.read_int(signed=False)  # skip vector id
            _count_users = reader.read_int()
            _list_users = []
            for _ in range(_count_users):
                _item_users = reader.read_long()
                _list_users.append(_item_users)
            _args['users'] = _list_users
        else:
            _args['users'] = None
        if flags & (1 << 6):
            reader.read_int(signed=False)  # skip vector id
            _count_exclude_users = reader.read_int()
            _list_exclude_users = []
            for _ in range(_count_exclude_users):
                _item_exclude_users = reader.read_long()
                _list_exclude_users.append(_item_exclude_users)
            _args['exclude_users'] = _list_exclude_users
        else:
            _args['exclude_users'] = None
        return cls(**_args)


class BusinessBotRights(TLObject):
    """TL type: businessBotRights"""
    CONSTRUCTOR_ID = 0xa0624cf7
    SUBCLASS_OF_ID = 0xb8dc759a

    def __init__(self, reply: Optional[bool] = None, read_messages: Optional[bool] = None, delete_sent_messages: Optional[bool] = None, delete_received_messages: Optional[bool] = None, edit_name: Optional[bool] = None, edit_bio: Optional[bool] = None, edit_profile_photo: Optional[bool] = None, edit_username: Optional[bool] = None, view_gifts: Optional[bool] = None, sell_gifts: Optional[bool] = None, change_gift_settings: Optional[bool] = None, transfer_and_upgrade_gifts: Optional[bool] = None, transfer_stars: Optional[bool] = None, manage_stories: Optional[bool] = None):
        self.reply = reply
        self.read_messages = read_messages
        self.delete_sent_messages = delete_sent_messages
        self.delete_received_messages = delete_received_messages
        self.edit_name = edit_name
        self.edit_bio = edit_bio
        self.edit_profile_photo = edit_profile_photo
        self.edit_username = edit_username
        self.view_gifts = view_gifts
        self.sell_gifts = sell_gifts
        self.change_gift_settings = change_gift_settings
        self.transfer_and_upgrade_gifts = transfer_and_upgrade_gifts
        self.transfer_stars = transfer_stars
        self.manage_stories = manage_stories

    def to_dict(self):
        return {
            '_': 'BusinessBotRights',
            'reply': self.reply,
            'read_messages': self.read_messages,
            'delete_sent_messages': self.delete_sent_messages,
            'delete_received_messages': self.delete_received_messages,
            'edit_name': self.edit_name,
            'edit_bio': self.edit_bio,
            'edit_profile_photo': self.edit_profile_photo,
            'edit_username': self.edit_username,
            'view_gifts': self.view_gifts,
            'sell_gifts': self.sell_gifts,
            'change_gift_settings': self.change_gift_settings,
            'transfer_and_upgrade_gifts': self.transfer_and_upgrade_gifts,
            'transfer_stars': self.transfer_stars,
            'manage_stories': self.manage_stories,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reply:
            flags |= (1 << 0)
        if self.read_messages:
            flags |= (1 << 1)
        if self.delete_sent_messages:
            flags |= (1 << 2)
        if self.delete_received_messages:
            flags |= (1 << 3)
        if self.edit_name:
            flags |= (1 << 4)
        if self.edit_bio:
            flags |= (1 << 5)
        if self.edit_profile_photo:
            flags |= (1 << 6)
        if self.edit_username:
            flags |= (1 << 7)
        if self.view_gifts:
            flags |= (1 << 8)
        if self.sell_gifts:
            flags |= (1 << 9)
        if self.change_gift_settings:
            flags |= (1 << 10)
        if self.transfer_and_upgrade_gifts:
            flags |= (1 << 11)
        if self.transfer_stars:
            flags |= (1 << 12)
        if self.manage_stories:
            flags |= (1 << 13)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['reply'] = bool(flags & (1 << 0))
        _args['read_messages'] = bool(flags & (1 << 1))
        _args['delete_sent_messages'] = bool(flags & (1 << 2))
        _args['delete_received_messages'] = bool(flags & (1 << 3))
        _args['edit_name'] = bool(flags & (1 << 4))
        _args['edit_bio'] = bool(flags & (1 << 5))
        _args['edit_profile_photo'] = bool(flags & (1 << 6))
        _args['edit_username'] = bool(flags & (1 << 7))
        _args['view_gifts'] = bool(flags & (1 << 8))
        _args['sell_gifts'] = bool(flags & (1 << 9))
        _args['change_gift_settings'] = bool(flags & (1 << 10))
        _args['transfer_and_upgrade_gifts'] = bool(flags & (1 << 11))
        _args['transfer_stars'] = bool(flags & (1 << 12))
        _args['manage_stories'] = bool(flags & (1 << 13))
        return cls(**_args)


class BusinessChatLink(TLObject):
    """TL type: businessChatLink"""
    CONSTRUCTOR_ID = 0xb4ae666f
    SUBCLASS_OF_ID = 0x3c0d4a8b

    def __init__(self, link: str, message: str, views: int, entities: Optional[List['TypeMessageEntity']] = None, title: Optional[str] = None):
        self.link = link
        self.message = message
        self.views = views
        self.entities = entities
        self.title = title

    def to_dict(self):
        return {
            '_': 'BusinessChatLink',
            'link': self.link,
            'message': self.message,
            'views': self.views,
            'entities': self.entities,
            'title': self.title,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.entities is not None:
            flags |= (1 << 0)
        if self.title is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.link))
        buf.write(TLObject.serialize_bytes(self.message))
        buf.write(struct.pack('<i', self.views))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_link = reader.tgread_string()
        _args['link'] = _val_link
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 1):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        _val_views = reader.read_int()
        _args['views'] = _val_views
        return cls(**_args)


class BusinessGreetingMessage(TLObject):
    """TL type: businessGreetingMessage"""
    CONSTRUCTOR_ID = 0xe519abab
    SUBCLASS_OF_ID = 0xb344eace

    def __init__(self, shortcut_id: int, recipients: 'TypeBusinessRecipients', no_activity_days: int):
        self.shortcut_id = shortcut_id
        self.recipients = recipients
        self.no_activity_days = no_activity_days

    def to_dict(self):
        return {
            '_': 'BusinessGreetingMessage',
            'shortcut_id': self.shortcut_id,
            'recipients': self.recipients,
            'no_activity_days': self.no_activity_days,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.shortcut_id))
        buf.write(bytes(self.recipients))
        buf.write(struct.pack('<i', self.no_activity_days))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_shortcut_id = reader.read_int()
        _args['shortcut_id'] = _val_shortcut_id
        _val_recipients = reader.tgread_object()
        _args['recipients'] = _val_recipients
        _val_no_activity_days = reader.read_int()
        _args['no_activity_days'] = _val_no_activity_days
        return cls(**_args)


class BusinessIntro(TLObject):
    """TL type: businessIntro"""
    CONSTRUCTOR_ID = 0x5a0a066d
    SUBCLASS_OF_ID = 0x6504d3c7

    def __init__(self, title: str, description: str, sticker: Optional['TypeDocument'] = None):
        self.title = title
        self.description = description
        self.sticker = sticker

    def to_dict(self):
        return {
            '_': 'BusinessIntro',
            'title': self.title,
            'description': self.description,
            'sticker': self.sticker,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.sticker is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.description))
        if self.sticker is not None:
            buf.write(bytes(self.sticker))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_description = reader.tgread_string()
        _args['description'] = _val_description
        if flags & (1 << 0):
            _val_sticker = reader.tgread_object()
            _args['sticker'] = _val_sticker
        else:
            _args['sticker'] = None
        return cls(**_args)


class BusinessLocation(TLObject):
    """TL type: businessLocation"""
    CONSTRUCTOR_ID = 0xac5c1af7
    SUBCLASS_OF_ID = 0x99accad0

    def __init__(self, address: str, geo_point: Optional['TypeGeoPoint'] = None):
        self.address = address
        self.geo_point = geo_point

    def to_dict(self):
        return {
            '_': 'BusinessLocation',
            'address': self.address,
            'geo_point': self.geo_point,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.geo_point is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.address))
        if self.geo_point is not None:
            buf.write(bytes(self.geo_point))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_geo_point = reader.tgread_object()
            _args['geo_point'] = _val_geo_point
        else:
            _args['geo_point'] = None
        _val_address = reader.tgread_string()
        _args['address'] = _val_address
        return cls(**_args)


class BusinessRecipients(TLObject):
    """TL type: businessRecipients"""
    CONSTRUCTOR_ID = 0x21108ff7
    SUBCLASS_OF_ID = 0x52852e46

    def __init__(self, existing_chats: Optional[bool] = None, new_chats: Optional[bool] = None, contacts: Optional[bool] = None, non_contacts: Optional[bool] = None, exclude_selected: Optional[bool] = None, users: Optional[List[int]] = None):
        self.existing_chats = existing_chats
        self.new_chats = new_chats
        self.contacts = contacts
        self.non_contacts = non_contacts
        self.exclude_selected = exclude_selected
        self.users = users

    def to_dict(self):
        return {
            '_': 'BusinessRecipients',
            'existing_chats': self.existing_chats,
            'new_chats': self.new_chats,
            'contacts': self.contacts,
            'non_contacts': self.non_contacts,
            'exclude_selected': self.exclude_selected,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.existing_chats:
            flags |= (1 << 0)
        if self.new_chats:
            flags |= (1 << 1)
        if self.contacts:
            flags |= (1 << 2)
        if self.non_contacts:
            flags |= (1 << 3)
        if self.exclude_selected:
            flags |= (1 << 5)
        if self.users is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        if self.users is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.users)))
            for item in self.users:
                buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['existing_chats'] = bool(flags & (1 << 0))
        _args['new_chats'] = bool(flags & (1 << 1))
        _args['contacts'] = bool(flags & (1 << 2))
        _args['non_contacts'] = bool(flags & (1 << 3))
        _args['exclude_selected'] = bool(flags & (1 << 5))
        if flags & (1 << 4):
            reader.read_int(signed=False)  # skip vector id
            _count_users = reader.read_int()
            _list_users = []
            for _ in range(_count_users):
                _item_users = reader.read_long()
                _list_users.append(_item_users)
            _args['users'] = _list_users
        else:
            _args['users'] = None
        return cls(**_args)


class BusinessWeeklyOpen(TLObject):
    """TL type: businessWeeklyOpen"""
    CONSTRUCTOR_ID = 0x120b1ab9
    SUBCLASS_OF_ID = 0x18402627

    def __init__(self, start_minute: int, end_minute: int):
        self.start_minute = start_minute
        self.end_minute = end_minute

    def to_dict(self):
        return {
            '_': 'BusinessWeeklyOpen',
            'start_minute': self.start_minute,
            'end_minute': self.end_minute,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.start_minute))
        buf.write(struct.pack('<i', self.end_minute))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_start_minute = reader.read_int()
        _args['start_minute'] = _val_start_minute
        _val_end_minute = reader.read_int()
        _args['end_minute'] = _val_end_minute
        return cls(**_args)


class BusinessWorkHours(TLObject):
    """TL type: businessWorkHours"""
    CONSTRUCTOR_ID = 0x8c92b098
    SUBCLASS_OF_ID = 0x659fa805

    def __init__(self, timezone_id: str, weekly_open: List['TypeBusinessWeeklyOpen'], open_now: Optional[bool] = None):
        self.timezone_id = timezone_id
        self.weekly_open = weekly_open
        self.open_now = open_now

    def to_dict(self):
        return {
            '_': 'BusinessWorkHours',
            'timezone_id': self.timezone_id,
            'weekly_open': self.weekly_open,
            'open_now': self.open_now,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.open_now:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.timezone_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.weekly_open)))
        for item in self.weekly_open:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['open_now'] = bool(flags & (1 << 0))
        _val_timezone_id = reader.tgread_string()
        _args['timezone_id'] = _val_timezone_id
        reader.read_int(signed=False)  # skip vector id
        _count_weekly_open = reader.read_int()
        _list_weekly_open = []
        for _ in range(_count_weekly_open):
            _item_weekly_open = reader.tgread_object()
            _list_weekly_open.append(_item_weekly_open)
        _args['weekly_open'] = _list_weekly_open
        return cls(**_args)


class CdnConfig(TLObject):
    """TL type: cdnConfig"""
    CONSTRUCTOR_ID = 0x5725e40a
    SUBCLASS_OF_ID = 0xecda397c

    def __init__(self, public_keys: List['TypeCdnPublicKey']):
        self.public_keys = public_keys

    def to_dict(self):
        return {
            '_': 'CdnConfig',
            'public_keys': self.public_keys,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.public_keys)))
        for item in self.public_keys:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_public_keys = reader.read_int()
        _list_public_keys = []
        for _ in range(_count_public_keys):
            _item_public_keys = reader.tgread_object()
            _list_public_keys.append(_item_public_keys)
        _args['public_keys'] = _list_public_keys
        return cls(**_args)


class CdnPublicKey(TLObject):
    """TL type: cdnPublicKey"""
    CONSTRUCTOR_ID = 0xc982eaba
    SUBCLASS_OF_ID = 0x16db47f3

    def __init__(self, dc_id: int, public_key: str):
        self.dc_id = dc_id
        self.public_key = public_key

    def to_dict(self):
        return {
            '_': 'CdnPublicKey',
            'dc_id': self.dc_id,
            'public_key': self.public_key,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.dc_id))
        buf.write(TLObject.serialize_bytes(self.public_key))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_dc_id = reader.read_int()
        _args['dc_id'] = _val_dc_id
        _val_public_key = reader.tgread_string()
        _args['public_key'] = _val_public_key
        return cls(**_args)


class Channel(TLObject):
    """TL type: channel"""
    CONSTRUCTOR_ID = 0x1c32b11c
    SUBCLASS_OF_ID = 0xc5af5d94

    def __init__(self, id: int, title: str, photo: 'TypeChatPhoto', date: Optional[datetime], creator: Optional[bool] = None, left: Optional[bool] = None, broadcast: Optional[bool] = None, verified: Optional[bool] = None, megagroup: Optional[bool] = None, restricted: Optional[bool] = None, signatures: Optional[bool] = None, min: Optional[bool] = None, scam: Optional[bool] = None, has_link: Optional[bool] = None, has_geo: Optional[bool] = None, slowmode_enabled: Optional[bool] = None, call_active: Optional[bool] = None, call_not_empty: Optional[bool] = None, fake: Optional[bool] = None, gigagroup: Optional[bool] = None, noforwards: Optional[bool] = None, join_to_send: Optional[bool] = None, join_request: Optional[bool] = None, forum: Optional[bool] = None, stories_hidden: Optional[bool] = None, stories_hidden_min: Optional[bool] = None, stories_unavailable: Optional[bool] = None, signature_profiles: Optional[bool] = None, autotranslation: Optional[bool] = None, broadcast_messages_allowed: Optional[bool] = None, monoforum: Optional[bool] = None, forum_tabs: Optional[bool] = None, access_hash: Optional[int] = None, username: Optional[str] = None, restriction_reason: Optional[List['TypeRestrictionReason']] = None, admin_rights: Optional['TypeChatAdminRights'] = None, banned_rights: Optional['TypeChatBannedRights'] = None, default_banned_rights: Optional['TypeChatBannedRights'] = None, participants_count: Optional[int] = None, usernames: Optional[List['TypeUsername']] = None, stories_max_id: Optional['TypeRecentStory'] = None, color: Optional['TypePeerColor'] = None, profile_color: Optional['TypePeerColor'] = None, emoji_status: Optional['TypeEmojiStatus'] = None, level: Optional[int] = None, subscription_until_date: Optional[datetime] = None, bot_verification_icon: Optional[int] = None, send_paid_messages_stars: Optional[int] = None, linked_monoforum_id: Optional[int] = None):
        self.id = id
        self.title = title
        self.photo = photo
        self.date = date
        self.creator = creator
        self.left = left
        self.broadcast = broadcast
        self.verified = verified
        self.megagroup = megagroup
        self.restricted = restricted
        self.signatures = signatures
        self.min = min
        self.scam = scam
        self.has_link = has_link
        self.has_geo = has_geo
        self.slowmode_enabled = slowmode_enabled
        self.call_active = call_active
        self.call_not_empty = call_not_empty
        self.fake = fake
        self.gigagroup = gigagroup
        self.noforwards = noforwards
        self.join_to_send = join_to_send
        self.join_request = join_request
        self.forum = forum
        self.stories_hidden = stories_hidden
        self.stories_hidden_min = stories_hidden_min
        self.stories_unavailable = stories_unavailable
        self.signature_profiles = signature_profiles
        self.autotranslation = autotranslation
        self.broadcast_messages_allowed = broadcast_messages_allowed
        self.monoforum = monoforum
        self.forum_tabs = forum_tabs
        self.access_hash = access_hash
        self.username = username
        self.restriction_reason = restriction_reason
        self.admin_rights = admin_rights
        self.banned_rights = banned_rights
        self.default_banned_rights = default_banned_rights
        self.participants_count = participants_count
        self.usernames = usernames
        self.stories_max_id = stories_max_id
        self.color = color
        self.profile_color = profile_color
        self.emoji_status = emoji_status
        self.level = level
        self.subscription_until_date = subscription_until_date
        self.bot_verification_icon = bot_verification_icon
        self.send_paid_messages_stars = send_paid_messages_stars
        self.linked_monoforum_id = linked_monoforum_id

    def to_dict(self):
        return {
            '_': 'Channel',
            'id': self.id,
            'title': self.title,
            'photo': self.photo,
            'date': self.date,
            'creator': self.creator,
            'left': self.left,
            'broadcast': self.broadcast,
            'verified': self.verified,
            'megagroup': self.megagroup,
            'restricted': self.restricted,
            'signatures': self.signatures,
            'min': self.min,
            'scam': self.scam,
            'has_link': self.has_link,
            'has_geo': self.has_geo,
            'slowmode_enabled': self.slowmode_enabled,
            'call_active': self.call_active,
            'call_not_empty': self.call_not_empty,
            'fake': self.fake,
            'gigagroup': self.gigagroup,
            'noforwards': self.noforwards,
            'join_to_send': self.join_to_send,
            'join_request': self.join_request,
            'forum': self.forum,
            'stories_hidden': self.stories_hidden,
            'stories_hidden_min': self.stories_hidden_min,
            'stories_unavailable': self.stories_unavailable,
            'signature_profiles': self.signature_profiles,
            'autotranslation': self.autotranslation,
            'broadcast_messages_allowed': self.broadcast_messages_allowed,
            'monoforum': self.monoforum,
            'forum_tabs': self.forum_tabs,
            'access_hash': self.access_hash,
            'username': self.username,
            'restriction_reason': self.restriction_reason,
            'admin_rights': self.admin_rights,
            'banned_rights': self.banned_rights,
            'default_banned_rights': self.default_banned_rights,
            'participants_count': self.participants_count,
            'usernames': self.usernames,
            'stories_max_id': self.stories_max_id,
            'color': self.color,
            'profile_color': self.profile_color,
            'emoji_status': self.emoji_status,
            'level': self.level,
            'subscription_until_date': self.subscription_until_date,
            'bot_verification_icon': self.bot_verification_icon,
            'send_paid_messages_stars': self.send_paid_messages_stars,
            'linked_monoforum_id': self.linked_monoforum_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.creator:
            flags |= (1 << 0)
        if self.left:
            flags |= (1 << 2)
        if self.broadcast:
            flags |= (1 << 5)
        if self.verified:
            flags |= (1 << 7)
        if self.megagroup:
            flags |= (1 << 8)
        if self.restriction_reason is not None:
            flags |= (1 << 9)
        if self.signatures:
            flags |= (1 << 11)
        if self.min:
            flags |= (1 << 12)
        if self.scam:
            flags |= (1 << 19)
        if self.has_link:
            flags |= (1 << 20)
        if self.has_geo:
            flags |= (1 << 21)
        if self.slowmode_enabled:
            flags |= (1 << 22)
        if self.call_active:
            flags |= (1 << 23)
        if self.call_not_empty:
            flags |= (1 << 24)
        if self.fake:
            flags |= (1 << 25)
        if self.gigagroup:
            flags |= (1 << 26)
        if self.noforwards:
            flags |= (1 << 27)
        if self.join_to_send:
            flags |= (1 << 28)
        if self.join_request:
            flags |= (1 << 29)
        if self.forum:
            flags |= (1 << 30)
        if self.access_hash is not None:
            flags |= (1 << 13)
        if self.username is not None:
            flags |= (1 << 6)
        if self.admin_rights is not None:
            flags |= (1 << 14)
        if self.banned_rights is not None:
            flags |= (1 << 15)
        if self.default_banned_rights is not None:
            flags |= (1 << 18)
        if self.participants_count is not None:
            flags |= (1 << 17)
        flags2 = 0
        if self.stories_hidden:
            flags2 |= (1 << 1)
        if self.stories_hidden_min:
            flags2 |= (1 << 2)
        if self.stories_unavailable:
            flags2 |= (1 << 3)
        if self.signature_profiles:
            flags2 |= (1 << 12)
        if self.autotranslation:
            flags2 |= (1 << 15)
        if self.broadcast_messages_allowed:
            flags2 |= (1 << 16)
        if self.monoforum:
            flags2 |= (1 << 17)
        if self.forum_tabs:
            flags2 |= (1 << 19)
        if self.usernames is not None:
            flags2 |= (1 << 0)
        if self.stories_max_id is not None:
            flags2 |= (1 << 4)
        if self.color is not None:
            flags2 |= (1 << 7)
        if self.profile_color is not None:
            flags2 |= (1 << 8)
        if self.emoji_status is not None:
            flags2 |= (1 << 9)
        if self.level is not None:
            flags2 |= (1 << 10)
        if self.subscription_until_date is not None:
            flags2 |= (1 << 11)
        if self.bot_verification_icon is not None:
            flags2 |= (1 << 13)
        if self.send_paid_messages_stars is not None:
            flags2 |= (1 << 14)
        if self.linked_monoforum_id is not None:
            flags2 |= (1 << 18)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<I', flags2))
        buf.write(struct.pack('<q', self.id))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(bytes(self.photo))
        buf.write(struct.pack('<i', self.date))
        if self.access_hash is not None:
            buf.write(struct.pack('<q', self.access_hash))
        if self.username is not None:
            buf.write(TLObject.serialize_bytes(self.username))
        if self.restriction_reason is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.restriction_reason)))
            for item in self.restriction_reason:
                buf.write(bytes(self.item))
        if self.admin_rights is not None:
            buf.write(bytes(self.admin_rights))
        if self.banned_rights is not None:
            buf.write(bytes(self.banned_rights))
        if self.default_banned_rights is not None:
            buf.write(bytes(self.default_banned_rights))
        if self.participants_count is not None:
            buf.write(struct.pack('<i', self.participants_count))
        if self.usernames is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.usernames)))
            for item in self.usernames:
                buf.write(bytes(self.item))
        if self.stories_max_id is not None:
            buf.write(bytes(self.stories_max_id))
        if self.color is not None:
            buf.write(bytes(self.color))
        if self.profile_color is not None:
            buf.write(bytes(self.profile_color))
        if self.emoji_status is not None:
            buf.write(bytes(self.emoji_status))
        if self.level is not None:
            buf.write(struct.pack('<i', self.level))
        if self.subscription_until_date is not None:
            buf.write(struct.pack('<i', self.subscription_until_date))
        if self.bot_verification_icon is not None:
            buf.write(struct.pack('<q', self.bot_verification_icon))
        if self.send_paid_messages_stars is not None:
            buf.write(struct.pack('<q', self.send_paid_messages_stars))
        if self.linked_monoforum_id is not None:
            buf.write(struct.pack('<q', self.linked_monoforum_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['creator'] = bool(flags & (1 << 0))
        _args['left'] = bool(flags & (1 << 2))
        _args['broadcast'] = bool(flags & (1 << 5))
        _args['verified'] = bool(flags & (1 << 7))
        _args['megagroup'] = bool(flags & (1 << 8))
        _args['restricted'] = bool(flags & (1 << 9))
        _args['signatures'] = bool(flags & (1 << 11))
        _args['min'] = bool(flags & (1 << 12))
        _args['scam'] = bool(flags & (1 << 19))
        _args['has_link'] = bool(flags & (1 << 20))
        _args['has_geo'] = bool(flags & (1 << 21))
        _args['slowmode_enabled'] = bool(flags & (1 << 22))
        _args['call_active'] = bool(flags & (1 << 23))
        _args['call_not_empty'] = bool(flags & (1 << 24))
        _args['fake'] = bool(flags & (1 << 25))
        _args['gigagroup'] = bool(flags & (1 << 26))
        _args['noforwards'] = bool(flags & (1 << 27))
        _args['join_to_send'] = bool(flags & (1 << 28))
        _args['join_request'] = bool(flags & (1 << 29))
        _args['forum'] = bool(flags & (1 << 30))
        flags2 = reader.read_int(signed=False)
        _args['stories_hidden'] = bool(flags2 & (1 << 1))
        _args['stories_hidden_min'] = bool(flags2 & (1 << 2))
        _args['stories_unavailable'] = bool(flags2 & (1 << 3))
        _args['signature_profiles'] = bool(flags2 & (1 << 12))
        _args['autotranslation'] = bool(flags2 & (1 << 15))
        _args['broadcast_messages_allowed'] = bool(flags2 & (1 << 16))
        _args['monoforum'] = bool(flags2 & (1 << 17))
        _args['forum_tabs'] = bool(flags2 & (1 << 19))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        if flags & (1 << 13):
            _val_access_hash = reader.read_long()
            _args['access_hash'] = _val_access_hash
        else:
            _args['access_hash'] = None
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        if flags & (1 << 6):
            _val_username = reader.tgread_string()
            _args['username'] = _val_username
        else:
            _args['username'] = None
        _val_photo = reader.tgread_object()
        _args['photo'] = _val_photo
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 9):
            reader.read_int(signed=False)  # skip vector id
            _count_restriction_reason = reader.read_int()
            _list_restriction_reason = []
            for _ in range(_count_restriction_reason):
                _item_restriction_reason = reader.tgread_object()
                _list_restriction_reason.append(_item_restriction_reason)
            _args['restriction_reason'] = _list_restriction_reason
        else:
            _args['restriction_reason'] = None
        if flags & (1 << 14):
            _val_admin_rights = reader.tgread_object()
            _args['admin_rights'] = _val_admin_rights
        else:
            _args['admin_rights'] = None
        if flags & (1 << 15):
            _val_banned_rights = reader.tgread_object()
            _args['banned_rights'] = _val_banned_rights
        else:
            _args['banned_rights'] = None
        if flags & (1 << 18):
            _val_default_banned_rights = reader.tgread_object()
            _args['default_banned_rights'] = _val_default_banned_rights
        else:
            _args['default_banned_rights'] = None
        if flags & (1 << 17):
            _val_participants_count = reader.read_int()
            _args['participants_count'] = _val_participants_count
        else:
            _args['participants_count'] = None
        if flags2 & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_usernames = reader.read_int()
            _list_usernames = []
            for _ in range(_count_usernames):
                _item_usernames = reader.tgread_object()
                _list_usernames.append(_item_usernames)
            _args['usernames'] = _list_usernames
        else:
            _args['usernames'] = None
        if flags2 & (1 << 4):
            _val_stories_max_id = reader.tgread_object()
            _args['stories_max_id'] = _val_stories_max_id
        else:
            _args['stories_max_id'] = None
        if flags2 & (1 << 7):
            _val_color = reader.tgread_object()
            _args['color'] = _val_color
        else:
            _args['color'] = None
        if flags2 & (1 << 8):
            _val_profile_color = reader.tgread_object()
            _args['profile_color'] = _val_profile_color
        else:
            _args['profile_color'] = None
        if flags2 & (1 << 9):
            _val_emoji_status = reader.tgread_object()
            _args['emoji_status'] = _val_emoji_status
        else:
            _args['emoji_status'] = None
        if flags2 & (1 << 10):
            _val_level = reader.read_int()
            _args['level'] = _val_level
        else:
            _args['level'] = None
        if flags2 & (1 << 11):
            _val_subscription_until_date = reader.read_int()
            _args['subscription_until_date'] = _val_subscription_until_date
        else:
            _args['subscription_until_date'] = None
        if flags2 & (1 << 13):
            _val_bot_verification_icon = reader.read_long()
            _args['bot_verification_icon'] = _val_bot_verification_icon
        else:
            _args['bot_verification_icon'] = None
        if flags2 & (1 << 14):
            _val_send_paid_messages_stars = reader.read_long()
            _args['send_paid_messages_stars'] = _val_send_paid_messages_stars
        else:
            _args['send_paid_messages_stars'] = None
        if flags2 & (1 << 18):
            _val_linked_monoforum_id = reader.read_long()
            _args['linked_monoforum_id'] = _val_linked_monoforum_id
        else:
            _args['linked_monoforum_id'] = None
        return cls(**_args)


class ChannelAdminLogEvent(TLObject):
    """TL type: channelAdminLogEvent"""
    CONSTRUCTOR_ID = 0x1fad68cd
    SUBCLASS_OF_ID = 0x408f0999

    def __init__(self, id: int, date: Optional[datetime], user_id: int, action: 'TypeChannelAdminLogEventAction'):
        self.id = id
        self.date = date
        self.user_id = user_id
        self.action = action

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEvent',
            'id': self.id,
            'date': self.date,
            'user_id': self.user_id,
            'action': self.action,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(bytes(self.action))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_action = reader.tgread_object()
        _args['action'] = _val_action
        return cls(**_args)


class ChannelAdminLogEventActionChangeAbout(TLObject):
    """TL type: channelAdminLogEventActionChangeAbout"""
    CONSTRUCTOR_ID = 0x55188a2e
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: str, new_value: str):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeAbout',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.prev_value))
        buf.write(TLObject.serialize_bytes(self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.tgread_string()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.tgread_string()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangeAvailableReactions(TLObject):
    """TL type: channelAdminLogEventActionChangeAvailableReactions"""
    CONSTRUCTOR_ID = 0xbe4e0ef8
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: 'TypeChatReactions', new_value: 'TypeChatReactions'):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeAvailableReactions',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_value))
        buf.write(bytes(self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.tgread_object()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.tgread_object()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangeEmojiStatus(TLObject):
    """TL type: channelAdminLogEventActionChangeEmojiStatus"""
    CONSTRUCTOR_ID = 0x3ea9feb1
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: 'TypeEmojiStatus', new_value: 'TypeEmojiStatus'):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeEmojiStatus',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_value))
        buf.write(bytes(self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.tgread_object()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.tgread_object()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangeEmojiStickerSet(TLObject):
    """TL type: channelAdminLogEventActionChangeEmojiStickerSet"""
    CONSTRUCTOR_ID = 0x46d840ab
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_stickerset: 'TypeInputStickerSet', new_stickerset: 'TypeInputStickerSet'):
        self.prev_stickerset = prev_stickerset
        self.new_stickerset = new_stickerset

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeEmojiStickerSet',
            'prev_stickerset': self.prev_stickerset,
            'new_stickerset': self.new_stickerset,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_stickerset))
        buf.write(bytes(self.new_stickerset))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_stickerset = reader.tgread_object()
        _args['prev_stickerset'] = _val_prev_stickerset
        _val_new_stickerset = reader.tgread_object()
        _args['new_stickerset'] = _val_new_stickerset
        return cls(**_args)


class ChannelAdminLogEventActionChangeHistoryTtl(TLObject):
    """TL type: channelAdminLogEventActionChangeHistoryTTL"""
    CONSTRUCTOR_ID = 0x6e941a38
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: int, new_value: int):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeHistoryTtl',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.prev_value))
        buf.write(struct.pack('<i', self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.read_int()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.read_int()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangeLinkedChat(TLObject):
    """TL type: channelAdminLogEventActionChangeLinkedChat"""
    CONSTRUCTOR_ID = 0x050c7ac8
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: int, new_value: int):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeLinkedChat',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.prev_value))
        buf.write(struct.pack('<q', self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.read_long()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.read_long()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangeLocation(TLObject):
    """TL type: channelAdminLogEventActionChangeLocation"""
    CONSTRUCTOR_ID = 0x0e6b76ae
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: 'TypeChannelLocation', new_value: 'TypeChannelLocation'):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeLocation',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_value))
        buf.write(bytes(self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.tgread_object()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.tgread_object()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangePeerColor(TLObject):
    """TL type: channelAdminLogEventActionChangePeerColor"""
    CONSTRUCTOR_ID = 0x5796e780
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: 'TypePeerColor', new_value: 'TypePeerColor'):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangePeerColor',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_value))
        buf.write(bytes(self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.tgread_object()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.tgread_object()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangePhoto(TLObject):
    """TL type: channelAdminLogEventActionChangePhoto"""
    CONSTRUCTOR_ID = 0x434bd2af
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_photo: 'TypePhoto', new_photo: 'TypePhoto'):
        self.prev_photo = prev_photo
        self.new_photo = new_photo

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangePhoto',
            'prev_photo': self.prev_photo,
            'new_photo': self.new_photo,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_photo))
        buf.write(bytes(self.new_photo))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_photo = reader.tgread_object()
        _args['prev_photo'] = _val_prev_photo
        _val_new_photo = reader.tgread_object()
        _args['new_photo'] = _val_new_photo
        return cls(**_args)


class ChannelAdminLogEventActionChangeProfilePeerColor(TLObject):
    """TL type: channelAdminLogEventActionChangeProfilePeerColor"""
    CONSTRUCTOR_ID = 0x5e477b25
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: 'TypePeerColor', new_value: 'TypePeerColor'):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeProfilePeerColor',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_value))
        buf.write(bytes(self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.tgread_object()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.tgread_object()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangeStickerSet(TLObject):
    """TL type: channelAdminLogEventActionChangeStickerSet"""
    CONSTRUCTOR_ID = 0xb1c3caa7
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_stickerset: 'TypeInputStickerSet', new_stickerset: 'TypeInputStickerSet'):
        self.prev_stickerset = prev_stickerset
        self.new_stickerset = new_stickerset

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeStickerSet',
            'prev_stickerset': self.prev_stickerset,
            'new_stickerset': self.new_stickerset,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_stickerset))
        buf.write(bytes(self.new_stickerset))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_stickerset = reader.tgread_object()
        _args['prev_stickerset'] = _val_prev_stickerset
        _val_new_stickerset = reader.tgread_object()
        _args['new_stickerset'] = _val_new_stickerset
        return cls(**_args)


class ChannelAdminLogEventActionChangeTheme(TLObject):
    """TL type: channelAdminLogEventActionChangeTheme"""
    CONSTRUCTOR_ID = 0xfe69018d
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: str, new_value: str):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeTheme',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.prev_value))
        buf.write(TLObject.serialize_bytes(self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.tgread_string()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.tgread_string()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangeTitle(TLObject):
    """TL type: channelAdminLogEventActionChangeTitle"""
    CONSTRUCTOR_ID = 0xe6dfb825
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: str, new_value: str):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeTitle',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.prev_value))
        buf.write(TLObject.serialize_bytes(self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.tgread_string()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.tgread_string()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangeUsername(TLObject):
    """TL type: channelAdminLogEventActionChangeUsername"""
    CONSTRUCTOR_ID = 0x6a4afc38
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: str, new_value: str):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeUsername',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.prev_value))
        buf.write(TLObject.serialize_bytes(self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.tgread_string()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.tgread_string()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangeUsernames(TLObject):
    """TL type: channelAdminLogEventActionChangeUsernames"""
    CONSTRUCTOR_ID = 0xf04fb3a9
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: List[str], new_value: List[str]):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeUsernames',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.prev_value)))
        for item in self.prev_value:
            buf.write(TLObject.serialize_bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.new_value)))
        for item in self.new_value:
            buf.write(TLObject.serialize_bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_prev_value = reader.read_int()
        _list_prev_value = []
        for _ in range(_count_prev_value):
            _item_prev_value = reader.tgread_string()
            _list_prev_value.append(_item_prev_value)
        _args['prev_value'] = _list_prev_value
        reader.read_int(signed=False)  # skip vector id
        _count_new_value = reader.read_int()
        _list_new_value = []
        for _ in range(_count_new_value):
            _item_new_value = reader.tgread_string()
            _list_new_value.append(_item_new_value)
        _args['new_value'] = _list_new_value
        return cls(**_args)


class ChannelAdminLogEventActionChangeWallpaper(TLObject):
    """TL type: channelAdminLogEventActionChangeWallpaper"""
    CONSTRUCTOR_ID = 0x31bb5d52
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: 'TypeWallPaper', new_value: 'TypeWallPaper'):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionChangeWallpaper',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_value))
        buf.write(bytes(self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.tgread_object()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.tgread_object()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionCreateTopic(TLObject):
    """TL type: channelAdminLogEventActionCreateTopic"""
    CONSTRUCTOR_ID = 0x58707d28
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, topic: 'TypeForumTopic'):
        self.topic = topic

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionCreateTopic',
            'topic': self.topic,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.topic))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_topic = reader.tgread_object()
        _args['topic'] = _val_topic
        return cls(**_args)


class ChannelAdminLogEventActionDefaultBannedRights(TLObject):
    """TL type: channelAdminLogEventActionDefaultBannedRights"""
    CONSTRUCTOR_ID = 0x2df5fc0a
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_banned_rights: 'TypeChatBannedRights', new_banned_rights: 'TypeChatBannedRights'):
        self.prev_banned_rights = prev_banned_rights
        self.new_banned_rights = new_banned_rights

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionDefaultBannedRights',
            'prev_banned_rights': self.prev_banned_rights,
            'new_banned_rights': self.new_banned_rights,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_banned_rights))
        buf.write(bytes(self.new_banned_rights))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_banned_rights = reader.tgread_object()
        _args['prev_banned_rights'] = _val_prev_banned_rights
        _val_new_banned_rights = reader.tgread_object()
        _args['new_banned_rights'] = _val_new_banned_rights
        return cls(**_args)


class ChannelAdminLogEventActionDeleteMessage(TLObject):
    """TL type: channelAdminLogEventActionDeleteMessage"""
    CONSTRUCTOR_ID = 0x42e047bb
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, message: 'TypeMessage'):
        self.message = message

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionDeleteMessage',
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        return cls(**_args)


class ChannelAdminLogEventActionDeleteTopic(TLObject):
    """TL type: channelAdminLogEventActionDeleteTopic"""
    CONSTRUCTOR_ID = 0xae168909
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, topic: 'TypeForumTopic'):
        self.topic = topic

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionDeleteTopic',
            'topic': self.topic,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.topic))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_topic = reader.tgread_object()
        _args['topic'] = _val_topic
        return cls(**_args)


class ChannelAdminLogEventActionDiscardGroupCall(TLObject):
    """TL type: channelAdminLogEventActionDiscardGroupCall"""
    CONSTRUCTOR_ID = 0xdb9f9140
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, call: 'TypeInputGroupCall'):
        self.call = call

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionDiscardGroupCall',
            'call': self.call,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.call))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        return cls(**_args)


class ChannelAdminLogEventActionEditMessage(TLObject):
    """TL type: channelAdminLogEventActionEditMessage"""
    CONSTRUCTOR_ID = 0x709b2405
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_message: 'TypeMessage', new_message: 'TypeMessage'):
        self.prev_message = prev_message
        self.new_message = new_message

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionEditMessage',
            'prev_message': self.prev_message,
            'new_message': self.new_message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_message))
        buf.write(bytes(self.new_message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_message = reader.tgread_object()
        _args['prev_message'] = _val_prev_message
        _val_new_message = reader.tgread_object()
        _args['new_message'] = _val_new_message
        return cls(**_args)


class ChannelAdminLogEventActionEditTopic(TLObject):
    """TL type: channelAdminLogEventActionEditTopic"""
    CONSTRUCTOR_ID = 0xf06fe208
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_topic: 'TypeForumTopic', new_topic: 'TypeForumTopic'):
        self.prev_topic = prev_topic
        self.new_topic = new_topic

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionEditTopic',
            'prev_topic': self.prev_topic,
            'new_topic': self.new_topic,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_topic))
        buf.write(bytes(self.new_topic))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_topic = reader.tgread_object()
        _args['prev_topic'] = _val_prev_topic
        _val_new_topic = reader.tgread_object()
        _args['new_topic'] = _val_new_topic
        return cls(**_args)


class ChannelAdminLogEventActionExportedInviteDelete(TLObject):
    """TL type: channelAdminLogEventActionExportedInviteDelete"""
    CONSTRUCTOR_ID = 0x5a50fca4
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, invite: 'TypeExportedChatInvite'):
        self.invite = invite

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionExportedInviteDelete',
            'invite': self.invite,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.invite))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_invite = reader.tgread_object()
        _args['invite'] = _val_invite
        return cls(**_args)


class ChannelAdminLogEventActionExportedInviteEdit(TLObject):
    """TL type: channelAdminLogEventActionExportedInviteEdit"""
    CONSTRUCTOR_ID = 0xe90ebb59
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_invite: 'TypeExportedChatInvite', new_invite: 'TypeExportedChatInvite'):
        self.prev_invite = prev_invite
        self.new_invite = new_invite

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionExportedInviteEdit',
            'prev_invite': self.prev_invite,
            'new_invite': self.new_invite,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_invite))
        buf.write(bytes(self.new_invite))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_invite = reader.tgread_object()
        _args['prev_invite'] = _val_prev_invite
        _val_new_invite = reader.tgread_object()
        _args['new_invite'] = _val_new_invite
        return cls(**_args)


class ChannelAdminLogEventActionExportedInviteRevoke(TLObject):
    """TL type: channelAdminLogEventActionExportedInviteRevoke"""
    CONSTRUCTOR_ID = 0x410a134e
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, invite: 'TypeExportedChatInvite'):
        self.invite = invite

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionExportedInviteRevoke',
            'invite': self.invite,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.invite))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_invite = reader.tgread_object()
        _args['invite'] = _val_invite
        return cls(**_args)


class ChannelAdminLogEventActionParticipantInvite(TLObject):
    """TL type: channelAdminLogEventActionParticipantInvite"""
    CONSTRUCTOR_ID = 0xe31c34d8
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, participant: 'TypeChannelParticipant'):
        self.participant = participant

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionParticipantInvite',
            'participant': self.participant,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.participant))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_participant = reader.tgread_object()
        _args['participant'] = _val_participant
        return cls(**_args)


class ChannelAdminLogEventActionParticipantJoin(TLObject):
    """TL type: channelAdminLogEventActionParticipantJoin"""
    CONSTRUCTOR_ID = 0x183040d3
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionParticipantJoin',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ChannelAdminLogEventActionParticipantJoinByInvite(TLObject):
    """TL type: channelAdminLogEventActionParticipantJoinByInvite"""
    CONSTRUCTOR_ID = 0xfe9fc158
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, invite: 'TypeExportedChatInvite', via_chatlist: Optional[bool] = None):
        self.invite = invite
        self.via_chatlist = via_chatlist

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionParticipantJoinByInvite',
            'invite': self.invite,
            'via_chatlist': self.via_chatlist,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.via_chatlist:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.invite))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['via_chatlist'] = bool(flags & (1 << 0))
        _val_invite = reader.tgread_object()
        _args['invite'] = _val_invite
        return cls(**_args)


class ChannelAdminLogEventActionParticipantJoinByRequest(TLObject):
    """TL type: channelAdminLogEventActionParticipantJoinByRequest"""
    CONSTRUCTOR_ID = 0xafb6144a
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, invite: 'TypeExportedChatInvite', approved_by: int):
        self.invite = invite
        self.approved_by = approved_by

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionParticipantJoinByRequest',
            'invite': self.invite,
            'approved_by': self.approved_by,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.invite))
        buf.write(struct.pack('<q', self.approved_by))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_invite = reader.tgread_object()
        _args['invite'] = _val_invite
        _val_approved_by = reader.read_long()
        _args['approved_by'] = _val_approved_by
        return cls(**_args)


class ChannelAdminLogEventActionParticipantLeave(TLObject):
    """TL type: channelAdminLogEventActionParticipantLeave"""
    CONSTRUCTOR_ID = 0xf89777f2
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionParticipantLeave',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ChannelAdminLogEventActionParticipantMute(TLObject):
    """TL type: channelAdminLogEventActionParticipantMute"""
    CONSTRUCTOR_ID = 0xf92424d2
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, participant: 'TypeGroupCallParticipant'):
        self.participant = participant

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionParticipantMute',
            'participant': self.participant,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.participant))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_participant = reader.tgread_object()
        _args['participant'] = _val_participant
        return cls(**_args)


class ChannelAdminLogEventActionParticipantSubExtend(TLObject):
    """TL type: channelAdminLogEventActionParticipantSubExtend"""
    CONSTRUCTOR_ID = 0x64642db3
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_participant: 'TypeChannelParticipant', new_participant: 'TypeChannelParticipant'):
        self.prev_participant = prev_participant
        self.new_participant = new_participant

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionParticipantSubExtend',
            'prev_participant': self.prev_participant,
            'new_participant': self.new_participant,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_participant))
        buf.write(bytes(self.new_participant))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_participant = reader.tgread_object()
        _args['prev_participant'] = _val_prev_participant
        _val_new_participant = reader.tgread_object()
        _args['new_participant'] = _val_new_participant
        return cls(**_args)


class ChannelAdminLogEventActionParticipantToggleAdmin(TLObject):
    """TL type: channelAdminLogEventActionParticipantToggleAdmin"""
    CONSTRUCTOR_ID = 0xd5676710
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_participant: 'TypeChannelParticipant', new_participant: 'TypeChannelParticipant'):
        self.prev_participant = prev_participant
        self.new_participant = new_participant

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionParticipantToggleAdmin',
            'prev_participant': self.prev_participant,
            'new_participant': self.new_participant,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_participant))
        buf.write(bytes(self.new_participant))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_participant = reader.tgread_object()
        _args['prev_participant'] = _val_prev_participant
        _val_new_participant = reader.tgread_object()
        _args['new_participant'] = _val_new_participant
        return cls(**_args)


class ChannelAdminLogEventActionParticipantToggleBan(TLObject):
    """TL type: channelAdminLogEventActionParticipantToggleBan"""
    CONSTRUCTOR_ID = 0xe6d83d7e
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_participant: 'TypeChannelParticipant', new_participant: 'TypeChannelParticipant'):
        self.prev_participant = prev_participant
        self.new_participant = new_participant

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionParticipantToggleBan',
            'prev_participant': self.prev_participant,
            'new_participant': self.new_participant,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.prev_participant))
        buf.write(bytes(self.new_participant))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_participant = reader.tgread_object()
        _args['prev_participant'] = _val_prev_participant
        _val_new_participant = reader.tgread_object()
        _args['new_participant'] = _val_new_participant
        return cls(**_args)


class ChannelAdminLogEventActionParticipantUnmute(TLObject):
    """TL type: channelAdminLogEventActionParticipantUnmute"""
    CONSTRUCTOR_ID = 0xe64429c0
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, participant: 'TypeGroupCallParticipant'):
        self.participant = participant

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionParticipantUnmute',
            'participant': self.participant,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.participant))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_participant = reader.tgread_object()
        _args['participant'] = _val_participant
        return cls(**_args)


class ChannelAdminLogEventActionParticipantVolume(TLObject):
    """TL type: channelAdminLogEventActionParticipantVolume"""
    CONSTRUCTOR_ID = 0x3e7f6847
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, participant: 'TypeGroupCallParticipant'):
        self.participant = participant

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionParticipantVolume',
            'participant': self.participant,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.participant))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_participant = reader.tgread_object()
        _args['participant'] = _val_participant
        return cls(**_args)


class ChannelAdminLogEventActionPinTopic(TLObject):
    """TL type: channelAdminLogEventActionPinTopic"""
    CONSTRUCTOR_ID = 0x5d8d353b
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_topic: Optional['TypeForumTopic'] = None, new_topic: Optional['TypeForumTopic'] = None):
        self.prev_topic = prev_topic
        self.new_topic = new_topic

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionPinTopic',
            'prev_topic': self.prev_topic,
            'new_topic': self.new_topic,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.prev_topic is not None:
            flags |= (1 << 0)
        if self.new_topic is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        if self.prev_topic is not None:
            buf.write(bytes(self.prev_topic))
        if self.new_topic is not None:
            buf.write(bytes(self.new_topic))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_prev_topic = reader.tgread_object()
            _args['prev_topic'] = _val_prev_topic
        else:
            _args['prev_topic'] = None
        if flags & (1 << 1):
            _val_new_topic = reader.tgread_object()
            _args['new_topic'] = _val_new_topic
        else:
            _args['new_topic'] = None
        return cls(**_args)


class ChannelAdminLogEventActionSendMessage(TLObject):
    """TL type: channelAdminLogEventActionSendMessage"""
    CONSTRUCTOR_ID = 0x278f2868
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, message: 'TypeMessage'):
        self.message = message

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionSendMessage',
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        return cls(**_args)


class ChannelAdminLogEventActionStartGroupCall(TLObject):
    """TL type: channelAdminLogEventActionStartGroupCall"""
    CONSTRUCTOR_ID = 0x23209745
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, call: 'TypeInputGroupCall'):
        self.call = call

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionStartGroupCall',
            'call': self.call,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.call))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        return cls(**_args)


class ChannelAdminLogEventActionStopPoll(TLObject):
    """TL type: channelAdminLogEventActionStopPoll"""
    CONSTRUCTOR_ID = 0x8f079643
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, message: 'TypeMessage'):
        self.message = message

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionStopPoll',
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        return cls(**_args)


class ChannelAdminLogEventActionToggleAntiSpam(TLObject):
    """TL type: channelAdminLogEventActionToggleAntiSpam"""
    CONSTRUCTOR_ID = 0x64f36dfc
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, new_value: bool):
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionToggleAntiSpam',
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', 0x997275b5 if self.new_value else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_new_value = reader.tgread_bool()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionToggleAutotranslation(TLObject):
    """TL type: channelAdminLogEventActionToggleAutotranslation"""
    CONSTRUCTOR_ID = 0xc517f77e
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, new_value: bool):
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionToggleAutotranslation',
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', 0x997275b5 if self.new_value else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_new_value = reader.tgread_bool()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionToggleForum(TLObject):
    """TL type: channelAdminLogEventActionToggleForum"""
    CONSTRUCTOR_ID = 0x02cc6383
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, new_value: bool):
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionToggleForum',
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', 0x997275b5 if self.new_value else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_new_value = reader.tgread_bool()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionToggleGroupCallSetting(TLObject):
    """TL type: channelAdminLogEventActionToggleGroupCallSetting"""
    CONSTRUCTOR_ID = 0x56d6a247
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, join_muted: bool):
        self.join_muted = join_muted

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionToggleGroupCallSetting',
            'join_muted': self.join_muted,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', 0x997275b5 if self.join_muted else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_join_muted = reader.tgread_bool()
        _args['join_muted'] = _val_join_muted
        return cls(**_args)


class ChannelAdminLogEventActionToggleInvites(TLObject):
    """TL type: channelAdminLogEventActionToggleInvites"""
    CONSTRUCTOR_ID = 0x1b7907ae
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, new_value: bool):
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionToggleInvites',
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', 0x997275b5 if self.new_value else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_new_value = reader.tgread_bool()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionToggleNoForwards(TLObject):
    """TL type: channelAdminLogEventActionToggleNoForwards"""
    CONSTRUCTOR_ID = 0xcb2ac766
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, new_value: bool):
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionToggleNoForwards',
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', 0x997275b5 if self.new_value else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_new_value = reader.tgread_bool()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionTogglePreHistoryHidden(TLObject):
    """TL type: channelAdminLogEventActionTogglePreHistoryHidden"""
    CONSTRUCTOR_ID = 0x5f5c95f1
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, new_value: bool):
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionTogglePreHistoryHidden',
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', 0x997275b5 if self.new_value else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_new_value = reader.tgread_bool()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionToggleSignatureProfiles(TLObject):
    """TL type: channelAdminLogEventActionToggleSignatureProfiles"""
    CONSTRUCTOR_ID = 0x60a79c79
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, new_value: bool):
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionToggleSignatureProfiles',
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', 0x997275b5 if self.new_value else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_new_value = reader.tgread_bool()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionToggleSignatures(TLObject):
    """TL type: channelAdminLogEventActionToggleSignatures"""
    CONSTRUCTOR_ID = 0x26ae0971
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, new_value: bool):
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionToggleSignatures',
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', 0x997275b5 if self.new_value else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_new_value = reader.tgread_bool()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionToggleSlowMode(TLObject):
    """TL type: channelAdminLogEventActionToggleSlowMode"""
    CONSTRUCTOR_ID = 0x53909779
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, prev_value: int, new_value: int):
        self.prev_value = prev_value
        self.new_value = new_value

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionToggleSlowMode',
            'prev_value': self.prev_value,
            'new_value': self.new_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.prev_value))
        buf.write(struct.pack('<i', self.new_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_prev_value = reader.read_int()
        _args['prev_value'] = _val_prev_value
        _val_new_value = reader.read_int()
        _args['new_value'] = _val_new_value
        return cls(**_args)


class ChannelAdminLogEventActionUpdatePinned(TLObject):
    """TL type: channelAdminLogEventActionUpdatePinned"""
    CONSTRUCTOR_ID = 0xe9e82c18
    SUBCLASS_OF_ID = 0xb2b987f3

    def __init__(self, message: 'TypeMessage'):
        self.message = message

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventActionUpdatePinned',
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        return cls(**_args)


class ChannelAdminLogEventsFilter(TLObject):
    """TL type: channelAdminLogEventsFilter"""
    CONSTRUCTOR_ID = 0xea107ae4
    SUBCLASS_OF_ID = 0x7cbbf319

    def __init__(self, join: Optional[bool] = None, leave: Optional[bool] = None, invite: Optional[bool] = None, ban: Optional[bool] = None, unban: Optional[bool] = None, kick: Optional[bool] = None, unkick: Optional[bool] = None, promote: Optional[bool] = None, demote: Optional[bool] = None, info: Optional[bool] = None, settings: Optional[bool] = None, pinned: Optional[bool] = None, edit: Optional[bool] = None, delete: Optional[bool] = None, group_call: Optional[bool] = None, invites: Optional[bool] = None, send: Optional[bool] = None, forums: Optional[bool] = None, sub_extend: Optional[bool] = None):
        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
        self.group_call = group_call
        self.invites = invites
        self.send = send
        self.forums = forums
        self.sub_extend = sub_extend

    def to_dict(self):
        return {
            '_': 'ChannelAdminLogEventsFilter',
            '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,
            'group_call': self.group_call,
            'invites': self.invites,
            'send': self.send,
            'forums': self.forums,
            'sub_extend': self.sub_extend,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.join:
            flags |= (1 << 0)
        if self.leave:
            flags |= (1 << 1)
        if self.invite:
            flags |= (1 << 2)
        if self.ban:
            flags |= (1 << 3)
        if self.unban:
            flags |= (1 << 4)
        if self.kick:
            flags |= (1 << 5)
        if self.unkick:
            flags |= (1 << 6)
        if self.promote:
            flags |= (1 << 7)
        if self.demote:
            flags |= (1 << 8)
        if self.info:
            flags |= (1 << 9)
        if self.settings:
            flags |= (1 << 10)
        if self.pinned:
            flags |= (1 << 11)
        if self.edit:
            flags |= (1 << 12)
        if self.delete:
            flags |= (1 << 13)
        if self.group_call:
            flags |= (1 << 14)
        if self.invites:
            flags |= (1 << 15)
        if self.send:
            flags |= (1 << 16)
        if self.forums:
            flags |= (1 << 17)
        if self.sub_extend:
            flags |= (1 << 18)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['join'] = bool(flags & (1 << 0))
        _args['leave'] = bool(flags & (1 << 1))
        _args['invite'] = bool(flags & (1 << 2))
        _args['ban'] = bool(flags & (1 << 3))
        _args['unban'] = bool(flags & (1 << 4))
        _args['kick'] = bool(flags & (1 << 5))
        _args['unkick'] = bool(flags & (1 << 6))
        _args['promote'] = bool(flags & (1 << 7))
        _args['demote'] = bool(flags & (1 << 8))
        _args['info'] = bool(flags & (1 << 9))
        _args['settings'] = bool(flags & (1 << 10))
        _args['pinned'] = bool(flags & (1 << 11))
        _args['edit'] = bool(flags & (1 << 12))
        _args['delete'] = bool(flags & (1 << 13))
        _args['group_call'] = bool(flags & (1 << 14))
        _args['invites'] = bool(flags & (1 << 15))
        _args['send'] = bool(flags & (1 << 16))
        _args['forums'] = bool(flags & (1 << 17))
        _args['sub_extend'] = bool(flags & (1 << 18))
        return cls(**_args)


class ChannelForbidden(TLObject):
    """TL type: channelForbidden"""
    CONSTRUCTOR_ID = 0x17d493d5
    SUBCLASS_OF_ID = 0xc5af5d94

    def __init__(self, id: int, access_hash: int, title: str, broadcast: Optional[bool] = None, megagroup: Optional[bool] = None, monoforum: Optional[bool] = None, until_date: Optional[datetime] = None):
        self.id = id
        self.access_hash = access_hash
        self.title = title
        self.broadcast = broadcast
        self.megagroup = megagroup
        self.monoforum = monoforum
        self.until_date = until_date

    def to_dict(self):
        return {
            '_': 'ChannelForbidden',
            'id': self.id,
            'access_hash': self.access_hash,
            'title': self.title,
            'broadcast': self.broadcast,
            'megagroup': self.megagroup,
            'monoforum': self.monoforum,
            'until_date': self.until_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.broadcast:
            flags |= (1 << 5)
        if self.megagroup:
            flags |= (1 << 8)
        if self.monoforum:
            flags |= (1 << 10)
        if self.until_date is not None:
            flags |= (1 << 16)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.title))
        if self.until_date is not None:
            buf.write(struct.pack('<i', self.until_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['broadcast'] = bool(flags & (1 << 5))
        _args['megagroup'] = bool(flags & (1 << 8))
        _args['monoforum'] = bool(flags & (1 << 10))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        if flags & (1 << 16):
            _val_until_date = reader.read_int()
            _args['until_date'] = _val_until_date
        else:
            _args['until_date'] = None
        return cls(**_args)


class ChannelFull(TLObject):
    """TL type: channelFull"""
    CONSTRUCTOR_ID = 0xe4e0b29d
    SUBCLASS_OF_ID = 0xd49a2697

    def __init__(self, id: int, about: str, read_inbox_max_id: int, read_outbox_max_id: int, unread_count: int, chat_photo: 'TypePhoto', notify_settings: 'TypePeerNotifySettings', bot_info: List['TypeBotInfo'], pts: int, can_view_participants: Optional[bool] = None, can_set_username: Optional[bool] = None, can_set_stickers: Optional[bool] = None, hidden_prehistory: Optional[bool] = None, can_set_location: Optional[bool] = None, has_scheduled: Optional[bool] = None, can_view_stats: Optional[bool] = None, blocked: Optional[bool] = None, can_delete_channel: Optional[bool] = None, antispam: Optional[bool] = None, participants_hidden: Optional[bool] = None, translations_disabled: Optional[bool] = None, stories_pinned_available: Optional[bool] = None, view_forum_as_messages: Optional[bool] = None, restricted_sponsored: Optional[bool] = None, can_view_revenue: Optional[bool] = None, paid_media_allowed: Optional[bool] = None, can_view_stars_revenue: Optional[bool] = None, paid_reactions_available: Optional[bool] = None, stargifts_available: Optional[bool] = None, paid_messages_available: Optional[bool] = None, participants_count: Optional[int] = None, admins_count: Optional[int] = None, kicked_count: Optional[int] = None, banned_count: Optional[int] = None, online_count: Optional[int] = None, exported_invite: Optional['TypeExportedChatInvite'] = None, migrated_from_chat_id: Optional[int] = None, migrated_from_max_id: Optional[int] = None, pinned_msg_id: Optional[int] = None, stickerset: Optional['TypeStickerSet'] = None, available_min_id: Optional[int] = None, folder_id: Optional[int] = None, linked_chat_id: Optional[int] = None, location: Optional['TypeChannelLocation'] = None, slowmode_seconds: Optional[int] = None, slowmode_next_send_date: Optional[datetime] = None, stats_dc: Optional[int] = None, call: Optional['TypeInputGroupCall'] = None, ttl_period: Optional[int] = None, pending_suggestions: Optional[List[str]] = None, groupcall_default_join_as: Optional['TypePeer'] = None, theme_emoticon: Optional[str] = None, requests_pending: Optional[int] = None, recent_requesters: Optional[List[int]] = None, default_send_as: Optional['TypePeer'] = None, available_reactions: Optional['TypeChatReactions'] = None, reactions_limit: Optional[int] = None, stories: Optional['TypePeerStories'] = None, wallpaper: Optional['TypeWallPaper'] = None, boosts_applied: Optional[int] = None, boosts_unrestrict: Optional[int] = None, emojiset: Optional['TypeStickerSet'] = None, bot_verification: Optional['TypeBotVerification'] = None, stargifts_count: Optional[int] = None, send_paid_messages_stars: Optional[int] = None, main_tab: Optional['TypeProfileTab'] = None):
        self.id = id
        self.about = about
        self.read_inbox_max_id = read_inbox_max_id
        self.read_outbox_max_id = read_outbox_max_id
        self.unread_count = unread_count
        self.chat_photo = chat_photo
        self.notify_settings = notify_settings
        self.bot_info = bot_info
        self.pts = pts
        self.can_view_participants = can_view_participants
        self.can_set_username = can_set_username
        self.can_set_stickers = can_set_stickers
        self.hidden_prehistory = hidden_prehistory
        self.can_set_location = can_set_location
        self.has_scheduled = has_scheduled
        self.can_view_stats = can_view_stats
        self.blocked = blocked
        self.can_delete_channel = can_delete_channel
        self.antispam = antispam
        self.participants_hidden = participants_hidden
        self.translations_disabled = translations_disabled
        self.stories_pinned_available = stories_pinned_available
        self.view_forum_as_messages = view_forum_as_messages
        self.restricted_sponsored = restricted_sponsored
        self.can_view_revenue = can_view_revenue
        self.paid_media_allowed = paid_media_allowed
        self.can_view_stars_revenue = can_view_stars_revenue
        self.paid_reactions_available = paid_reactions_available
        self.stargifts_available = stargifts_available
        self.paid_messages_available = paid_messages_available
        self.participants_count = participants_count
        self.admins_count = admins_count
        self.kicked_count = kicked_count
        self.banned_count = banned_count
        self.online_count = online_count
        self.exported_invite = exported_invite
        self.migrated_from_chat_id = migrated_from_chat_id
        self.migrated_from_max_id = migrated_from_max_id
        self.pinned_msg_id = pinned_msg_id
        self.stickerset = stickerset
        self.available_min_id = available_min_id
        self.folder_id = folder_id
        self.linked_chat_id = linked_chat_id
        self.location = location
        self.slowmode_seconds = slowmode_seconds
        self.slowmode_next_send_date = slowmode_next_send_date
        self.stats_dc = stats_dc
        self.call = call
        self.ttl_period = ttl_period
        self.pending_suggestions = pending_suggestions
        self.groupcall_default_join_as = groupcall_default_join_as
        self.theme_emoticon = theme_emoticon
        self.requests_pending = requests_pending
        self.recent_requesters = recent_requesters
        self.default_send_as = default_send_as
        self.available_reactions = available_reactions
        self.reactions_limit = reactions_limit
        self.stories = stories
        self.wallpaper = wallpaper
        self.boosts_applied = boosts_applied
        self.boosts_unrestrict = boosts_unrestrict
        self.emojiset = emojiset
        self.bot_verification = bot_verification
        self.stargifts_count = stargifts_count
        self.send_paid_messages_stars = send_paid_messages_stars
        self.main_tab = main_tab

    def to_dict(self):
        return {
            '_': 'ChannelFull',
            'id': self.id,
            'about': self.about,
            'read_inbox_max_id': self.read_inbox_max_id,
            'read_outbox_max_id': self.read_outbox_max_id,
            'unread_count': self.unread_count,
            'chat_photo': self.chat_photo,
            'notify_settings': self.notify_settings,
            'bot_info': self.bot_info,
            'pts': self.pts,
            'can_view_participants': self.can_view_participants,
            'can_set_username': self.can_set_username,
            'can_set_stickers': self.can_set_stickers,
            'hidden_prehistory': self.hidden_prehistory,
            'can_set_location': self.can_set_location,
            'has_scheduled': self.has_scheduled,
            'can_view_stats': self.can_view_stats,
            'blocked': self.blocked,
            'can_delete_channel': self.can_delete_channel,
            'antispam': self.antispam,
            'participants_hidden': self.participants_hidden,
            'translations_disabled': self.translations_disabled,
            'stories_pinned_available': self.stories_pinned_available,
            'view_forum_as_messages': self.view_forum_as_messages,
            'restricted_sponsored': self.restricted_sponsored,
            'can_view_revenue': self.can_view_revenue,
            'paid_media_allowed': self.paid_media_allowed,
            'can_view_stars_revenue': self.can_view_stars_revenue,
            'paid_reactions_available': self.paid_reactions_available,
            'stargifts_available': self.stargifts_available,
            'paid_messages_available': self.paid_messages_available,
            'participants_count': self.participants_count,
            'admins_count': self.admins_count,
            'kicked_count': self.kicked_count,
            'banned_count': self.banned_count,
            'online_count': self.online_count,
            'exported_invite': self.exported_invite,
            'migrated_from_chat_id': self.migrated_from_chat_id,
            'migrated_from_max_id': self.migrated_from_max_id,
            'pinned_msg_id': self.pinned_msg_id,
            'stickerset': self.stickerset,
            'available_min_id': self.available_min_id,
            'folder_id': self.folder_id,
            'linked_chat_id': self.linked_chat_id,
            'location': self.location,
            'slowmode_seconds': self.slowmode_seconds,
            'slowmode_next_send_date': self.slowmode_next_send_date,
            'stats_dc': self.stats_dc,
            'call': self.call,
            'ttl_period': self.ttl_period,
            'pending_suggestions': self.pending_suggestions,
            'groupcall_default_join_as': self.groupcall_default_join_as,
            'theme_emoticon': self.theme_emoticon,
            'requests_pending': self.requests_pending,
            'recent_requesters': self.recent_requesters,
            'default_send_as': self.default_send_as,
            'available_reactions': self.available_reactions,
            'reactions_limit': self.reactions_limit,
            'stories': self.stories,
            'wallpaper': self.wallpaper,
            'boosts_applied': self.boosts_applied,
            'boosts_unrestrict': self.boosts_unrestrict,
            'emojiset': self.emojiset,
            'bot_verification': self.bot_verification,
            'stargifts_count': self.stargifts_count,
            'send_paid_messages_stars': self.send_paid_messages_stars,
            'main_tab': self.main_tab,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.can_view_participants:
            flags |= (1 << 3)
        if self.can_set_username:
            flags |= (1 << 6)
        if self.can_set_stickers:
            flags |= (1 << 7)
        if self.hidden_prehistory:
            flags |= (1 << 10)
        if self.can_set_location:
            flags |= (1 << 16)
        if self.has_scheduled:
            flags |= (1 << 19)
        if self.can_view_stats:
            flags |= (1 << 20)
        if self.blocked:
            flags |= (1 << 22)
        if self.participants_count is not None:
            flags |= (1 << 0)
        if self.admins_count is not None:
            flags |= (1 << 1)
        if self.banned_count is not None:
            flags |= (1 << 2)
        if self.online_count is not None:
            flags |= (1 << 13)
        if self.exported_invite is not None:
            flags |= (1 << 23)
        if self.migrated_from_max_id is not None:
            flags |= (1 << 4)
        if self.pinned_msg_id is not None:
            flags |= (1 << 5)
        if self.stickerset is not None:
            flags |= (1 << 8)
        if self.available_min_id is not None:
            flags |= (1 << 9)
        if self.folder_id is not None:
            flags |= (1 << 11)
        if self.linked_chat_id is not None:
            flags |= (1 << 14)
        if self.location is not None:
            flags |= (1 << 15)
        if self.slowmode_seconds is not None:
            flags |= (1 << 17)
        if self.slowmode_next_send_date is not None:
            flags |= (1 << 18)
        if self.stats_dc is not None:
            flags |= (1 << 12)
        if self.call is not None:
            flags |= (1 << 21)
        if self.ttl_period is not None:
            flags |= (1 << 24)
        if self.pending_suggestions is not None:
            flags |= (1 << 25)
        if self.groupcall_default_join_as is not None:
            flags |= (1 << 26)
        if self.theme_emoticon is not None:
            flags |= (1 << 27)
        if self.recent_requesters is not None:
            flags |= (1 << 28)
        if self.default_send_as is not None:
            flags |= (1 << 29)
        if self.available_reactions is not None:
            flags |= (1 << 30)
        flags2 = 0
        if self.can_delete_channel:
            flags2 |= (1 << 0)
        if self.antispam:
            flags2 |= (1 << 1)
        if self.participants_hidden:
            flags2 |= (1 << 2)
        if self.translations_disabled:
            flags2 |= (1 << 3)
        if self.stories_pinned_available:
            flags2 |= (1 << 5)
        if self.view_forum_as_messages:
            flags2 |= (1 << 6)
        if self.restricted_sponsored:
            flags2 |= (1 << 11)
        if self.can_view_revenue:
            flags2 |= (1 << 12)
        if self.paid_media_allowed:
            flags2 |= (1 << 14)
        if self.can_view_stars_revenue:
            flags2 |= (1 << 15)
        if self.paid_reactions_available:
            flags2 |= (1 << 16)
        if self.stargifts_available:
            flags2 |= (1 << 19)
        if self.paid_messages_available:
            flags2 |= (1 << 20)
        if self.reactions_limit is not None:
            flags2 |= (1 << 13)
        if self.stories is not None:
            flags2 |= (1 << 4)
        if self.wallpaper is not None:
            flags2 |= (1 << 7)
        if self.boosts_applied is not None:
            flags2 |= (1 << 8)
        if self.boosts_unrestrict is not None:
            flags2 |= (1 << 9)
        if self.emojiset is not None:
            flags2 |= (1 << 10)
        if self.bot_verification is not None:
            flags2 |= (1 << 17)
        if self.stargifts_count is not None:
            flags2 |= (1 << 18)
        if self.send_paid_messages_stars is not None:
            flags2 |= (1 << 21)
        if self.main_tab is not None:
            flags2 |= (1 << 22)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<I', flags2))
        buf.write(struct.pack('<q', self.id))
        buf.write(TLObject.serialize_bytes(self.about))
        buf.write(struct.pack('<i', self.read_inbox_max_id))
        buf.write(struct.pack('<i', self.read_outbox_max_id))
        buf.write(struct.pack('<i', self.unread_count))
        buf.write(bytes(self.chat_photo))
        buf.write(bytes(self.notify_settings))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.bot_info)))
        for item in self.bot_info:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', self.pts))
        if self.participants_count is not None:
            buf.write(struct.pack('<i', self.participants_count))
        if self.admins_count is not None:
            buf.write(struct.pack('<i', self.admins_count))
        if self.kicked_count is not None:
            buf.write(struct.pack('<i', self.kicked_count))
        if self.banned_count is not None:
            buf.write(struct.pack('<i', self.banned_count))
        if self.online_count is not None:
            buf.write(struct.pack('<i', self.online_count))
        if self.exported_invite is not None:
            buf.write(bytes(self.exported_invite))
        if self.migrated_from_chat_id is not None:
            buf.write(struct.pack('<q', self.migrated_from_chat_id))
        if self.migrated_from_max_id is not None:
            buf.write(struct.pack('<i', self.migrated_from_max_id))
        if self.pinned_msg_id is not None:
            buf.write(struct.pack('<i', self.pinned_msg_id))
        if self.stickerset is not None:
            buf.write(bytes(self.stickerset))
        if self.available_min_id is not None:
            buf.write(struct.pack('<i', self.available_min_id))
        if self.folder_id is not None:
            buf.write(struct.pack('<i', self.folder_id))
        if self.linked_chat_id is not None:
            buf.write(struct.pack('<q', self.linked_chat_id))
        if self.location is not None:
            buf.write(bytes(self.location))
        if self.slowmode_seconds is not None:
            buf.write(struct.pack('<i', self.slowmode_seconds))
        if self.slowmode_next_send_date is not None:
            buf.write(struct.pack('<i', self.slowmode_next_send_date))
        if self.stats_dc is not None:
            buf.write(struct.pack('<i', self.stats_dc))
        if self.call is not None:
            buf.write(bytes(self.call))
        if self.ttl_period is not None:
            buf.write(struct.pack('<i', self.ttl_period))
        if self.pending_suggestions is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.pending_suggestions)))
            for item in self.pending_suggestions:
                buf.write(TLObject.serialize_bytes(self.item))
        if self.groupcall_default_join_as is not None:
            buf.write(bytes(self.groupcall_default_join_as))
        if self.theme_emoticon is not None:
            buf.write(TLObject.serialize_bytes(self.theme_emoticon))
        if self.requests_pending is not None:
            buf.write(struct.pack('<i', self.requests_pending))
        if self.recent_requesters is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.recent_requesters)))
            for item in self.recent_requesters:
                buf.write(struct.pack('<q', self.item))
        if self.default_send_as is not None:
            buf.write(bytes(self.default_send_as))
        if self.available_reactions is not None:
            buf.write(bytes(self.available_reactions))
        if self.reactions_limit is not None:
            buf.write(struct.pack('<i', self.reactions_limit))
        if self.stories is not None:
            buf.write(bytes(self.stories))
        if self.wallpaper is not None:
            buf.write(bytes(self.wallpaper))
        if self.boosts_applied is not None:
            buf.write(struct.pack('<i', self.boosts_applied))
        if self.boosts_unrestrict is not None:
            buf.write(struct.pack('<i', self.boosts_unrestrict))
        if self.emojiset is not None:
            buf.write(bytes(self.emojiset))
        if self.bot_verification is not None:
            buf.write(bytes(self.bot_verification))
        if self.stargifts_count is not None:
            buf.write(struct.pack('<i', self.stargifts_count))
        if self.send_paid_messages_stars is not None:
            buf.write(struct.pack('<q', self.send_paid_messages_stars))
        if self.main_tab is not None:
            buf.write(bytes(self.main_tab))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['can_view_participants'] = bool(flags & (1 << 3))
        _args['can_set_username'] = bool(flags & (1 << 6))
        _args['can_set_stickers'] = bool(flags & (1 << 7))
        _args['hidden_prehistory'] = bool(flags & (1 << 10))
        _args['can_set_location'] = bool(flags & (1 << 16))
        _args['has_scheduled'] = bool(flags & (1 << 19))
        _args['can_view_stats'] = bool(flags & (1 << 20))
        _args['blocked'] = bool(flags & (1 << 22))
        flags2 = reader.read_int(signed=False)
        _args['can_delete_channel'] = bool(flags2 & (1 << 0))
        _args['antispam'] = bool(flags2 & (1 << 1))
        _args['participants_hidden'] = bool(flags2 & (1 << 2))
        _args['translations_disabled'] = bool(flags2 & (1 << 3))
        _args['stories_pinned_available'] = bool(flags2 & (1 << 5))
        _args['view_forum_as_messages'] = bool(flags2 & (1 << 6))
        _args['restricted_sponsored'] = bool(flags2 & (1 << 11))
        _args['can_view_revenue'] = bool(flags2 & (1 << 12))
        _args['paid_media_allowed'] = bool(flags2 & (1 << 14))
        _args['can_view_stars_revenue'] = bool(flags2 & (1 << 15))
        _args['paid_reactions_available'] = bool(flags2 & (1 << 16))
        _args['stargifts_available'] = bool(flags2 & (1 << 19))
        _args['paid_messages_available'] = bool(flags2 & (1 << 20))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_about = reader.tgread_string()
        _args['about'] = _val_about
        if flags & (1 << 0):
            _val_participants_count = reader.read_int()
            _args['participants_count'] = _val_participants_count
        else:
            _args['participants_count'] = None
        if flags & (1 << 1):
            _val_admins_count = reader.read_int()
            _args['admins_count'] = _val_admins_count
        else:
            _args['admins_count'] = None
        if flags & (1 << 2):
            _val_kicked_count = reader.read_int()
            _args['kicked_count'] = _val_kicked_count
        else:
            _args['kicked_count'] = None
        if flags & (1 << 2):
            _val_banned_count = reader.read_int()
            _args['banned_count'] = _val_banned_count
        else:
            _args['banned_count'] = None
        if flags & (1 << 13):
            _val_online_count = reader.read_int()
            _args['online_count'] = _val_online_count
        else:
            _args['online_count'] = None
        _val_read_inbox_max_id = reader.read_int()
        _args['read_inbox_max_id'] = _val_read_inbox_max_id
        _val_read_outbox_max_id = reader.read_int()
        _args['read_outbox_max_id'] = _val_read_outbox_max_id
        _val_unread_count = reader.read_int()
        _args['unread_count'] = _val_unread_count
        _val_chat_photo = reader.tgread_object()
        _args['chat_photo'] = _val_chat_photo
        _val_notify_settings = reader.tgread_object()
        _args['notify_settings'] = _val_notify_settings
        if flags & (1 << 23):
            _val_exported_invite = reader.tgread_object()
            _args['exported_invite'] = _val_exported_invite
        else:
            _args['exported_invite'] = None
        reader.read_int(signed=False)  # skip vector id
        _count_bot_info = reader.read_int()
        _list_bot_info = []
        for _ in range(_count_bot_info):
            _item_bot_info = reader.tgread_object()
            _list_bot_info.append(_item_bot_info)
        _args['bot_info'] = _list_bot_info
        if flags & (1 << 4):
            _val_migrated_from_chat_id = reader.read_long()
            _args['migrated_from_chat_id'] = _val_migrated_from_chat_id
        else:
            _args['migrated_from_chat_id'] = None
        if flags & (1 << 4):
            _val_migrated_from_max_id = reader.read_int()
            _args['migrated_from_max_id'] = _val_migrated_from_max_id
        else:
            _args['migrated_from_max_id'] = None
        if flags & (1 << 5):
            _val_pinned_msg_id = reader.read_int()
            _args['pinned_msg_id'] = _val_pinned_msg_id
        else:
            _args['pinned_msg_id'] = None
        if flags & (1 << 8):
            _val_stickerset = reader.tgread_object()
            _args['stickerset'] = _val_stickerset
        else:
            _args['stickerset'] = None
        if flags & (1 << 9):
            _val_available_min_id = reader.read_int()
            _args['available_min_id'] = _val_available_min_id
        else:
            _args['available_min_id'] = None
        if flags & (1 << 11):
            _val_folder_id = reader.read_int()
            _args['folder_id'] = _val_folder_id
        else:
            _args['folder_id'] = None
        if flags & (1 << 14):
            _val_linked_chat_id = reader.read_long()
            _args['linked_chat_id'] = _val_linked_chat_id
        else:
            _args['linked_chat_id'] = None
        if flags & (1 << 15):
            _val_location = reader.tgread_object()
            _args['location'] = _val_location
        else:
            _args['location'] = None
        if flags & (1 << 17):
            _val_slowmode_seconds = reader.read_int()
            _args['slowmode_seconds'] = _val_slowmode_seconds
        else:
            _args['slowmode_seconds'] = None
        if flags & (1 << 18):
            _val_slowmode_next_send_date = reader.read_int()
            _args['slowmode_next_send_date'] = _val_slowmode_next_send_date
        else:
            _args['slowmode_next_send_date'] = None
        if flags & (1 << 12):
            _val_stats_dc = reader.read_int()
            _args['stats_dc'] = _val_stats_dc
        else:
            _args['stats_dc'] = None
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        if flags & (1 << 21):
            _val_call = reader.tgread_object()
            _args['call'] = _val_call
        else:
            _args['call'] = None
        if flags & (1 << 24):
            _val_ttl_period = reader.read_int()
            _args['ttl_period'] = _val_ttl_period
        else:
            _args['ttl_period'] = None
        if flags & (1 << 25):
            reader.read_int(signed=False)  # skip vector id
            _count_pending_suggestions = reader.read_int()
            _list_pending_suggestions = []
            for _ in range(_count_pending_suggestions):
                _item_pending_suggestions = reader.tgread_string()
                _list_pending_suggestions.append(_item_pending_suggestions)
            _args['pending_suggestions'] = _list_pending_suggestions
        else:
            _args['pending_suggestions'] = None
        if flags & (1 << 26):
            _val_groupcall_default_join_as = reader.tgread_object()
            _args['groupcall_default_join_as'] = _val_groupcall_default_join_as
        else:
            _args['groupcall_default_join_as'] = None
        if flags & (1 << 27):
            _val_theme_emoticon = reader.tgread_string()
            _args['theme_emoticon'] = _val_theme_emoticon
        else:
            _args['theme_emoticon'] = None
        if flags & (1 << 28):
            _val_requests_pending = reader.read_int()
            _args['requests_pending'] = _val_requests_pending
        else:
            _args['requests_pending'] = None
        if flags & (1 << 28):
            reader.read_int(signed=False)  # skip vector id
            _count_recent_requesters = reader.read_int()
            _list_recent_requesters = []
            for _ in range(_count_recent_requesters):
                _item_recent_requesters = reader.read_long()
                _list_recent_requesters.append(_item_recent_requesters)
            _args['recent_requesters'] = _list_recent_requesters
        else:
            _args['recent_requesters'] = None
        if flags & (1 << 29):
            _val_default_send_as = reader.tgread_object()
            _args['default_send_as'] = _val_default_send_as
        else:
            _args['default_send_as'] = None
        if flags & (1 << 30):
            _val_available_reactions = reader.tgread_object()
            _args['available_reactions'] = _val_available_reactions
        else:
            _args['available_reactions'] = None
        if flags2 & (1 << 13):
            _val_reactions_limit = reader.read_int()
            _args['reactions_limit'] = _val_reactions_limit
        else:
            _args['reactions_limit'] = None
        if flags2 & (1 << 4):
            _val_stories = reader.tgread_object()
            _args['stories'] = _val_stories
        else:
            _args['stories'] = None
        if flags2 & (1 << 7):
            _val_wallpaper = reader.tgread_object()
            _args['wallpaper'] = _val_wallpaper
        else:
            _args['wallpaper'] = None
        if flags2 & (1 << 8):
            _val_boosts_applied = reader.read_int()
            _args['boosts_applied'] = _val_boosts_applied
        else:
            _args['boosts_applied'] = None
        if flags2 & (1 << 9):
            _val_boosts_unrestrict = reader.read_int()
            _args['boosts_unrestrict'] = _val_boosts_unrestrict
        else:
            _args['boosts_unrestrict'] = None
        if flags2 & (1 << 10):
            _val_emojiset = reader.tgread_object()
            _args['emojiset'] = _val_emojiset
        else:
            _args['emojiset'] = None
        if flags2 & (1 << 17):
            _val_bot_verification = reader.tgread_object()
            _args['bot_verification'] = _val_bot_verification
        else:
            _args['bot_verification'] = None
        if flags2 & (1 << 18):
            _val_stargifts_count = reader.read_int()
            _args['stargifts_count'] = _val_stargifts_count
        else:
            _args['stargifts_count'] = None
        if flags2 & (1 << 21):
            _val_send_paid_messages_stars = reader.read_long()
            _args['send_paid_messages_stars'] = _val_send_paid_messages_stars
        else:
            _args['send_paid_messages_stars'] = None
        if flags2 & (1 << 22):
            _val_main_tab = reader.tgread_object()
            _args['main_tab'] = _val_main_tab
        else:
            _args['main_tab'] = None
        return cls(**_args)


class ChannelLocation(TLObject):
    """TL type: channelLocation"""
    CONSTRUCTOR_ID = 0x209b82db
    SUBCLASS_OF_ID = 0xec260b7f

    def __init__(self, geo_point: 'TypeGeoPoint', address: str):
        self.geo_point = geo_point
        self.address = address

    def to_dict(self):
        return {
            '_': 'ChannelLocation',
            'geo_point': self.geo_point,
            'address': self.address,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.geo_point))
        buf.write(TLObject.serialize_bytes(self.address))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_geo_point = reader.tgread_object()
        _args['geo_point'] = _val_geo_point
        _val_address = reader.tgread_string()
        _args['address'] = _val_address
        return cls(**_args)


class ChannelLocationEmpty(TLObject):
    """TL type: channelLocationEmpty"""
    CONSTRUCTOR_ID = 0xbfb5ad8b
    SUBCLASS_OF_ID = 0xec260b7f

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ChannelLocationEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ChannelMessagesFilter(TLObject):
    """TL type: channelMessagesFilter"""
    CONSTRUCTOR_ID = 0xcd77d957
    SUBCLASS_OF_ID = 0x13336a56

    def __init__(self, ranges: List['TypeMessageRange'], exclude_new_messages: Optional[bool] = None):
        self.ranges = ranges
        self.exclude_new_messages = exclude_new_messages

    def to_dict(self):
        return {
            '_': 'ChannelMessagesFilter',
            'ranges': self.ranges,
            'exclude_new_messages': self.exclude_new_messages,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.exclude_new_messages:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.ranges)))
        for item in self.ranges:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['exclude_new_messages'] = bool(flags & (1 << 1))
        reader.read_int(signed=False)  # skip vector id
        _count_ranges = reader.read_int()
        _list_ranges = []
        for _ in range(_count_ranges):
            _item_ranges = reader.tgread_object()
            _list_ranges.append(_item_ranges)
        _args['ranges'] = _list_ranges
        return cls(**_args)


class ChannelMessagesFilterEmpty(TLObject):
    """TL type: channelMessagesFilterEmpty"""
    CONSTRUCTOR_ID = 0x94d42ee7
    SUBCLASS_OF_ID = 0x13336a56

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ChannelMessagesFilterEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ChannelParticipant(TLObject):
    """TL type: channelParticipant"""
    CONSTRUCTOR_ID = 0xcb397619
    SUBCLASS_OF_ID = 0xd9c7fc18

    def __init__(self, user_id: int, date: Optional[datetime], subscription_until_date: Optional[datetime] = None):
        self.user_id = user_id
        self.date = date
        self.subscription_until_date = subscription_until_date

    def to_dict(self):
        return {
            '_': 'ChannelParticipant',
            'user_id': self.user_id,
            'date': self.date,
            'subscription_until_date': self.subscription_until_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.subscription_until_date is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.date))
        if self.subscription_until_date is not None:
            buf.write(struct.pack('<i', self.subscription_until_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 0):
            _val_subscription_until_date = reader.read_int()
            _args['subscription_until_date'] = _val_subscription_until_date
        else:
            _args['subscription_until_date'] = None
        return cls(**_args)


class ChannelParticipantAdmin(TLObject):
    """TL type: channelParticipantAdmin"""
    CONSTRUCTOR_ID = 0x34c3bb53
    SUBCLASS_OF_ID = 0xd9c7fc18

    def __init__(self, user_id: int, promoted_by: int, date: Optional[datetime], admin_rights: 'TypeChatAdminRights', can_edit: Optional[bool] = None, is_self: Optional[bool] = None, inviter_id: Optional[int] = None, rank: Optional[str] = None):
        self.user_id = user_id
        self.promoted_by = promoted_by
        self.date = date
        self.admin_rights = admin_rights
        self.can_edit = can_edit
        self.is_self = is_self
        self.inviter_id = inviter_id
        self.rank = rank

    def to_dict(self):
        return {
            '_': 'ChannelParticipantAdmin',
            'user_id': self.user_id,
            'promoted_by': self.promoted_by,
            'date': self.date,
            'admin_rights': self.admin_rights,
            'can_edit': self.can_edit,
            'is_self': self.is_self,
            'inviter_id': self.inviter_id,
            'rank': self.rank,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.can_edit:
            flags |= (1 << 0)
        if self.inviter_id is not None:
            flags |= (1 << 1)
        if self.rank is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<q', self.promoted_by))
        buf.write(struct.pack('<i', self.date))
        buf.write(bytes(self.admin_rights))
        if self.inviter_id is not None:
            buf.write(struct.pack('<q', self.inviter_id))
        if self.rank is not None:
            buf.write(TLObject.serialize_bytes(self.rank))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['can_edit'] = bool(flags & (1 << 0))
        _args['is_self'] = bool(flags & (1 << 1))
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        if flags & (1 << 1):
            _val_inviter_id = reader.read_long()
            _args['inviter_id'] = _val_inviter_id
        else:
            _args['inviter_id'] = None
        _val_promoted_by = reader.read_long()
        _args['promoted_by'] = _val_promoted_by
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_admin_rights = reader.tgread_object()
        _args['admin_rights'] = _val_admin_rights
        if flags & (1 << 2):
            _val_rank = reader.tgread_string()
            _args['rank'] = _val_rank
        else:
            _args['rank'] = None
        return cls(**_args)


class ChannelParticipantBanned(TLObject):
    """TL type: channelParticipantBanned"""
    CONSTRUCTOR_ID = 0x6df8014e
    SUBCLASS_OF_ID = 0xd9c7fc18

    def __init__(self, peer: 'TypePeer', kicked_by: int, date: Optional[datetime], banned_rights: 'TypeChatBannedRights', left: Optional[bool] = None):
        self.peer = peer
        self.kicked_by = kicked_by
        self.date = date
        self.banned_rights = banned_rights
        self.left = left

    def to_dict(self):
        return {
            '_': 'ChannelParticipantBanned',
            'peer': self.peer,
            'kicked_by': self.kicked_by,
            'date': self.date,
            'banned_rights': self.banned_rights,
            'left': self.left,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.left:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<q', self.kicked_by))
        buf.write(struct.pack('<i', self.date))
        buf.write(bytes(self.banned_rights))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['left'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_kicked_by = reader.read_long()
        _args['kicked_by'] = _val_kicked_by
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_banned_rights = reader.tgread_object()
        _args['banned_rights'] = _val_banned_rights
        return cls(**_args)


class ChannelParticipantCreator(TLObject):
    """TL type: channelParticipantCreator"""
    CONSTRUCTOR_ID = 0x2fe601d3
    SUBCLASS_OF_ID = 0xd9c7fc18

    def __init__(self, user_id: int, admin_rights: 'TypeChatAdminRights', rank: Optional[str] = None):
        self.user_id = user_id
        self.admin_rights = admin_rights
        self.rank = rank

    def to_dict(self):
        return {
            '_': 'ChannelParticipantCreator',
            'user_id': self.user_id,
            'admin_rights': self.admin_rights,
            'rank': self.rank,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.rank is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(bytes(self.admin_rights))
        if self.rank is not None:
            buf.write(TLObject.serialize_bytes(self.rank))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_admin_rights = reader.tgread_object()
        _args['admin_rights'] = _val_admin_rights
        if flags & (1 << 0):
            _val_rank = reader.tgread_string()
            _args['rank'] = _val_rank
        else:
            _args['rank'] = None
        return cls(**_args)


class ChannelParticipantLeft(TLObject):
    """TL type: channelParticipantLeft"""
    CONSTRUCTOR_ID = 0x1b03f006
    SUBCLASS_OF_ID = 0xd9c7fc18

    def __init__(self, peer: 'TypePeer'):
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'ChannelParticipantLeft',
            'peer': self.peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class ChannelParticipantSelf(TLObject):
    """TL type: channelParticipantSelf"""
    CONSTRUCTOR_ID = 0x4f607bef
    SUBCLASS_OF_ID = 0xd9c7fc18

    def __init__(self, user_id: int, inviter_id: int, date: Optional[datetime], via_request: Optional[bool] = None, subscription_until_date: Optional[datetime] = None):
        self.user_id = user_id
        self.inviter_id = inviter_id
        self.date = date
        self.via_request = via_request
        self.subscription_until_date = subscription_until_date

    def to_dict(self):
        return {
            '_': 'ChannelParticipantSelf',
            'user_id': self.user_id,
            'inviter_id': self.inviter_id,
            'date': self.date,
            'via_request': self.via_request,
            'subscription_until_date': self.subscription_until_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.via_request:
            flags |= (1 << 0)
        if self.subscription_until_date is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<q', self.inviter_id))
        buf.write(struct.pack('<i', self.date))
        if self.subscription_until_date is not None:
            buf.write(struct.pack('<i', self.subscription_until_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['via_request'] = bool(flags & (1 << 0))
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_inviter_id = reader.read_long()
        _args['inviter_id'] = _val_inviter_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 1):
            _val_subscription_until_date = reader.read_int()
            _args['subscription_until_date'] = _val_subscription_until_date
        else:
            _args['subscription_until_date'] = None
        return cls(**_args)


class ChannelParticipantsAdmins(TLObject):
    """TL type: channelParticipantsAdmins"""
    CONSTRUCTOR_ID = 0xb4608969
    SUBCLASS_OF_ID = 0xbf4e2753

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ChannelParticipantsAdmins',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ChannelParticipantsBanned(TLObject):
    """TL type: channelParticipantsBanned"""
    CONSTRUCTOR_ID = 0x1427a5e1
    SUBCLASS_OF_ID = 0xbf4e2753

    def __init__(self, q: str):
        self.q = q

    def to_dict(self):
        return {
            '_': 'ChannelParticipantsBanned',
            'q': self.q,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.q))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_q = reader.tgread_string()
        _args['q'] = _val_q
        return cls(**_args)


class ChannelParticipantsBots(TLObject):
    """TL type: channelParticipantsBots"""
    CONSTRUCTOR_ID = 0xb0d1865b
    SUBCLASS_OF_ID = 0xbf4e2753

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ChannelParticipantsBots',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ChannelParticipantsContacts(TLObject):
    """TL type: channelParticipantsContacts"""
    CONSTRUCTOR_ID = 0xbb6ae88d
    SUBCLASS_OF_ID = 0xbf4e2753

    def __init__(self, q: str):
        self.q = q

    def to_dict(self):
        return {
            '_': 'ChannelParticipantsContacts',
            'q': self.q,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.q))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_q = reader.tgread_string()
        _args['q'] = _val_q
        return cls(**_args)


class ChannelParticipantsKicked(TLObject):
    """TL type: channelParticipantsKicked"""
    CONSTRUCTOR_ID = 0xa3b54985
    SUBCLASS_OF_ID = 0xbf4e2753

    def __init__(self, q: str):
        self.q = q

    def to_dict(self):
        return {
            '_': 'ChannelParticipantsKicked',
            'q': self.q,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.q))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_q = reader.tgread_string()
        _args['q'] = _val_q
        return cls(**_args)


class ChannelParticipantsMentions(TLObject):
    """TL type: channelParticipantsMentions"""
    CONSTRUCTOR_ID = 0xe04b5ceb
    SUBCLASS_OF_ID = 0xbf4e2753

    def __init__(self, q: Optional[str] = None, top_msg_id: Optional[int] = None):
        self.q = q
        self.top_msg_id = top_msg_id

    def to_dict(self):
        return {
            '_': 'ChannelParticipantsMentions',
            'q': self.q,
            'top_msg_id': self.top_msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.q is not None:
            flags |= (1 << 0)
        if self.top_msg_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        if self.q is not None:
            buf.write(TLObject.serialize_bytes(self.q))
        if self.top_msg_id is not None:
            buf.write(struct.pack('<i', self.top_msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_q = reader.tgread_string()
            _args['q'] = _val_q
        else:
            _args['q'] = None
        if flags & (1 << 1):
            _val_top_msg_id = reader.read_int()
            _args['top_msg_id'] = _val_top_msg_id
        else:
            _args['top_msg_id'] = None
        return cls(**_args)


class ChannelParticipantsRecent(TLObject):
    """TL type: channelParticipantsRecent"""
    CONSTRUCTOR_ID = 0xde3f3c79
    SUBCLASS_OF_ID = 0xbf4e2753

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ChannelParticipantsRecent',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ChannelParticipantsSearch(TLObject):
    """TL type: channelParticipantsSearch"""
    CONSTRUCTOR_ID = 0x0656ac4b
    SUBCLASS_OF_ID = 0xbf4e2753

    def __init__(self, q: str):
        self.q = q

    def to_dict(self):
        return {
            '_': 'ChannelParticipantsSearch',
            'q': self.q,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.q))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_q = reader.tgread_string()
        _args['q'] = _val_q
        return cls(**_args)


class Chat(TLObject):
    """TL type: chat"""
    CONSTRUCTOR_ID = 0x41cbf256
    SUBCLASS_OF_ID = 0xc5af5d94

    def __init__(self, id: int, title: str, photo: 'TypeChatPhoto', participants_count: int, date: Optional[datetime], version: int, creator: Optional[bool] = None, left: Optional[bool] = None, deactivated: Optional[bool] = None, call_active: Optional[bool] = None, call_not_empty: Optional[bool] = None, noforwards: Optional[bool] = None, migrated_to: Optional['TypeInputChannel'] = None, admin_rights: Optional['TypeChatAdminRights'] = None, default_banned_rights: Optional['TypeChatBannedRights'] = None):
        self.id = id
        self.title = title
        self.photo = photo
        self.participants_count = participants_count
        self.date = date
        self.version = version
        self.creator = creator
        self.left = left
        self.deactivated = deactivated
        self.call_active = call_active
        self.call_not_empty = call_not_empty
        self.noforwards = noforwards
        self.migrated_to = migrated_to
        self.admin_rights = admin_rights
        self.default_banned_rights = default_banned_rights

    def to_dict(self):
        return {
            '_': 'Chat',
            'id': self.id,
            'title': self.title,
            'photo': self.photo,
            'participants_count': self.participants_count,
            'date': self.date,
            'version': self.version,
            'creator': self.creator,
            'left': self.left,
            'deactivated': self.deactivated,
            'call_active': self.call_active,
            'call_not_empty': self.call_not_empty,
            'noforwards': self.noforwards,
            'migrated_to': self.migrated_to,
            'admin_rights': self.admin_rights,
            'default_banned_rights': self.default_banned_rights,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.creator:
            flags |= (1 << 0)
        if self.left:
            flags |= (1 << 2)
        if self.deactivated:
            flags |= (1 << 5)
        if self.call_active:
            flags |= (1 << 23)
        if self.call_not_empty:
            flags |= (1 << 24)
        if self.noforwards:
            flags |= (1 << 25)
        if self.migrated_to is not None:
            flags |= (1 << 6)
        if self.admin_rights is not None:
            flags |= (1 << 14)
        if self.default_banned_rights is not None:
            flags |= (1 << 18)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(bytes(self.photo))
        buf.write(struct.pack('<i', self.participants_count))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.version))
        if self.migrated_to is not None:
            buf.write(bytes(self.migrated_to))
        if self.admin_rights is not None:
            buf.write(bytes(self.admin_rights))
        if self.default_banned_rights is not None:
            buf.write(bytes(self.default_banned_rights))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['creator'] = bool(flags & (1 << 0))
        _args['left'] = bool(flags & (1 << 2))
        _args['deactivated'] = bool(flags & (1 << 5))
        _args['call_active'] = bool(flags & (1 << 23))
        _args['call_not_empty'] = bool(flags & (1 << 24))
        _args['noforwards'] = bool(flags & (1 << 25))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_photo = reader.tgread_object()
        _args['photo'] = _val_photo
        _val_participants_count = reader.read_int()
        _args['participants_count'] = _val_participants_count
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_version = reader.read_int()
        _args['version'] = _val_version
        if flags & (1 << 6):
            _val_migrated_to = reader.tgread_object()
            _args['migrated_to'] = _val_migrated_to
        else:
            _args['migrated_to'] = None
        if flags & (1 << 14):
            _val_admin_rights = reader.tgread_object()
            _args['admin_rights'] = _val_admin_rights
        else:
            _args['admin_rights'] = None
        if flags & (1 << 18):
            _val_default_banned_rights = reader.tgread_object()
            _args['default_banned_rights'] = _val_default_banned_rights
        else:
            _args['default_banned_rights'] = None
        return cls(**_args)


class ChatAdminRights(TLObject):
    """TL type: chatAdminRights"""
    CONSTRUCTOR_ID = 0x5fb224d5
    SUBCLASS_OF_ID = 0x863dc7c4

    def __init__(self, change_info: Optional[bool] = None, post_messages: Optional[bool] = None, edit_messages: Optional[bool] = None, delete_messages: Optional[bool] = None, ban_users: Optional[bool] = None, invite_users: Optional[bool] = None, pin_messages: Optional[bool] = None, add_admins: Optional[bool] = None, anonymous: Optional[bool] = None, manage_call: Optional[bool] = None, other: Optional[bool] = None, manage_topics: Optional[bool] = None, post_stories: Optional[bool] = None, edit_stories: Optional[bool] = None, delete_stories: Optional[bool] = None, manage_direct_messages: Optional[bool] = None):
        self.change_info = change_info
        self.post_messages = post_messages
        self.edit_messages = edit_messages
        self.delete_messages = delete_messages
        self.ban_users = ban_users
        self.invite_users = invite_users
        self.pin_messages = pin_messages
        self.add_admins = add_admins
        self.anonymous = anonymous
        self.manage_call = manage_call
        self.other = other
        self.manage_topics = manage_topics
        self.post_stories = post_stories
        self.edit_stories = edit_stories
        self.delete_stories = delete_stories
        self.manage_direct_messages = manage_direct_messages

    def to_dict(self):
        return {
            '_': 'ChatAdminRights',
            'change_info': self.change_info,
            'post_messages': self.post_messages,
            'edit_messages': self.edit_messages,
            'delete_messages': self.delete_messages,
            'ban_users': self.ban_users,
            'invite_users': self.invite_users,
            'pin_messages': self.pin_messages,
            'add_admins': self.add_admins,
            'anonymous': self.anonymous,
            'manage_call': self.manage_call,
            'other': self.other,
            'manage_topics': self.manage_topics,
            'post_stories': self.post_stories,
            'edit_stories': self.edit_stories,
            'delete_stories': self.delete_stories,
            'manage_direct_messages': self.manage_direct_messages,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.change_info:
            flags |= (1 << 0)
        if self.post_messages:
            flags |= (1 << 1)
        if self.edit_messages:
            flags |= (1 << 2)
        if self.delete_messages:
            flags |= (1 << 3)
        if self.ban_users:
            flags |= (1 << 4)
        if self.invite_users:
            flags |= (1 << 5)
        if self.pin_messages:
            flags |= (1 << 7)
        if self.add_admins:
            flags |= (1 << 9)
        if self.anonymous:
            flags |= (1 << 10)
        if self.manage_call:
            flags |= (1 << 11)
        if self.other:
            flags |= (1 << 12)
        if self.manage_topics:
            flags |= (1 << 13)
        if self.post_stories:
            flags |= (1 << 14)
        if self.edit_stories:
            flags |= (1 << 15)
        if self.delete_stories:
            flags |= (1 << 16)
        if self.manage_direct_messages:
            flags |= (1 << 17)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['change_info'] = bool(flags & (1 << 0))
        _args['post_messages'] = bool(flags & (1 << 1))
        _args['edit_messages'] = bool(flags & (1 << 2))
        _args['delete_messages'] = bool(flags & (1 << 3))
        _args['ban_users'] = bool(flags & (1 << 4))
        _args['invite_users'] = bool(flags & (1 << 5))
        _args['pin_messages'] = bool(flags & (1 << 7))
        _args['add_admins'] = bool(flags & (1 << 9))
        _args['anonymous'] = bool(flags & (1 << 10))
        _args['manage_call'] = bool(flags & (1 << 11))
        _args['other'] = bool(flags & (1 << 12))
        _args['manage_topics'] = bool(flags & (1 << 13))
        _args['post_stories'] = bool(flags & (1 << 14))
        _args['edit_stories'] = bool(flags & (1 << 15))
        _args['delete_stories'] = bool(flags & (1 << 16))
        _args['manage_direct_messages'] = bool(flags & (1 << 17))
        return cls(**_args)


class ChatAdminWithInvites(TLObject):
    """TL type: chatAdminWithInvites"""
    CONSTRUCTOR_ID = 0xf2ecef23
    SUBCLASS_OF_ID = 0x5063f398

    def __init__(self, admin_id: int, invites_count: int, revoked_invites_count: int):
        self.admin_id = admin_id
        self.invites_count = invites_count
        self.revoked_invites_count = revoked_invites_count

    def to_dict(self):
        return {
            '_': 'ChatAdminWithInvites',
            'admin_id': self.admin_id,
            'invites_count': self.invites_count,
            'revoked_invites_count': self.revoked_invites_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.admin_id))
        buf.write(struct.pack('<i', self.invites_count))
        buf.write(struct.pack('<i', self.revoked_invites_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_admin_id = reader.read_long()
        _args['admin_id'] = _val_admin_id
        _val_invites_count = reader.read_int()
        _args['invites_count'] = _val_invites_count
        _val_revoked_invites_count = reader.read_int()
        _args['revoked_invites_count'] = _val_revoked_invites_count
        return cls(**_args)


class ChatBannedRights(TLObject):
    """TL type: chatBannedRights"""
    CONSTRUCTOR_ID = 0x9f120418
    SUBCLASS_OF_ID = 0x4b5445a9

    def __init__(self, until_date: Optional[datetime], view_messages: Optional[bool] = None, send_messages: Optional[bool] = None, send_media: Optional[bool] = None, send_stickers: Optional[bool] = None, send_gifs: Optional[bool] = None, send_games: Optional[bool] = None, send_inline: Optional[bool] = None, embed_links: Optional[bool] = None, send_polls: Optional[bool] = None, change_info: Optional[bool] = None, invite_users: Optional[bool] = None, pin_messages: Optional[bool] = None, manage_topics: Optional[bool] = None, send_photos: Optional[bool] = None, send_videos: Optional[bool] = None, send_roundvideos: Optional[bool] = None, send_audios: Optional[bool] = None, send_voices: Optional[bool] = None, send_docs: Optional[bool] = None, send_plain: Optional[bool] = None):
        self.until_date = until_date
        self.view_messages = view_messages
        self.send_messages = send_messages
        self.send_media = send_media
        self.send_stickers = send_stickers
        self.send_gifs = send_gifs
        self.send_games = send_games
        self.send_inline = send_inline
        self.embed_links = embed_links
        self.send_polls = send_polls
        self.change_info = change_info
        self.invite_users = invite_users
        self.pin_messages = pin_messages
        self.manage_topics = manage_topics
        self.send_photos = send_photos
        self.send_videos = send_videos
        self.send_roundvideos = send_roundvideos
        self.send_audios = send_audios
        self.send_voices = send_voices
        self.send_docs = send_docs
        self.send_plain = send_plain

    def to_dict(self):
        return {
            '_': 'ChatBannedRights',
            'until_date': self.until_date,
            'view_messages': self.view_messages,
            'send_messages': self.send_messages,
            'send_media': self.send_media,
            'send_stickers': self.send_stickers,
            'send_gifs': self.send_gifs,
            'send_games': self.send_games,
            'send_inline': self.send_inline,
            'embed_links': self.embed_links,
            'send_polls': self.send_polls,
            'change_info': self.change_info,
            'invite_users': self.invite_users,
            'pin_messages': self.pin_messages,
            'manage_topics': self.manage_topics,
            'send_photos': self.send_photos,
            'send_videos': self.send_videos,
            'send_roundvideos': self.send_roundvideos,
            'send_audios': self.send_audios,
            'send_voices': self.send_voices,
            'send_docs': self.send_docs,
            'send_plain': self.send_plain,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.view_messages:
            flags |= (1 << 0)
        if self.send_messages:
            flags |= (1 << 1)
        if self.send_media:
            flags |= (1 << 2)
        if self.send_stickers:
            flags |= (1 << 3)
        if self.send_gifs:
            flags |= (1 << 4)
        if self.send_games:
            flags |= (1 << 5)
        if self.send_inline:
            flags |= (1 << 6)
        if self.embed_links:
            flags |= (1 << 7)
        if self.send_polls:
            flags |= (1 << 8)
        if self.change_info:
            flags |= (1 << 10)
        if self.invite_users:
            flags |= (1 << 15)
        if self.pin_messages:
            flags |= (1 << 17)
        if self.manage_topics:
            flags |= (1 << 18)
        if self.send_photos:
            flags |= (1 << 19)
        if self.send_videos:
            flags |= (1 << 20)
        if self.send_roundvideos:
            flags |= (1 << 21)
        if self.send_audios:
            flags |= (1 << 22)
        if self.send_voices:
            flags |= (1 << 23)
        if self.send_docs:
            flags |= (1 << 24)
        if self.send_plain:
            flags |= (1 << 25)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.until_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['view_messages'] = bool(flags & (1 << 0))
        _args['send_messages'] = bool(flags & (1 << 1))
        _args['send_media'] = bool(flags & (1 << 2))
        _args['send_stickers'] = bool(flags & (1 << 3))
        _args['send_gifs'] = bool(flags & (1 << 4))
        _args['send_games'] = bool(flags & (1 << 5))
        _args['send_inline'] = bool(flags & (1 << 6))
        _args['embed_links'] = bool(flags & (1 << 7))
        _args['send_polls'] = bool(flags & (1 << 8))
        _args['change_info'] = bool(flags & (1 << 10))
        _args['invite_users'] = bool(flags & (1 << 15))
        _args['pin_messages'] = bool(flags & (1 << 17))
        _args['manage_topics'] = bool(flags & (1 << 18))
        _args['send_photos'] = bool(flags & (1 << 19))
        _args['send_videos'] = bool(flags & (1 << 20))
        _args['send_roundvideos'] = bool(flags & (1 << 21))
        _args['send_audios'] = bool(flags & (1 << 22))
        _args['send_voices'] = bool(flags & (1 << 23))
        _args['send_docs'] = bool(flags & (1 << 24))
        _args['send_plain'] = bool(flags & (1 << 25))
        _val_until_date = reader.read_int()
        _args['until_date'] = _val_until_date
        return cls(**_args)


class ChatEmpty(TLObject):
    """TL type: chatEmpty"""
    CONSTRUCTOR_ID = 0x29562865
    SUBCLASS_OF_ID = 0xc5af5d94

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'ChatEmpty',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        return cls(**_args)


class ChatForbidden(TLObject):
    """TL type: chatForbidden"""
    CONSTRUCTOR_ID = 0x6592a1a7
    SUBCLASS_OF_ID = 0xc5af5d94

    def __init__(self, id: int, title: str):
        self.id = id
        self.title = title

    def to_dict(self):
        return {
            '_': 'ChatForbidden',
            'id': self.id,
            'title': self.title,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(TLObject.serialize_bytes(self.title))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        return cls(**_args)


class ChatFull(TLObject):
    """TL type: chatFull"""
    CONSTRUCTOR_ID = 0x2633421b
    SUBCLASS_OF_ID = 0xd49a2697

    def __init__(self, id: int, about: str, participants: 'TypeChatParticipants', notify_settings: 'TypePeerNotifySettings', can_set_username: Optional[bool] = None, has_scheduled: Optional[bool] = None, translations_disabled: Optional[bool] = None, chat_photo: Optional['TypePhoto'] = None, exported_invite: Optional['TypeExportedChatInvite'] = None, bot_info: Optional[List['TypeBotInfo']] = None, pinned_msg_id: Optional[int] = None, folder_id: Optional[int] = None, call: Optional['TypeInputGroupCall'] = None, ttl_period: Optional[int] = None, groupcall_default_join_as: Optional['TypePeer'] = None, theme_emoticon: Optional[str] = None, requests_pending: Optional[int] = None, recent_requesters: Optional[List[int]] = None, available_reactions: Optional['TypeChatReactions'] = None, reactions_limit: Optional[int] = None):
        self.id = id
        self.about = about
        self.participants = participants
        self.notify_settings = notify_settings
        self.can_set_username = can_set_username
        self.has_scheduled = has_scheduled
        self.translations_disabled = translations_disabled
        self.chat_photo = chat_photo
        self.exported_invite = exported_invite
        self.bot_info = bot_info
        self.pinned_msg_id = pinned_msg_id
        self.folder_id = folder_id
        self.call = call
        self.ttl_period = ttl_period
        self.groupcall_default_join_as = groupcall_default_join_as
        self.theme_emoticon = theme_emoticon
        self.requests_pending = requests_pending
        self.recent_requesters = recent_requesters
        self.available_reactions = available_reactions
        self.reactions_limit = reactions_limit

    def to_dict(self):
        return {
            '_': 'ChatFull',
            'id': self.id,
            'about': self.about,
            'participants': self.participants,
            'notify_settings': self.notify_settings,
            'can_set_username': self.can_set_username,
            'has_scheduled': self.has_scheduled,
            'translations_disabled': self.translations_disabled,
            'chat_photo': self.chat_photo,
            'exported_invite': self.exported_invite,
            'bot_info': self.bot_info,
            'pinned_msg_id': self.pinned_msg_id,
            'folder_id': self.folder_id,
            'call': self.call,
            'ttl_period': self.ttl_period,
            'groupcall_default_join_as': self.groupcall_default_join_as,
            'theme_emoticon': self.theme_emoticon,
            'requests_pending': self.requests_pending,
            'recent_requesters': self.recent_requesters,
            'available_reactions': self.available_reactions,
            'reactions_limit': self.reactions_limit,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.can_set_username:
            flags |= (1 << 7)
        if self.has_scheduled:
            flags |= (1 << 8)
        if self.translations_disabled:
            flags |= (1 << 19)
        if self.chat_photo is not None:
            flags |= (1 << 2)
        if self.exported_invite is not None:
            flags |= (1 << 13)
        if self.bot_info is not None:
            flags |= (1 << 3)
        if self.pinned_msg_id is not None:
            flags |= (1 << 6)
        if self.folder_id is not None:
            flags |= (1 << 11)
        if self.call is not None:
            flags |= (1 << 12)
        if self.ttl_period is not None:
            flags |= (1 << 14)
        if self.groupcall_default_join_as is not None:
            flags |= (1 << 15)
        if self.theme_emoticon is not None:
            flags |= (1 << 16)
        if self.recent_requesters is not None:
            flags |= (1 << 17)
        if self.available_reactions is not None:
            flags |= (1 << 18)
        if self.reactions_limit is not None:
            flags |= (1 << 20)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(TLObject.serialize_bytes(self.about))
        buf.write(bytes(self.participants))
        buf.write(bytes(self.notify_settings))
        if self.chat_photo is not None:
            buf.write(bytes(self.chat_photo))
        if self.exported_invite is not None:
            buf.write(bytes(self.exported_invite))
        if self.bot_info is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.bot_info)))
            for item in self.bot_info:
                buf.write(bytes(self.item))
        if self.pinned_msg_id is not None:
            buf.write(struct.pack('<i', self.pinned_msg_id))
        if self.folder_id is not None:
            buf.write(struct.pack('<i', self.folder_id))
        if self.call is not None:
            buf.write(bytes(self.call))
        if self.ttl_period is not None:
            buf.write(struct.pack('<i', self.ttl_period))
        if self.groupcall_default_join_as is not None:
            buf.write(bytes(self.groupcall_default_join_as))
        if self.theme_emoticon is not None:
            buf.write(TLObject.serialize_bytes(self.theme_emoticon))
        if self.requests_pending is not None:
            buf.write(struct.pack('<i', self.requests_pending))
        if self.recent_requesters is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.recent_requesters)))
            for item in self.recent_requesters:
                buf.write(struct.pack('<q', self.item))
        if self.available_reactions is not None:
            buf.write(bytes(self.available_reactions))
        if self.reactions_limit is not None:
            buf.write(struct.pack('<i', self.reactions_limit))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['can_set_username'] = bool(flags & (1 << 7))
        _args['has_scheduled'] = bool(flags & (1 << 8))
        _args['translations_disabled'] = bool(flags & (1 << 19))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_about = reader.tgread_string()
        _args['about'] = _val_about
        _val_participants = reader.tgread_object()
        _args['participants'] = _val_participants
        if flags & (1 << 2):
            _val_chat_photo = reader.tgread_object()
            _args['chat_photo'] = _val_chat_photo
        else:
            _args['chat_photo'] = None
        _val_notify_settings = reader.tgread_object()
        _args['notify_settings'] = _val_notify_settings
        if flags & (1 << 13):
            _val_exported_invite = reader.tgread_object()
            _args['exported_invite'] = _val_exported_invite
        else:
            _args['exported_invite'] = None
        if flags & (1 << 3):
            reader.read_int(signed=False)  # skip vector id
            _count_bot_info = reader.read_int()
            _list_bot_info = []
            for _ in range(_count_bot_info):
                _item_bot_info = reader.tgread_object()
                _list_bot_info.append(_item_bot_info)
            _args['bot_info'] = _list_bot_info
        else:
            _args['bot_info'] = None
        if flags & (1 << 6):
            _val_pinned_msg_id = reader.read_int()
            _args['pinned_msg_id'] = _val_pinned_msg_id
        else:
            _args['pinned_msg_id'] = None
        if flags & (1 << 11):
            _val_folder_id = reader.read_int()
            _args['folder_id'] = _val_folder_id
        else:
            _args['folder_id'] = None
        if flags & (1 << 12):
            _val_call = reader.tgread_object()
            _args['call'] = _val_call
        else:
            _args['call'] = None
        if flags & (1 << 14):
            _val_ttl_period = reader.read_int()
            _args['ttl_period'] = _val_ttl_period
        else:
            _args['ttl_period'] = None
        if flags & (1 << 15):
            _val_groupcall_default_join_as = reader.tgread_object()
            _args['groupcall_default_join_as'] = _val_groupcall_default_join_as
        else:
            _args['groupcall_default_join_as'] = None
        if flags & (1 << 16):
            _val_theme_emoticon = reader.tgread_string()
            _args['theme_emoticon'] = _val_theme_emoticon
        else:
            _args['theme_emoticon'] = None
        if flags & (1 << 17):
            _val_requests_pending = reader.read_int()
            _args['requests_pending'] = _val_requests_pending
        else:
            _args['requests_pending'] = None
        if flags & (1 << 17):
            reader.read_int(signed=False)  # skip vector id
            _count_recent_requesters = reader.read_int()
            _list_recent_requesters = []
            for _ in range(_count_recent_requesters):
                _item_recent_requesters = reader.read_long()
                _list_recent_requesters.append(_item_recent_requesters)
            _args['recent_requesters'] = _list_recent_requesters
        else:
            _args['recent_requesters'] = None
        if flags & (1 << 18):
            _val_available_reactions = reader.tgread_object()
            _args['available_reactions'] = _val_available_reactions
        else:
            _args['available_reactions'] = None
        if flags & (1 << 20):
            _val_reactions_limit = reader.read_int()
            _args['reactions_limit'] = _val_reactions_limit
        else:
            _args['reactions_limit'] = None
        return cls(**_args)


class ChatInvite(TLObject):
    """TL type: chatInvite"""
    CONSTRUCTOR_ID = 0x5c9d3702
    SUBCLASS_OF_ID = 0x04561736

    def __init__(self, title: str, photo: 'TypePhoto', participants_count: int, color: int, channel: Optional[bool] = None, broadcast: Optional[bool] = None, public: Optional[bool] = None, megagroup: Optional[bool] = None, request_needed: Optional[bool] = None, verified: Optional[bool] = None, scam: Optional[bool] = None, fake: Optional[bool] = None, can_refulfill_subscription: Optional[bool] = None, about: Optional[str] = None, participants: Optional[List['TypeUser']] = None, subscription_pricing: Optional['TypeStarsSubscriptionPricing'] = None, subscription_form_id: Optional[int] = None, bot_verification: Optional['TypeBotVerification'] = None):
        self.title = title
        self.photo = photo
        self.participants_count = participants_count
        self.color = color
        self.channel = channel
        self.broadcast = broadcast
        self.public = public
        self.megagroup = megagroup
        self.request_needed = request_needed
        self.verified = verified
        self.scam = scam
        self.fake = fake
        self.can_refulfill_subscription = can_refulfill_subscription
        self.about = about
        self.participants = participants
        self.subscription_pricing = subscription_pricing
        self.subscription_form_id = subscription_form_id
        self.bot_verification = bot_verification

    def to_dict(self):
        return {
            '_': 'ChatInvite',
            'title': self.title,
            'photo': self.photo,
            'participants_count': self.participants_count,
            'color': self.color,
            'channel': self.channel,
            'broadcast': self.broadcast,
            'public': self.public,
            'megagroup': self.megagroup,
            'request_needed': self.request_needed,
            'verified': self.verified,
            'scam': self.scam,
            'fake': self.fake,
            'can_refulfill_subscription': self.can_refulfill_subscription,
            'about': self.about,
            'participants': self.participants,
            'subscription_pricing': self.subscription_pricing,
            'subscription_form_id': self.subscription_form_id,
            'bot_verification': self.bot_verification,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.channel:
            flags |= (1 << 0)
        if self.broadcast:
            flags |= (1 << 1)
        if self.public:
            flags |= (1 << 2)
        if self.megagroup:
            flags |= (1 << 3)
        if self.request_needed:
            flags |= (1 << 6)
        if self.verified:
            flags |= (1 << 7)
        if self.scam:
            flags |= (1 << 8)
        if self.fake:
            flags |= (1 << 9)
        if self.can_refulfill_subscription:
            flags |= (1 << 11)
        if self.about is not None:
            flags |= (1 << 5)
        if self.participants is not None:
            flags |= (1 << 4)
        if self.subscription_pricing is not None:
            flags |= (1 << 10)
        if self.subscription_form_id is not None:
            flags |= (1 << 12)
        if self.bot_verification is not None:
            flags |= (1 << 13)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(bytes(self.photo))
        buf.write(struct.pack('<i', self.participants_count))
        buf.write(struct.pack('<i', self.color))
        if self.about is not None:
            buf.write(TLObject.serialize_bytes(self.about))
        if self.participants is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.participants)))
            for item in self.participants:
                buf.write(bytes(self.item))
        if self.subscription_pricing is not None:
            buf.write(bytes(self.subscription_pricing))
        if self.subscription_form_id is not None:
            buf.write(struct.pack('<q', self.subscription_form_id))
        if self.bot_verification is not None:
            buf.write(bytes(self.bot_verification))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['channel'] = bool(flags & (1 << 0))
        _args['broadcast'] = bool(flags & (1 << 1))
        _args['public'] = bool(flags & (1 << 2))
        _args['megagroup'] = bool(flags & (1 << 3))
        _args['request_needed'] = bool(flags & (1 << 6))
        _args['verified'] = bool(flags & (1 << 7))
        _args['scam'] = bool(flags & (1 << 8))
        _args['fake'] = bool(flags & (1 << 9))
        _args['can_refulfill_subscription'] = bool(flags & (1 << 11))
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        if flags & (1 << 5):
            _val_about = reader.tgread_string()
            _args['about'] = _val_about
        else:
            _args['about'] = None
        _val_photo = reader.tgread_object()
        _args['photo'] = _val_photo
        _val_participants_count = reader.read_int()
        _args['participants_count'] = _val_participants_count
        if flags & (1 << 4):
            reader.read_int(signed=False)  # skip vector id
            _count_participants = reader.read_int()
            _list_participants = []
            for _ in range(_count_participants):
                _item_participants = reader.tgread_object()
                _list_participants.append(_item_participants)
            _args['participants'] = _list_participants
        else:
            _args['participants'] = None
        _val_color = reader.read_int()
        _args['color'] = _val_color
        if flags & (1 << 10):
            _val_subscription_pricing = reader.tgread_object()
            _args['subscription_pricing'] = _val_subscription_pricing
        else:
            _args['subscription_pricing'] = None
        if flags & (1 << 12):
            _val_subscription_form_id = reader.read_long()
            _args['subscription_form_id'] = _val_subscription_form_id
        else:
            _args['subscription_form_id'] = None
        if flags & (1 << 13):
            _val_bot_verification = reader.tgread_object()
            _args['bot_verification'] = _val_bot_verification
        else:
            _args['bot_verification'] = None
        return cls(**_args)


class ChatInviteAlready(TLObject):
    """TL type: chatInviteAlready"""
    CONSTRUCTOR_ID = 0x5a686d7c
    SUBCLASS_OF_ID = 0x04561736

    def __init__(self, chat: 'TypeChat'):
        self.chat = chat

    def to_dict(self):
        return {
            '_': 'ChatInviteAlready',
            'chat': self.chat,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.chat))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat = reader.tgread_object()
        _args['chat'] = _val_chat
        return cls(**_args)


class ChatInviteExported(TLObject):
    """TL type: chatInviteExported"""
    CONSTRUCTOR_ID = 0xa22cbd96
    SUBCLASS_OF_ID = 0xb4748a58

    def __init__(self, link: str, admin_id: int, date: Optional[datetime], revoked: Optional[bool] = None, permanent: Optional[bool] = None, request_needed: Optional[bool] = None, start_date: Optional[datetime] = None, expire_date: Optional[datetime] = None, usage_limit: Optional[int] = None, usage: Optional[int] = None, requested: Optional[int] = None, subscription_expired: Optional[int] = None, title: Optional[str] = None, subscription_pricing: Optional['TypeStarsSubscriptionPricing'] = None):
        self.link = link
        self.admin_id = admin_id
        self.date = date
        self.revoked = revoked
        self.permanent = permanent
        self.request_needed = request_needed
        self.start_date = start_date
        self.expire_date = expire_date
        self.usage_limit = usage_limit
        self.usage = usage
        self.requested = requested
        self.subscription_expired = subscription_expired
        self.title = title
        self.subscription_pricing = subscription_pricing

    def to_dict(self):
        return {
            '_': 'ChatInviteExported',
            'link': self.link,
            'admin_id': self.admin_id,
            'date': self.date,
            'revoked': self.revoked,
            'permanent': self.permanent,
            'request_needed': self.request_needed,
            'start_date': self.start_date,
            'expire_date': self.expire_date,
            'usage_limit': self.usage_limit,
            'usage': self.usage,
            'requested': self.requested,
            'subscription_expired': self.subscription_expired,
            'title': self.title,
            'subscription_pricing': self.subscription_pricing,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.revoked:
            flags |= (1 << 0)
        if self.permanent:
            flags |= (1 << 5)
        if self.request_needed:
            flags |= (1 << 6)
        if self.start_date is not None:
            flags |= (1 << 4)
        if self.expire_date is not None:
            flags |= (1 << 1)
        if self.usage_limit is not None:
            flags |= (1 << 2)
        if self.usage is not None:
            flags |= (1 << 3)
        if self.requested is not None:
            flags |= (1 << 7)
        if self.subscription_expired is not None:
            flags |= (1 << 10)
        if self.title is not None:
            flags |= (1 << 8)
        if self.subscription_pricing is not None:
            flags |= (1 << 9)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.link))
        buf.write(struct.pack('<q', self.admin_id))
        buf.write(struct.pack('<i', self.date))
        if self.start_date is not None:
            buf.write(struct.pack('<i', self.start_date))
        if self.expire_date is not None:
            buf.write(struct.pack('<i', self.expire_date))
        if self.usage_limit is not None:
            buf.write(struct.pack('<i', self.usage_limit))
        if self.usage is not None:
            buf.write(struct.pack('<i', self.usage))
        if self.requested is not None:
            buf.write(struct.pack('<i', self.requested))
        if self.subscription_expired is not None:
            buf.write(struct.pack('<i', self.subscription_expired))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.subscription_pricing is not None:
            buf.write(bytes(self.subscription_pricing))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['revoked'] = bool(flags & (1 << 0))
        _args['permanent'] = bool(flags & (1 << 5))
        _args['request_needed'] = bool(flags & (1 << 6))
        _val_link = reader.tgread_string()
        _args['link'] = _val_link
        _val_admin_id = reader.read_long()
        _args['admin_id'] = _val_admin_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 4):
            _val_start_date = reader.read_int()
            _args['start_date'] = _val_start_date
        else:
            _args['start_date'] = None
        if flags & (1 << 1):
            _val_expire_date = reader.read_int()
            _args['expire_date'] = _val_expire_date
        else:
            _args['expire_date'] = None
        if flags & (1 << 2):
            _val_usage_limit = reader.read_int()
            _args['usage_limit'] = _val_usage_limit
        else:
            _args['usage_limit'] = None
        if flags & (1 << 3):
            _val_usage = reader.read_int()
            _args['usage'] = _val_usage
        else:
            _args['usage'] = None
        if flags & (1 << 7):
            _val_requested = reader.read_int()
            _args['requested'] = _val_requested
        else:
            _args['requested'] = None
        if flags & (1 << 10):
            _val_subscription_expired = reader.read_int()
            _args['subscription_expired'] = _val_subscription_expired
        else:
            _args['subscription_expired'] = None
        if flags & (1 << 8):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 9):
            _val_subscription_pricing = reader.tgread_object()
            _args['subscription_pricing'] = _val_subscription_pricing
        else:
            _args['subscription_pricing'] = None
        return cls(**_args)


class ChatInviteImporter(TLObject):
    """TL type: chatInviteImporter"""
    CONSTRUCTOR_ID = 0x8c5adfd9
    SUBCLASS_OF_ID = 0x5312542e

    def __init__(self, user_id: int, date: Optional[datetime], requested: Optional[bool] = None, via_chatlist: Optional[bool] = None, about: Optional[str] = None, approved_by: Optional[int] = None):
        self.user_id = user_id
        self.date = date
        self.requested = requested
        self.via_chatlist = via_chatlist
        self.about = about
        self.approved_by = approved_by

    def to_dict(self):
        return {
            '_': 'ChatInviteImporter',
            'user_id': self.user_id,
            'date': self.date,
            'requested': self.requested,
            'via_chatlist': self.via_chatlist,
            'about': self.about,
            'approved_by': self.approved_by,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.requested:
            flags |= (1 << 0)
        if self.via_chatlist:
            flags |= (1 << 3)
        if self.about is not None:
            flags |= (1 << 2)
        if self.approved_by is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.date))
        if self.about is not None:
            buf.write(TLObject.serialize_bytes(self.about))
        if self.approved_by is not None:
            buf.write(struct.pack('<q', self.approved_by))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['requested'] = bool(flags & (1 << 0))
        _args['via_chatlist'] = bool(flags & (1 << 3))
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 2):
            _val_about = reader.tgread_string()
            _args['about'] = _val_about
        else:
            _args['about'] = None
        if flags & (1 << 1):
            _val_approved_by = reader.read_long()
            _args['approved_by'] = _val_approved_by
        else:
            _args['approved_by'] = None
        return cls(**_args)


class ChatInvitePeek(TLObject):
    """TL type: chatInvitePeek"""
    CONSTRUCTOR_ID = 0x61695cb0
    SUBCLASS_OF_ID = 0x04561736

    def __init__(self, chat: 'TypeChat', expires: Optional[datetime]):
        self.chat = chat
        self.expires = expires

    def to_dict(self):
        return {
            '_': 'ChatInvitePeek',
            'chat': self.chat,
            'expires': self.expires,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.chat))
        buf.write(struct.pack('<i', self.expires))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat = reader.tgread_object()
        _args['chat'] = _val_chat
        _val_expires = reader.read_int()
        _args['expires'] = _val_expires
        return cls(**_args)


class ChatInvitePublicJoinRequests(TLObject):
    """TL type: chatInvitePublicJoinRequests"""
    CONSTRUCTOR_ID = 0xed107ab7
    SUBCLASS_OF_ID = 0xb4748a58

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ChatInvitePublicJoinRequests',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ChatOnlines(TLObject):
    """TL type: chatOnlines"""
    CONSTRUCTOR_ID = 0xf041e250
    SUBCLASS_OF_ID = 0x8c81903a

    def __init__(self, onlines: int):
        self.onlines = onlines

    def to_dict(self):
        return {
            '_': 'ChatOnlines',
            'onlines': self.onlines,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.onlines))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_onlines = reader.read_int()
        _args['onlines'] = _val_onlines
        return cls(**_args)


class ChatParticipant(TLObject):
    """TL type: chatParticipant"""
    CONSTRUCTOR_ID = 0xc02d4007
    SUBCLASS_OF_ID = 0x7d7c6f86

    def __init__(self, user_id: int, inviter_id: int, date: Optional[datetime]):
        self.user_id = user_id
        self.inviter_id = inviter_id
        self.date = date

    def to_dict(self):
        return {
            '_': 'ChatParticipant',
            'user_id': self.user_id,
            'inviter_id': self.inviter_id,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<q', self.inviter_id))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_inviter_id = reader.read_long()
        _args['inviter_id'] = _val_inviter_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class ChatParticipantAdmin(TLObject):
    """TL type: chatParticipantAdmin"""
    CONSTRUCTOR_ID = 0xa0933f5b
    SUBCLASS_OF_ID = 0x7d7c6f86

    def __init__(self, user_id: int, inviter_id: int, date: Optional[datetime]):
        self.user_id = user_id
        self.inviter_id = inviter_id
        self.date = date

    def to_dict(self):
        return {
            '_': 'ChatParticipantAdmin',
            'user_id': self.user_id,
            'inviter_id': self.inviter_id,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<q', self.inviter_id))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_inviter_id = reader.read_long()
        _args['inviter_id'] = _val_inviter_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class ChatParticipantCreator(TLObject):
    """TL type: chatParticipantCreator"""
    CONSTRUCTOR_ID = 0xe46bcee4
    SUBCLASS_OF_ID = 0x7d7c6f86

    def __init__(self, user_id: int):
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'ChatParticipantCreator',
            'user_id': self.user_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class ChatParticipants(TLObject):
    """TL type: chatParticipants"""
    CONSTRUCTOR_ID = 0x3cbc93f8
    SUBCLASS_OF_ID = 0x1fa89571

    def __init__(self, chat_id: int, participants: List['TypeChatParticipant'], version: int):
        self.chat_id = chat_id
        self.participants = participants
        self.version = version

    def to_dict(self):
        return {
            '_': 'ChatParticipants',
            'chat_id': self.chat_id,
            'participants': self.participants,
            'version': self.version,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.chat_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.participants)))
        for item in self.participants:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', self.version))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        reader.read_int(signed=False)  # skip vector id
        _count_participants = reader.read_int()
        _list_participants = []
        for _ in range(_count_participants):
            _item_participants = reader.tgread_object()
            _list_participants.append(_item_participants)
        _args['participants'] = _list_participants
        _val_version = reader.read_int()
        _args['version'] = _val_version
        return cls(**_args)


class ChatParticipantsForbidden(TLObject):
    """TL type: chatParticipantsForbidden"""
    CONSTRUCTOR_ID = 0x8763d3e1
    SUBCLASS_OF_ID = 0x1fa89571

    def __init__(self, chat_id: int, self_participant: Optional['TypeChatParticipant'] = None):
        self.chat_id = chat_id
        self.self_participant = self_participant

    def to_dict(self):
        return {
            '_': 'ChatParticipantsForbidden',
            'chat_id': self.chat_id,
            'self_participant': self.self_participant,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.self_participant is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.chat_id))
        if self.self_participant is not None:
            buf.write(bytes(self.self_participant))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        if flags & (1 << 0):
            _val_self_participant = reader.tgread_object()
            _args['self_participant'] = _val_self_participant
        else:
            _args['self_participant'] = None
        return cls(**_args)


class ChatPhoto(TLObject):
    """TL type: chatPhoto"""
    CONSTRUCTOR_ID = 0x1c6e1c11
    SUBCLASS_OF_ID = 0xac3ec4e5

    def __init__(self, photo_id: int, dc_id: int, has_video: Optional[bool] = None, stripped_thumb: Optional[bytes] = None):
        self.photo_id = photo_id
        self.dc_id = dc_id
        self.has_video = has_video
        self.stripped_thumb = stripped_thumb

    def to_dict(self):
        return {
            '_': 'ChatPhoto',
            'photo_id': self.photo_id,
            'dc_id': self.dc_id,
            'has_video': self.has_video,
            'stripped_thumb': self.stripped_thumb,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.has_video:
            flags |= (1 << 0)
        if self.stripped_thumb is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.photo_id))
        buf.write(struct.pack('<i', self.dc_id))
        if self.stripped_thumb is not None:
            buf.write(TLObject.serialize_bytes(self.stripped_thumb))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['has_video'] = bool(flags & (1 << 0))
        _val_photo_id = reader.read_long()
        _args['photo_id'] = _val_photo_id
        if flags & (1 << 1):
            _val_stripped_thumb = reader.tgread_bytes()
            _args['stripped_thumb'] = _val_stripped_thumb
        else:
            _args['stripped_thumb'] = None
        _val_dc_id = reader.read_int()
        _args['dc_id'] = _val_dc_id
        return cls(**_args)


class ChatPhotoEmpty(TLObject):
    """TL type: chatPhotoEmpty"""
    CONSTRUCTOR_ID = 0x37c1011c
    SUBCLASS_OF_ID = 0xac3ec4e5

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ChatPhotoEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ChatReactionsAll(TLObject):
    """TL type: chatReactionsAll"""
    CONSTRUCTOR_ID = 0x52928bca
    SUBCLASS_OF_ID = 0x131e24b5

    def __init__(self, allow_custom: Optional[bool] = None):
        self.allow_custom = allow_custom

    def to_dict(self):
        return {
            '_': 'ChatReactionsAll',
            'allow_custom': self.allow_custom,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.allow_custom:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['allow_custom'] = bool(flags & (1 << 0))
        return cls(**_args)


class ChatReactionsNone(TLObject):
    """TL type: chatReactionsNone"""
    CONSTRUCTOR_ID = 0xeafc32bc
    SUBCLASS_OF_ID = 0x131e24b5

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ChatReactionsNone',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ChatReactionsSome(TLObject):
    """TL type: chatReactionsSome"""
    CONSTRUCTOR_ID = 0x661d4037
    SUBCLASS_OF_ID = 0x131e24b5

    def __init__(self, reactions: List['TypeReaction']):
        self.reactions = reactions

    def to_dict(self):
        return {
            '_': 'ChatReactionsSome',
            'reactions': self.reactions,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.reactions)))
        for item in self.reactions:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_reactions = reader.read_int()
        _list_reactions = []
        for _ in range(_count_reactions):
            _item_reactions = reader.tgread_object()
            _list_reactions.append(_item_reactions)
        _args['reactions'] = _list_reactions
        return cls(**_args)


class ChatTheme(TLObject):
    """TL type: chatTheme"""
    CONSTRUCTOR_ID = 0xc3dffc04
    SUBCLASS_OF_ID = 0x2ffca7f5

    def __init__(self, emoticon: str):
        self.emoticon = emoticon

    def to_dict(self):
        return {
            '_': 'ChatTheme',
            'emoticon': self.emoticon,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.emoticon))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        return cls(**_args)


class ChatThemeUniqueGift(TLObject):
    """TL type: chatThemeUniqueGift"""
    CONSTRUCTOR_ID = 0x3458f9c8
    SUBCLASS_OF_ID = 0x2ffca7f5

    def __init__(self, gift: 'TypeStarGift', theme_settings: List['TypeThemeSettings']):
        self.gift = gift
        self.theme_settings = theme_settings

    def to_dict(self):
        return {
            '_': 'ChatThemeUniqueGift',
            'gift': self.gift,
            'theme_settings': self.theme_settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.gift))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.theme_settings)))
        for item in self.theme_settings:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_gift = reader.tgread_object()
        _args['gift'] = _val_gift
        reader.read_int(signed=False)  # skip vector id
        _count_theme_settings = reader.read_int()
        _list_theme_settings = []
        for _ in range(_count_theme_settings):
            _item_theme_settings = reader.tgread_object()
            _list_theme_settings.append(_item_theme_settings)
        _args['theme_settings'] = _list_theme_settings
        return cls(**_args)


class CodeSettings(TLObject):
    """TL type: codeSettings"""
    CONSTRUCTOR_ID = 0xad253d78
    SUBCLASS_OF_ID = 0x48edbc8a

    def __init__(self, allow_flashcall: Optional[bool] = None, current_number: Optional[bool] = None, allow_app_hash: Optional[bool] = None, allow_missed_call: Optional[bool] = None, allow_firebase: Optional[bool] = None, unknown_number: Optional[bool] = None, logout_tokens: Optional[List[bytes]] = None, token: Optional[str] = None, app_sandbox: Optional[bool] = None):
        self.allow_flashcall = allow_flashcall
        self.current_number = current_number
        self.allow_app_hash = allow_app_hash
        self.allow_missed_call = allow_missed_call
        self.allow_firebase = allow_firebase
        self.unknown_number = unknown_number
        self.logout_tokens = logout_tokens
        self.token = token
        self.app_sandbox = app_sandbox

    def to_dict(self):
        return {
            '_': 'CodeSettings',
            'allow_flashcall': self.allow_flashcall,
            'current_number': self.current_number,
            'allow_app_hash': self.allow_app_hash,
            'allow_missed_call': self.allow_missed_call,
            'allow_firebase': self.allow_firebase,
            'unknown_number': self.unknown_number,
            'logout_tokens': self.logout_tokens,
            'token': self.token,
            'app_sandbox': self.app_sandbox,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.allow_flashcall:
            flags |= (1 << 0)
        if self.current_number:
            flags |= (1 << 1)
        if self.allow_app_hash:
            flags |= (1 << 4)
        if self.allow_missed_call:
            flags |= (1 << 5)
        if self.allow_firebase:
            flags |= (1 << 7)
        if self.unknown_number:
            flags |= (1 << 9)
        if self.logout_tokens is not None:
            flags |= (1 << 6)
        if self.app_sandbox is not None:
            flags |= (1 << 8)
        buf.write(struct.pack('<I', flags))
        if self.logout_tokens is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.logout_tokens)))
            for item in self.logout_tokens:
                buf.write(TLObject.serialize_bytes(self.item))
        if self.token is not None:
            buf.write(TLObject.serialize_bytes(self.token))
        if self.app_sandbox is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.app_sandbox else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['allow_flashcall'] = bool(flags & (1 << 0))
        _args['current_number'] = bool(flags & (1 << 1))
        _args['allow_app_hash'] = bool(flags & (1 << 4))
        _args['allow_missed_call'] = bool(flags & (1 << 5))
        _args['allow_firebase'] = bool(flags & (1 << 7))
        _args['unknown_number'] = bool(flags & (1 << 9))
        if flags & (1 << 6):
            reader.read_int(signed=False)  # skip vector id
            _count_logout_tokens = reader.read_int()
            _list_logout_tokens = []
            for _ in range(_count_logout_tokens):
                _item_logout_tokens = reader.tgread_bytes()
                _list_logout_tokens.append(_item_logout_tokens)
            _args['logout_tokens'] = _list_logout_tokens
        else:
            _args['logout_tokens'] = None
        if flags & (1 << 8):
            _val_token = reader.tgread_string()
            _args['token'] = _val_token
        else:
            _args['token'] = None
        if flags & (1 << 8):
            _val_app_sandbox = reader.tgread_bool()
            _args['app_sandbox'] = _val_app_sandbox
        else:
            _args['app_sandbox'] = None
        return cls(**_args)


class Config(TLObject):
    """TL type: config"""
    CONSTRUCTOR_ID = 0xcc1a241e
    SUBCLASS_OF_ID = 0xd3262a4a

    def __init__(self, date: Optional[datetime], expires: Optional[datetime], test_mode: bool, this_dc: int, dc_options: List['TypeDcOption'], dc_txt_domain_name: str, chat_size_max: int, megagroup_size_max: int, forwarded_count_max: int, online_update_period_ms: int, offline_blur_timeout_ms: int, offline_idle_timeout_ms: int, online_cloud_timeout_ms: int, notify_cloud_delay_ms: int, notify_default_delay_ms: int, push_chat_period_ms: int, push_chat_limit: int, edit_time_limit: int, revoke_time_limit: int, revoke_pm_time_limit: int, rating_e_decay: int, stickers_recent_limit: int, channels_read_media_period: int, call_receive_timeout_ms: int, call_ring_timeout_ms: int, call_connect_timeout_ms: int, call_packet_timeout_ms: int, me_url_prefix: str, caption_length_max: int, message_length_max: int, webfile_dc_id: int, default_p2p_contacts: Optional[bool] = None, preload_featured_stickers: Optional[bool] = None, revoke_pm_inbox: Optional[bool] = None, blocked_mode: Optional[bool] = None, force_try_ipv6: Optional[bool] = None, tmp_sessions: Optional[int] = None, autoupdate_url_prefix: Optional[str] = None, gif_search_username: Optional[str] = None, venue_search_username: Optional[str] = None, img_search_username: Optional[str] = None, static_maps_provider: Optional[str] = None, suggested_lang_code: Optional[str] = None, lang_pack_version: Optional[int] = None, base_lang_pack_version: Optional[int] = None, reactions_default: Optional['TypeReaction'] = None, autologin_token: Optional[str] = None):
        self.date = date
        self.expires = expires
        self.test_mode = test_mode
        self.this_dc = this_dc
        self.dc_options = dc_options
        self.dc_txt_domain_name = dc_txt_domain_name
        self.chat_size_max = chat_size_max
        self.megagroup_size_max = megagroup_size_max
        self.forwarded_count_max = forwarded_count_max
        self.online_update_period_ms = online_update_period_ms
        self.offline_blur_timeout_ms = offline_blur_timeout_ms
        self.offline_idle_timeout_ms = offline_idle_timeout_ms
        self.online_cloud_timeout_ms = online_cloud_timeout_ms
        self.notify_cloud_delay_ms = notify_cloud_delay_ms
        self.notify_default_delay_ms = notify_default_delay_ms
        self.push_chat_period_ms = push_chat_period_ms
        self.push_chat_limit = push_chat_limit
        self.edit_time_limit = edit_time_limit
        self.revoke_time_limit = revoke_time_limit
        self.revoke_pm_time_limit = revoke_pm_time_limit
        self.rating_e_decay = rating_e_decay
        self.stickers_recent_limit = stickers_recent_limit
        self.channels_read_media_period = channels_read_media_period
        self.call_receive_timeout_ms = call_receive_timeout_ms
        self.call_ring_timeout_ms = call_ring_timeout_ms
        self.call_connect_timeout_ms = call_connect_timeout_ms
        self.call_packet_timeout_ms = call_packet_timeout_ms
        self.me_url_prefix = me_url_prefix
        self.caption_length_max = caption_length_max
        self.message_length_max = message_length_max
        self.webfile_dc_id = webfile_dc_id
        self.default_p2p_contacts = default_p2p_contacts
        self.preload_featured_stickers = preload_featured_stickers
        self.revoke_pm_inbox = revoke_pm_inbox
        self.blocked_mode = blocked_mode
        self.force_try_ipv6 = force_try_ipv6
        self.tmp_sessions = tmp_sessions
        self.autoupdate_url_prefix = autoupdate_url_prefix
        self.gif_search_username = gif_search_username
        self.venue_search_username = venue_search_username
        self.img_search_username = img_search_username
        self.static_maps_provider = static_maps_provider
        self.suggested_lang_code = suggested_lang_code
        self.lang_pack_version = lang_pack_version
        self.base_lang_pack_version = base_lang_pack_version
        self.reactions_default = reactions_default
        self.autologin_token = autologin_token

    def to_dict(self):
        return {
            '_': 'Config',
            'date': self.date,
            'expires': self.expires,
            'test_mode': self.test_mode,
            'this_dc': self.this_dc,
            'dc_options': self.dc_options,
            'dc_txt_domain_name': self.dc_txt_domain_name,
            'chat_size_max': self.chat_size_max,
            'megagroup_size_max': self.megagroup_size_max,
            'forwarded_count_max': self.forwarded_count_max,
            'online_update_period_ms': self.online_update_period_ms,
            'offline_blur_timeout_ms': self.offline_blur_timeout_ms,
            'offline_idle_timeout_ms': self.offline_idle_timeout_ms,
            'online_cloud_timeout_ms': self.online_cloud_timeout_ms,
            'notify_cloud_delay_ms': self.notify_cloud_delay_ms,
            'notify_default_delay_ms': self.notify_default_delay_ms,
            'push_chat_period_ms': self.push_chat_period_ms,
            'push_chat_limit': self.push_chat_limit,
            'edit_time_limit': self.edit_time_limit,
            'revoke_time_limit': self.revoke_time_limit,
            'revoke_pm_time_limit': self.revoke_pm_time_limit,
            'rating_e_decay': self.rating_e_decay,
            'stickers_recent_limit': self.stickers_recent_limit,
            'channels_read_media_period': self.channels_read_media_period,
            'call_receive_timeout_ms': self.call_receive_timeout_ms,
            'call_ring_timeout_ms': self.call_ring_timeout_ms,
            'call_connect_timeout_ms': self.call_connect_timeout_ms,
            'call_packet_timeout_ms': self.call_packet_timeout_ms,
            'me_url_prefix': self.me_url_prefix,
            'caption_length_max': self.caption_length_max,
            'message_length_max': self.message_length_max,
            'webfile_dc_id': self.webfile_dc_id,
            'default_p2p_contacts': self.default_p2p_contacts,
            'preload_featured_stickers': self.preload_featured_stickers,
            'revoke_pm_inbox': self.revoke_pm_inbox,
            'blocked_mode': self.blocked_mode,
            'force_try_ipv6': self.force_try_ipv6,
            'tmp_sessions': self.tmp_sessions,
            'autoupdate_url_prefix': self.autoupdate_url_prefix,
            'gif_search_username': self.gif_search_username,
            'venue_search_username': self.venue_search_username,
            'img_search_username': self.img_search_username,
            'static_maps_provider': self.static_maps_provider,
            'suggested_lang_code': self.suggested_lang_code,
            'lang_pack_version': self.lang_pack_version,
            'base_lang_pack_version': self.base_lang_pack_version,
            'reactions_default': self.reactions_default,
            'autologin_token': self.autologin_token,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.default_p2p_contacts:
            flags |= (1 << 3)
        if self.preload_featured_stickers:
            flags |= (1 << 4)
        if self.revoke_pm_inbox:
            flags |= (1 << 6)
        if self.blocked_mode:
            flags |= (1 << 8)
        if self.force_try_ipv6:
            flags |= (1 << 14)
        if self.tmp_sessions is not None:
            flags |= (1 << 0)
        if self.autoupdate_url_prefix is not None:
            flags |= (1 << 7)
        if self.gif_search_username is not None:
            flags |= (1 << 9)
        if self.venue_search_username is not None:
            flags |= (1 << 10)
        if self.img_search_username is not None:
            flags |= (1 << 11)
        if self.static_maps_provider is not None:
            flags |= (1 << 12)
        if self.base_lang_pack_version is not None:
            flags |= (1 << 2)
        if self.reactions_default is not None:
            flags |= (1 << 15)
        if self.autologin_token is not None:
            flags |= (1 << 16)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.expires))
        buf.write(struct.pack('<I', 0x997275b5 if self.test_mode else 0xbc799737))
        buf.write(struct.pack('<i', self.this_dc))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.dc_options)))
        for item in self.dc_options:
            buf.write(bytes(self.item))
        buf.write(TLObject.serialize_bytes(self.dc_txt_domain_name))
        buf.write(struct.pack('<i', self.chat_size_max))
        buf.write(struct.pack('<i', self.megagroup_size_max))
        buf.write(struct.pack('<i', self.forwarded_count_max))
        buf.write(struct.pack('<i', self.online_update_period_ms))
        buf.write(struct.pack('<i', self.offline_blur_timeout_ms))
        buf.write(struct.pack('<i', self.offline_idle_timeout_ms))
        buf.write(struct.pack('<i', self.online_cloud_timeout_ms))
        buf.write(struct.pack('<i', self.notify_cloud_delay_ms))
        buf.write(struct.pack('<i', self.notify_default_delay_ms))
        buf.write(struct.pack('<i', self.push_chat_period_ms))
        buf.write(struct.pack('<i', self.push_chat_limit))
        buf.write(struct.pack('<i', self.edit_time_limit))
        buf.write(struct.pack('<i', self.revoke_time_limit))
        buf.write(struct.pack('<i', self.revoke_pm_time_limit))
        buf.write(struct.pack('<i', self.rating_e_decay))
        buf.write(struct.pack('<i', self.stickers_recent_limit))
        buf.write(struct.pack('<i', self.channels_read_media_period))
        buf.write(struct.pack('<i', self.call_receive_timeout_ms))
        buf.write(struct.pack('<i', self.call_ring_timeout_ms))
        buf.write(struct.pack('<i', self.call_connect_timeout_ms))
        buf.write(struct.pack('<i', self.call_packet_timeout_ms))
        buf.write(TLObject.serialize_bytes(self.me_url_prefix))
        buf.write(struct.pack('<i', self.caption_length_max))
        buf.write(struct.pack('<i', self.message_length_max))
        buf.write(struct.pack('<i', self.webfile_dc_id))
        if self.tmp_sessions is not None:
            buf.write(struct.pack('<i', self.tmp_sessions))
        if self.autoupdate_url_prefix is not None:
            buf.write(TLObject.serialize_bytes(self.autoupdate_url_prefix))
        if self.gif_search_username is not None:
            buf.write(TLObject.serialize_bytes(self.gif_search_username))
        if self.venue_search_username is not None:
            buf.write(TLObject.serialize_bytes(self.venue_search_username))
        if self.img_search_username is not None:
            buf.write(TLObject.serialize_bytes(self.img_search_username))
        if self.static_maps_provider is not None:
            buf.write(TLObject.serialize_bytes(self.static_maps_provider))
        if self.suggested_lang_code is not None:
            buf.write(TLObject.serialize_bytes(self.suggested_lang_code))
        if self.lang_pack_version is not None:
            buf.write(struct.pack('<i', self.lang_pack_version))
        if self.base_lang_pack_version is not None:
            buf.write(struct.pack('<i', self.base_lang_pack_version))
        if self.reactions_default is not None:
            buf.write(bytes(self.reactions_default))
        if self.autologin_token is not None:
            buf.write(TLObject.serialize_bytes(self.autologin_token))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['default_p2p_contacts'] = bool(flags & (1 << 3))
        _args['preload_featured_stickers'] = bool(flags & (1 << 4))
        _args['revoke_pm_inbox'] = bool(flags & (1 << 6))
        _args['blocked_mode'] = bool(flags & (1 << 8))
        _args['force_try_ipv6'] = bool(flags & (1 << 14))
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_expires = reader.read_int()
        _args['expires'] = _val_expires
        _val_test_mode = reader.tgread_bool()
        _args['test_mode'] = _val_test_mode
        _val_this_dc = reader.read_int()
        _args['this_dc'] = _val_this_dc
        reader.read_int(signed=False)  # skip vector id
        _count_dc_options = reader.read_int()
        _list_dc_options = []
        for _ in range(_count_dc_options):
            _item_dc_options = reader.tgread_object()
            _list_dc_options.append(_item_dc_options)
        _args['dc_options'] = _list_dc_options
        _val_dc_txt_domain_name = reader.tgread_string()
        _args['dc_txt_domain_name'] = _val_dc_txt_domain_name
        _val_chat_size_max = reader.read_int()
        _args['chat_size_max'] = _val_chat_size_max
        _val_megagroup_size_max = reader.read_int()
        _args['megagroup_size_max'] = _val_megagroup_size_max
        _val_forwarded_count_max = reader.read_int()
        _args['forwarded_count_max'] = _val_forwarded_count_max
        _val_online_update_period_ms = reader.read_int()
        _args['online_update_period_ms'] = _val_online_update_period_ms
        _val_offline_blur_timeout_ms = reader.read_int()
        _args['offline_blur_timeout_ms'] = _val_offline_blur_timeout_ms
        _val_offline_idle_timeout_ms = reader.read_int()
        _args['offline_idle_timeout_ms'] = _val_offline_idle_timeout_ms
        _val_online_cloud_timeout_ms = reader.read_int()
        _args['online_cloud_timeout_ms'] = _val_online_cloud_timeout_ms
        _val_notify_cloud_delay_ms = reader.read_int()
        _args['notify_cloud_delay_ms'] = _val_notify_cloud_delay_ms
        _val_notify_default_delay_ms = reader.read_int()
        _args['notify_default_delay_ms'] = _val_notify_default_delay_ms
        _val_push_chat_period_ms = reader.read_int()
        _args['push_chat_period_ms'] = _val_push_chat_period_ms
        _val_push_chat_limit = reader.read_int()
        _args['push_chat_limit'] = _val_push_chat_limit
        _val_edit_time_limit = reader.read_int()
        _args['edit_time_limit'] = _val_edit_time_limit
        _val_revoke_time_limit = reader.read_int()
        _args['revoke_time_limit'] = _val_revoke_time_limit
        _val_revoke_pm_time_limit = reader.read_int()
        _args['revoke_pm_time_limit'] = _val_revoke_pm_time_limit
        _val_rating_e_decay = reader.read_int()
        _args['rating_e_decay'] = _val_rating_e_decay
        _val_stickers_recent_limit = reader.read_int()
        _args['stickers_recent_limit'] = _val_stickers_recent_limit
        _val_channels_read_media_period = reader.read_int()
        _args['channels_read_media_period'] = _val_channels_read_media_period
        if flags & (1 << 0):
            _val_tmp_sessions = reader.read_int()
            _args['tmp_sessions'] = _val_tmp_sessions
        else:
            _args['tmp_sessions'] = None
        _val_call_receive_timeout_ms = reader.read_int()
        _args['call_receive_timeout_ms'] = _val_call_receive_timeout_ms
        _val_call_ring_timeout_ms = reader.read_int()
        _args['call_ring_timeout_ms'] = _val_call_ring_timeout_ms
        _val_call_connect_timeout_ms = reader.read_int()
        _args['call_connect_timeout_ms'] = _val_call_connect_timeout_ms
        _val_call_packet_timeout_ms = reader.read_int()
        _args['call_packet_timeout_ms'] = _val_call_packet_timeout_ms
        _val_me_url_prefix = reader.tgread_string()
        _args['me_url_prefix'] = _val_me_url_prefix
        if flags & (1 << 7):
            _val_autoupdate_url_prefix = reader.tgread_string()
            _args['autoupdate_url_prefix'] = _val_autoupdate_url_prefix
        else:
            _args['autoupdate_url_prefix'] = None
        if flags & (1 << 9):
            _val_gif_search_username = reader.tgread_string()
            _args['gif_search_username'] = _val_gif_search_username
        else:
            _args['gif_search_username'] = None
        if flags & (1 << 10):
            _val_venue_search_username = reader.tgread_string()
            _args['venue_search_username'] = _val_venue_search_username
        else:
            _args['venue_search_username'] = None
        if flags & (1 << 11):
            _val_img_search_username = reader.tgread_string()
            _args['img_search_username'] = _val_img_search_username
        else:
            _args['img_search_username'] = None
        if flags & (1 << 12):
            _val_static_maps_provider = reader.tgread_string()
            _args['static_maps_provider'] = _val_static_maps_provider
        else:
            _args['static_maps_provider'] = None
        _val_caption_length_max = reader.read_int()
        _args['caption_length_max'] = _val_caption_length_max
        _val_message_length_max = reader.read_int()
        _args['message_length_max'] = _val_message_length_max
        _val_webfile_dc_id = reader.read_int()
        _args['webfile_dc_id'] = _val_webfile_dc_id
        if flags & (1 << 2):
            _val_suggested_lang_code = reader.tgread_string()
            _args['suggested_lang_code'] = _val_suggested_lang_code
        else:
            _args['suggested_lang_code'] = None
        if flags & (1 << 2):
            _val_lang_pack_version = reader.read_int()
            _args['lang_pack_version'] = _val_lang_pack_version
        else:
            _args['lang_pack_version'] = None
        if flags & (1 << 2):
            _val_base_lang_pack_version = reader.read_int()
            _args['base_lang_pack_version'] = _val_base_lang_pack_version
        else:
            _args['base_lang_pack_version'] = None
        if flags & (1 << 15):
            _val_reactions_default = reader.tgread_object()
            _args['reactions_default'] = _val_reactions_default
        else:
            _args['reactions_default'] = None
        if flags & (1 << 16):
            _val_autologin_token = reader.tgread_string()
            _args['autologin_token'] = _val_autologin_token
        else:
            _args['autologin_token'] = None
        return cls(**_args)


class ConnectedBot(TLObject):
    """TL type: connectedBot"""
    CONSTRUCTOR_ID = 0xcd64636c
    SUBCLASS_OF_ID = 0x35e81b9e

    def __init__(self, bot_id: int, recipients: 'TypeBusinessBotRecipients', rights: 'TypeBusinessBotRights'):
        self.bot_id = bot_id
        self.recipients = recipients
        self.rights = rights

    def to_dict(self):
        return {
            '_': 'ConnectedBot',
            'bot_id': self.bot_id,
            'recipients': self.recipients,
            'rights': self.rights,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.bot_id))
        buf.write(bytes(self.recipients))
        buf.write(bytes(self.rights))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_bot_id = reader.read_long()
        _args['bot_id'] = _val_bot_id
        _val_recipients = reader.tgread_object()
        _args['recipients'] = _val_recipients
        _val_rights = reader.tgread_object()
        _args['rights'] = _val_rights
        return cls(**_args)


class ConnectedBotStarRef(TLObject):
    """TL type: connectedBotStarRef"""
    CONSTRUCTOR_ID = 0x19a13f71
    SUBCLASS_OF_ID = 0xa0528f8c

    def __init__(self, url: str, date: Optional[datetime], bot_id: int, commission_permille: int, participants: int, revenue: int, revoked: Optional[bool] = None, duration_months: Optional[int] = None):
        self.url = url
        self.date = date
        self.bot_id = bot_id
        self.commission_permille = commission_permille
        self.participants = participants
        self.revenue = revenue
        self.revoked = revoked
        self.duration_months = duration_months

    def to_dict(self):
        return {
            '_': 'ConnectedBotStarRef',
            'url': self.url,
            'date': self.date,
            'bot_id': self.bot_id,
            'commission_permille': self.commission_permille,
            'participants': self.participants,
            'revenue': self.revenue,
            'revoked': self.revoked,
            'duration_months': self.duration_months,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.revoked:
            flags |= (1 << 1)
        if self.duration_months is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.bot_id))
        buf.write(struct.pack('<i', self.commission_permille))
        buf.write(struct.pack('<q', self.participants))
        buf.write(struct.pack('<q', self.revenue))
        if self.duration_months is not None:
            buf.write(struct.pack('<i', self.duration_months))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['revoked'] = bool(flags & (1 << 1))
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_bot_id = reader.read_long()
        _args['bot_id'] = _val_bot_id
        _val_commission_permille = reader.read_int()
        _args['commission_permille'] = _val_commission_permille
        if flags & (1 << 0):
            _val_duration_months = reader.read_int()
            _args['duration_months'] = _val_duration_months
        else:
            _args['duration_months'] = None
        _val_participants = reader.read_long()
        _args['participants'] = _val_participants
        _val_revenue = reader.read_long()
        _args['revenue'] = _val_revenue
        return cls(**_args)


class Contact(TLObject):
    """TL type: contact"""
    CONSTRUCTOR_ID = 0x145ade0b
    SUBCLASS_OF_ID = 0x83dfdfa4

    def __init__(self, user_id: int, mutual: bool):
        self.user_id = user_id
        self.mutual = mutual

    def to_dict(self):
        return {
            '_': 'Contact',
            'user_id': self.user_id,
            'mutual': self.mutual,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<I', 0x997275b5 if self.mutual else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_mutual = reader.tgread_bool()
        _args['mutual'] = _val_mutual
        return cls(**_args)


class ContactBirthday(TLObject):
    """TL type: contactBirthday"""
    CONSTRUCTOR_ID = 0x1d998733
    SUBCLASS_OF_ID = 0xd8dd2806

    def __init__(self, contact_id: int, birthday: 'TypeBirthday'):
        self.contact_id = contact_id
        self.birthday = birthday

    def to_dict(self):
        return {
            '_': 'ContactBirthday',
            'contact_id': self.contact_id,
            'birthday': self.birthday,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.contact_id))
        buf.write(bytes(self.birthday))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_contact_id = reader.read_long()
        _args['contact_id'] = _val_contact_id
        _val_birthday = reader.tgread_object()
        _args['birthday'] = _val_birthday
        return cls(**_args)


class ContactStatus(TLObject):
    """TL type: contactStatus"""
    CONSTRUCTOR_ID = 0x16d9703b
    SUBCLASS_OF_ID = 0x68c0d74c

    def __init__(self, user_id: int, status: 'TypeUserStatus'):
        self.user_id = user_id
        self.status = status

    def to_dict(self):
        return {
            '_': 'ContactStatus',
            'user_id': self.user_id,
            'status': self.status,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(bytes(self.status))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_status = reader.tgread_object()
        _args['status'] = _val_status
        return cls(**_args)


class DataJson(TLObject):
    """TL type: dataJSON"""
    CONSTRUCTOR_ID = 0x7d748d04
    SUBCLASS_OF_ID = 0xad0352e8

    def __init__(self, data: str):
        self.data = data

    def to_dict(self):
        return {
            '_': 'DataJson',
            'data': self.data,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_data = reader.tgread_string()
        _args['data'] = _val_data
        return cls(**_args)


class DcOption(TLObject):
    """TL type: dcOption"""
    CONSTRUCTOR_ID = 0x18b7a10d
    SUBCLASS_OF_ID = 0x9e43e123

    def __init__(self, id: int, ip_address: str, port: int, ipv6: Optional[bool] = None, media_only: Optional[bool] = None, tcpo_only: Optional[bool] = None, cdn: Optional[bool] = None, static: Optional[bool] = None, this_port_only: Optional[bool] = None, secret: Optional[bytes] = None):
        self.id = id
        self.ip_address = ip_address
        self.port = port
        self.ipv6 = ipv6
        self.media_only = media_only
        self.tcpo_only = tcpo_only
        self.cdn = cdn
        self.static = static
        self.this_port_only = this_port_only
        self.secret = secret

    def to_dict(self):
        return {
            '_': 'DcOption',
            'id': self.id,
            'ip_address': self.ip_address,
            'port': self.port,
            'ipv6': self.ipv6,
            'media_only': self.media_only,
            'tcpo_only': self.tcpo_only,
            'cdn': self.cdn,
            'static': self.static,
            'this_port_only': self.this_port_only,
            'secret': self.secret,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.ipv6:
            flags |= (1 << 0)
        if self.media_only:
            flags |= (1 << 1)
        if self.tcpo_only:
            flags |= (1 << 2)
        if self.cdn:
            flags |= (1 << 3)
        if self.static:
            flags |= (1 << 4)
        if self.this_port_only:
            flags |= (1 << 5)
        if self.secret is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(TLObject.serialize_bytes(self.ip_address))
        buf.write(struct.pack('<i', self.port))
        if self.secret is not None:
            buf.write(TLObject.serialize_bytes(self.secret))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['ipv6'] = bool(flags & (1 << 0))
        _args['media_only'] = bool(flags & (1 << 1))
        _args['tcpo_only'] = bool(flags & (1 << 2))
        _args['cdn'] = bool(flags & (1 << 3))
        _args['static'] = bool(flags & (1 << 4))
        _args['this_port_only'] = bool(flags & (1 << 5))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_ip_address = reader.tgread_string()
        _args['ip_address'] = _val_ip_address
        _val_port = reader.read_int()
        _args['port'] = _val_port
        if flags & (1 << 10):
            _val_secret = reader.tgread_bytes()
            _args['secret'] = _val_secret
        else:
            _args['secret'] = None
        return cls(**_args)


class DefaultHistoryTtl(TLObject):
    """TL type: defaultHistoryTTL"""
    CONSTRUCTOR_ID = 0x43b46b20
    SUBCLASS_OF_ID = 0xf00d3367

    def __init__(self, period: int):
        self.period = period

    def to_dict(self):
        return {
            '_': 'DefaultHistoryTtl',
            'period': self.period,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.period))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_period = reader.read_int()
        _args['period'] = _val_period
        return cls(**_args)


class Dialog(TLObject):
    """TL type: dialog"""
    CONSTRUCTOR_ID = 0xd58a08c6
    SUBCLASS_OF_ID = 0x42cddd54

    def __init__(self, peer: 'TypePeer', top_message: int, read_inbox_max_id: int, read_outbox_max_id: int, unread_count: int, unread_mentions_count: int, unread_reactions_count: int, notify_settings: 'TypePeerNotifySettings', pinned: Optional[bool] = None, unread_mark: Optional[bool] = None, view_forum_as_messages: Optional[bool] = None, pts: Optional[int] = None, draft: Optional['TypeDraftMessage'] = None, folder_id: Optional[int] = None, ttl_period: Optional[int] = None):
        self.peer = peer
        self.top_message = top_message
        self.read_inbox_max_id = read_inbox_max_id
        self.read_outbox_max_id = read_outbox_max_id
        self.unread_count = unread_count
        self.unread_mentions_count = unread_mentions_count
        self.unread_reactions_count = unread_reactions_count
        self.notify_settings = notify_settings
        self.pinned = pinned
        self.unread_mark = unread_mark
        self.view_forum_as_messages = view_forum_as_messages
        self.pts = pts
        self.draft = draft
        self.folder_id = folder_id
        self.ttl_period = ttl_period

    def to_dict(self):
        return {
            '_': 'Dialog',
            'peer': self.peer,
            'top_message': self.top_message,
            'read_inbox_max_id': self.read_inbox_max_id,
            'read_outbox_max_id': self.read_outbox_max_id,
            'unread_count': self.unread_count,
            'unread_mentions_count': self.unread_mentions_count,
            'unread_reactions_count': self.unread_reactions_count,
            'notify_settings': self.notify_settings,
            'pinned': self.pinned,
            'unread_mark': self.unread_mark,
            'view_forum_as_messages': self.view_forum_as_messages,
            'pts': self.pts,
            'draft': self.draft,
            'folder_id': self.folder_id,
            'ttl_period': self.ttl_period,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.pinned:
            flags |= (1 << 2)
        if self.unread_mark:
            flags |= (1 << 3)
        if self.view_forum_as_messages:
            flags |= (1 << 6)
        if self.pts is not None:
            flags |= (1 << 0)
        if self.draft is not None:
            flags |= (1 << 1)
        if self.folder_id is not None:
            flags |= (1 << 4)
        if self.ttl_period is not None:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.top_message))
        buf.write(struct.pack('<i', self.read_inbox_max_id))
        buf.write(struct.pack('<i', self.read_outbox_max_id))
        buf.write(struct.pack('<i', self.unread_count))
        buf.write(struct.pack('<i', self.unread_mentions_count))
        buf.write(struct.pack('<i', self.unread_reactions_count))
        buf.write(bytes(self.notify_settings))
        if self.pts is not None:
            buf.write(struct.pack('<i', self.pts))
        if self.draft is not None:
            buf.write(bytes(self.draft))
        if self.folder_id is not None:
            buf.write(struct.pack('<i', self.folder_id))
        if self.ttl_period is not None:
            buf.write(struct.pack('<i', self.ttl_period))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['pinned'] = bool(flags & (1 << 2))
        _args['unread_mark'] = bool(flags & (1 << 3))
        _args['view_forum_as_messages'] = bool(flags & (1 << 6))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_top_message = reader.read_int()
        _args['top_message'] = _val_top_message
        _val_read_inbox_max_id = reader.read_int()
        _args['read_inbox_max_id'] = _val_read_inbox_max_id
        _val_read_outbox_max_id = reader.read_int()
        _args['read_outbox_max_id'] = _val_read_outbox_max_id
        _val_unread_count = reader.read_int()
        _args['unread_count'] = _val_unread_count
        _val_unread_mentions_count = reader.read_int()
        _args['unread_mentions_count'] = _val_unread_mentions_count
        _val_unread_reactions_count = reader.read_int()
        _args['unread_reactions_count'] = _val_unread_reactions_count
        _val_notify_settings = reader.tgread_object()
        _args['notify_settings'] = _val_notify_settings
        if flags & (1 << 0):
            _val_pts = reader.read_int()
            _args['pts'] = _val_pts
        else:
            _args['pts'] = None
        if flags & (1 << 1):
            _val_draft = reader.tgread_object()
            _args['draft'] = _val_draft
        else:
            _args['draft'] = None
        if flags & (1 << 4):
            _val_folder_id = reader.read_int()
            _args['folder_id'] = _val_folder_id
        else:
            _args['folder_id'] = None
        if flags & (1 << 5):
            _val_ttl_period = reader.read_int()
            _args['ttl_period'] = _val_ttl_period
        else:
            _args['ttl_period'] = None
        return cls(**_args)


class DialogFilter(TLObject):
    """TL type: dialogFilter"""
    CONSTRUCTOR_ID = 0xaa472651
    SUBCLASS_OF_ID = 0x692bc457

    def __init__(self, id: int, title: 'TypeTextWithEntities', pinned_peers: List['TypeInputPeer'], include_peers: List['TypeInputPeer'], exclude_peers: List['TypeInputPeer'], contacts: Optional[bool] = None, non_contacts: Optional[bool] = None, groups: Optional[bool] = None, broadcasts: Optional[bool] = None, bots: Optional[bool] = None, exclude_muted: Optional[bool] = None, exclude_read: Optional[bool] = None, exclude_archived: Optional[bool] = None, title_noanimate: Optional[bool] = None, emoticon: Optional[str] = None, color: Optional[int] = None):
        self.id = id
        self.title = title
        self.pinned_peers = pinned_peers
        self.include_peers = include_peers
        self.exclude_peers = exclude_peers
        self.contacts = contacts
        self.non_contacts = non_contacts
        self.groups = groups
        self.broadcasts = broadcasts
        self.bots = bots
        self.exclude_muted = exclude_muted
        self.exclude_read = exclude_read
        self.exclude_archived = exclude_archived
        self.title_noanimate = title_noanimate
        self.emoticon = emoticon
        self.color = color

    def to_dict(self):
        return {
            '_': 'DialogFilter',
            'id': self.id,
            'title': self.title,
            'pinned_peers': self.pinned_peers,
            'include_peers': self.include_peers,
            'exclude_peers': self.exclude_peers,
            'contacts': self.contacts,
            'non_contacts': self.non_contacts,
            'groups': self.groups,
            'broadcasts': self.broadcasts,
            'bots': self.bots,
            'exclude_muted': self.exclude_muted,
            'exclude_read': self.exclude_read,
            'exclude_archived': self.exclude_archived,
            'title_noanimate': self.title_noanimate,
            'emoticon': self.emoticon,
            'color': self.color,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.contacts:
            flags |= (1 << 0)
        if self.non_contacts:
            flags |= (1 << 1)
        if self.groups:
            flags |= (1 << 2)
        if self.broadcasts:
            flags |= (1 << 3)
        if self.bots:
            flags |= (1 << 4)
        if self.exclude_muted:
            flags |= (1 << 11)
        if self.exclude_read:
            flags |= (1 << 12)
        if self.exclude_archived:
            flags |= (1 << 13)
        if self.title_noanimate:
            flags |= (1 << 28)
        if self.emoticon is not None:
            flags |= (1 << 25)
        if self.color is not None:
            flags |= (1 << 27)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(bytes(self.title))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.pinned_peers)))
        for item in self.pinned_peers:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.include_peers)))
        for item in self.include_peers:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.exclude_peers)))
        for item in self.exclude_peers:
            buf.write(bytes(self.item))
        if self.emoticon is not None:
            buf.write(TLObject.serialize_bytes(self.emoticon))
        if self.color is not None:
            buf.write(struct.pack('<i', self.color))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['contacts'] = bool(flags & (1 << 0))
        _args['non_contacts'] = bool(flags & (1 << 1))
        _args['groups'] = bool(flags & (1 << 2))
        _args['broadcasts'] = bool(flags & (1 << 3))
        _args['bots'] = bool(flags & (1 << 4))
        _args['exclude_muted'] = bool(flags & (1 << 11))
        _args['exclude_read'] = bool(flags & (1 << 12))
        _args['exclude_archived'] = bool(flags & (1 << 13))
        _args['title_noanimate'] = bool(flags & (1 << 28))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_title = reader.tgread_object()
        _args['title'] = _val_title
        if flags & (1 << 25):
            _val_emoticon = reader.tgread_string()
            _args['emoticon'] = _val_emoticon
        else:
            _args['emoticon'] = None
        if flags & (1 << 27):
            _val_color = reader.read_int()
            _args['color'] = _val_color
        else:
            _args['color'] = None
        reader.read_int(signed=False)  # skip vector id
        _count_pinned_peers = reader.read_int()
        _list_pinned_peers = []
        for _ in range(_count_pinned_peers):
            _item_pinned_peers = reader.tgread_object()
            _list_pinned_peers.append(_item_pinned_peers)
        _args['pinned_peers'] = _list_pinned_peers
        reader.read_int(signed=False)  # skip vector id
        _count_include_peers = reader.read_int()
        _list_include_peers = []
        for _ in range(_count_include_peers):
            _item_include_peers = reader.tgread_object()
            _list_include_peers.append(_item_include_peers)
        _args['include_peers'] = _list_include_peers
        reader.read_int(signed=False)  # skip vector id
        _count_exclude_peers = reader.read_int()
        _list_exclude_peers = []
        for _ in range(_count_exclude_peers):
            _item_exclude_peers = reader.tgread_object()
            _list_exclude_peers.append(_item_exclude_peers)
        _args['exclude_peers'] = _list_exclude_peers
        return cls(**_args)


class DialogFilterChatlist(TLObject):
    """TL type: dialogFilterChatlist"""
    CONSTRUCTOR_ID = 0x96537bd7
    SUBCLASS_OF_ID = 0x692bc457

    def __init__(self, id: int, title: 'TypeTextWithEntities', pinned_peers: List['TypeInputPeer'], include_peers: List['TypeInputPeer'], has_my_invites: Optional[bool] = None, title_noanimate: Optional[bool] = None, emoticon: Optional[str] = None, color: Optional[int] = None):
        self.id = id
        self.title = title
        self.pinned_peers = pinned_peers
        self.include_peers = include_peers
        self.has_my_invites = has_my_invites
        self.title_noanimate = title_noanimate
        self.emoticon = emoticon
        self.color = color

    def to_dict(self):
        return {
            '_': 'DialogFilterChatlist',
            'id': self.id,
            'title': self.title,
            'pinned_peers': self.pinned_peers,
            'include_peers': self.include_peers,
            'has_my_invites': self.has_my_invites,
            'title_noanimate': self.title_noanimate,
            'emoticon': self.emoticon,
            'color': self.color,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.has_my_invites:
            flags |= (1 << 26)
        if self.title_noanimate:
            flags |= (1 << 28)
        if self.emoticon is not None:
            flags |= (1 << 25)
        if self.color is not None:
            flags |= (1 << 27)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(bytes(self.title))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.pinned_peers)))
        for item in self.pinned_peers:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.include_peers)))
        for item in self.include_peers:
            buf.write(bytes(self.item))
        if self.emoticon is not None:
            buf.write(TLObject.serialize_bytes(self.emoticon))
        if self.color is not None:
            buf.write(struct.pack('<i', self.color))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['has_my_invites'] = bool(flags & (1 << 26))
        _args['title_noanimate'] = bool(flags & (1 << 28))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_title = reader.tgread_object()
        _args['title'] = _val_title
        if flags & (1 << 25):
            _val_emoticon = reader.tgread_string()
            _args['emoticon'] = _val_emoticon
        else:
            _args['emoticon'] = None
        if flags & (1 << 27):
            _val_color = reader.read_int()
            _args['color'] = _val_color
        else:
            _args['color'] = None
        reader.read_int(signed=False)  # skip vector id
        _count_pinned_peers = reader.read_int()
        _list_pinned_peers = []
        for _ in range(_count_pinned_peers):
            _item_pinned_peers = reader.tgread_object()
            _list_pinned_peers.append(_item_pinned_peers)
        _args['pinned_peers'] = _list_pinned_peers
        reader.read_int(signed=False)  # skip vector id
        _count_include_peers = reader.read_int()
        _list_include_peers = []
        for _ in range(_count_include_peers):
            _item_include_peers = reader.tgread_object()
            _list_include_peers.append(_item_include_peers)
        _args['include_peers'] = _list_include_peers
        return cls(**_args)


class DialogFilterDefault(TLObject):
    """TL type: dialogFilterDefault"""
    CONSTRUCTOR_ID = 0x363293ae
    SUBCLASS_OF_ID = 0x692bc457

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'DialogFilterDefault',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class DialogFilterSuggested(TLObject):
    """TL type: dialogFilterSuggested"""
    CONSTRUCTOR_ID = 0x77744d4a
    SUBCLASS_OF_ID = 0x31ede086

    def __init__(self, filter: 'TypeDialogFilter', description: str):
        self.filter = filter
        self.description = description

    def to_dict(self):
        return {
            '_': 'DialogFilterSuggested',
            'filter': self.filter,
            'description': self.description,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.filter))
        buf.write(TLObject.serialize_bytes(self.description))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_filter = reader.tgread_object()
        _args['filter'] = _val_filter
        _val_description = reader.tgread_string()
        _args['description'] = _val_description
        return cls(**_args)


class DialogFolder(TLObject):
    """TL type: dialogFolder"""
    CONSTRUCTOR_ID = 0x71bd134c
    SUBCLASS_OF_ID = 0x42cddd54

    def __init__(self, folder: 'TypeFolder', peer: 'TypePeer', top_message: int, unread_muted_peers_count: int, unread_unmuted_peers_count: int, unread_muted_messages_count: int, unread_unmuted_messages_count: int, pinned: Optional[bool] = None):
        self.folder = folder
        self.peer = peer
        self.top_message = top_message
        self.unread_muted_peers_count = unread_muted_peers_count
        self.unread_unmuted_peers_count = unread_unmuted_peers_count
        self.unread_muted_messages_count = unread_muted_messages_count
        self.unread_unmuted_messages_count = unread_unmuted_messages_count
        self.pinned = pinned

    def to_dict(self):
        return {
            '_': 'DialogFolder',
            'folder': self.folder,
            'peer': self.peer,
            'top_message': self.top_message,
            'unread_muted_peers_count': self.unread_muted_peers_count,
            'unread_unmuted_peers_count': self.unread_unmuted_peers_count,
            'unread_muted_messages_count': self.unread_muted_messages_count,
            'unread_unmuted_messages_count': self.unread_unmuted_messages_count,
            'pinned': self.pinned,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.pinned:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.folder))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.top_message))
        buf.write(struct.pack('<i', self.unread_muted_peers_count))
        buf.write(struct.pack('<i', self.unread_unmuted_peers_count))
        buf.write(struct.pack('<i', self.unread_muted_messages_count))
        buf.write(struct.pack('<i', self.unread_unmuted_messages_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['pinned'] = bool(flags & (1 << 2))
        _val_folder = reader.tgread_object()
        _args['folder'] = _val_folder
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_top_message = reader.read_int()
        _args['top_message'] = _val_top_message
        _val_unread_muted_peers_count = reader.read_int()
        _args['unread_muted_peers_count'] = _val_unread_muted_peers_count
        _val_unread_unmuted_peers_count = reader.read_int()
        _args['unread_unmuted_peers_count'] = _val_unread_unmuted_peers_count
        _val_unread_muted_messages_count = reader.read_int()
        _args['unread_muted_messages_count'] = _val_unread_muted_messages_count
        _val_unread_unmuted_messages_count = reader.read_int()
        _args['unread_unmuted_messages_count'] = _val_unread_unmuted_messages_count
        return cls(**_args)


class DialogPeer(TLObject):
    """TL type: dialogPeer"""
    CONSTRUCTOR_ID = 0xe56dbf05
    SUBCLASS_OF_ID = 0x256ce1ae

    def __init__(self, peer: 'TypePeer'):
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'DialogPeer',
            'peer': self.peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class DialogPeerFolder(TLObject):
    """TL type: dialogPeerFolder"""
    CONSTRUCTOR_ID = 0x514519e2
    SUBCLASS_OF_ID = 0x256ce1ae

    def __init__(self, folder_id: int):
        self.folder_id = folder_id

    def to_dict(self):
        return {
            '_': 'DialogPeerFolder',
            'folder_id': self.folder_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.folder_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_folder_id = reader.read_int()
        _args['folder_id'] = _val_folder_id
        return cls(**_args)


class DisallowedGiftsSettings(TLObject):
    """TL type: disallowedGiftsSettings"""
    CONSTRUCTOR_ID = 0x71f276c4
    SUBCLASS_OF_ID = 0x0382e9ab

    def __init__(self, disallow_unlimited_stargifts: Optional[bool] = None, disallow_limited_stargifts: Optional[bool] = None, disallow_unique_stargifts: Optional[bool] = None, disallow_premium_gifts: Optional[bool] = None, disallow_stargifts_from_channels: Optional[bool] = None):
        self.disallow_unlimited_stargifts = disallow_unlimited_stargifts
        self.disallow_limited_stargifts = disallow_limited_stargifts
        self.disallow_unique_stargifts = disallow_unique_stargifts
        self.disallow_premium_gifts = disallow_premium_gifts
        self.disallow_stargifts_from_channels = disallow_stargifts_from_channels

    def to_dict(self):
        return {
            '_': 'DisallowedGiftsSettings',
            'disallow_unlimited_stargifts': self.disallow_unlimited_stargifts,
            'disallow_limited_stargifts': self.disallow_limited_stargifts,
            'disallow_unique_stargifts': self.disallow_unique_stargifts,
            'disallow_premium_gifts': self.disallow_premium_gifts,
            'disallow_stargifts_from_channels': self.disallow_stargifts_from_channels,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.disallow_unlimited_stargifts:
            flags |= (1 << 0)
        if self.disallow_limited_stargifts:
            flags |= (1 << 1)
        if self.disallow_unique_stargifts:
            flags |= (1 << 2)
        if self.disallow_premium_gifts:
            flags |= (1 << 3)
        if self.disallow_stargifts_from_channels:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['disallow_unlimited_stargifts'] = bool(flags & (1 << 0))
        _args['disallow_limited_stargifts'] = bool(flags & (1 << 1))
        _args['disallow_unique_stargifts'] = bool(flags & (1 << 2))
        _args['disallow_premium_gifts'] = bool(flags & (1 << 3))
        _args['disallow_stargifts_from_channels'] = bool(flags & (1 << 4))
        return cls(**_args)


class Document(TLObject):
    """TL type: document"""
    CONSTRUCTOR_ID = 0x8fd4c4d8
    SUBCLASS_OF_ID = 0x211fe820

    def __init__(self, id: int, access_hash: int, file_reference: bytes, date: Optional[datetime], mime_type: str, size: int, dc_id: int, attributes: List['TypeDocumentAttribute'], thumbs: Optional[List['TypePhotoSize']] = None, video_thumbs: Optional[List['TypeVideoSize']] = None):
        self.id = id
        self.access_hash = access_hash
        self.file_reference = file_reference
        self.date = date
        self.mime_type = mime_type
        self.size = size
        self.dc_id = dc_id
        self.attributes = attributes
        self.thumbs = thumbs
        self.video_thumbs = video_thumbs

    def to_dict(self):
        return {
            '_': 'Document',
            'id': self.id,
            'access_hash': self.access_hash,
            'file_reference': self.file_reference,
            'date': self.date,
            'mime_type': self.mime_type,
            'size': self.size,
            'dc_id': self.dc_id,
            'attributes': self.attributes,
            'thumbs': self.thumbs,
            'video_thumbs': self.video_thumbs,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.thumbs is not None:
            flags |= (1 << 0)
        if self.video_thumbs is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.file_reference))
        buf.write(struct.pack('<i', self.date))
        buf.write(TLObject.serialize_bytes(self.mime_type))
        buf.write(struct.pack('<q', self.size))
        buf.write(struct.pack('<i', self.dc_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.attributes)))
        for item in self.attributes:
            buf.write(bytes(self.item))
        if self.thumbs is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.thumbs)))
            for item in self.thumbs:
                buf.write(bytes(self.item))
        if self.video_thumbs is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.video_thumbs)))
            for item in self.video_thumbs:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_file_reference = reader.tgread_bytes()
        _args['file_reference'] = _val_file_reference
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_mime_type = reader.tgread_string()
        _args['mime_type'] = _val_mime_type
        _val_size = reader.read_long()
        _args['size'] = _val_size
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_thumbs = reader.read_int()
            _list_thumbs = []
            for _ in range(_count_thumbs):
                _item_thumbs = reader.tgread_object()
                _list_thumbs.append(_item_thumbs)
            _args['thumbs'] = _list_thumbs
        else:
            _args['thumbs'] = None
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_video_thumbs = reader.read_int()
            _list_video_thumbs = []
            for _ in range(_count_video_thumbs):
                _item_video_thumbs = reader.tgread_object()
                _list_video_thumbs.append(_item_video_thumbs)
            _args['video_thumbs'] = _list_video_thumbs
        else:
            _args['video_thumbs'] = None
        _val_dc_id = reader.read_int()
        _args['dc_id'] = _val_dc_id
        reader.read_int(signed=False)  # skip vector id
        _count_attributes = reader.read_int()
        _list_attributes = []
        for _ in range(_count_attributes):
            _item_attributes = reader.tgread_object()
            _list_attributes.append(_item_attributes)
        _args['attributes'] = _list_attributes
        return cls(**_args)


class DocumentAttributeAnimated(TLObject):
    """TL type: documentAttributeAnimated"""
    CONSTRUCTOR_ID = 0x11b58939
    SUBCLASS_OF_ID = 0xf729eb9b

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'DocumentAttributeAnimated',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class DocumentAttributeAudio(TLObject):
    """TL type: documentAttributeAudio"""
    CONSTRUCTOR_ID = 0x9852f9c6
    SUBCLASS_OF_ID = 0xf729eb9b

    def __init__(self, duration: int, voice: Optional[bool] = None, title: Optional[str] = None, performer: Optional[str] = None, waveform: Optional[bytes] = None):
        self.duration = duration
        self.voice = voice
        self.title = title
        self.performer = performer
        self.waveform = waveform

    def to_dict(self):
        return {
            '_': 'DocumentAttributeAudio',
            'duration': self.duration,
            'voice': self.voice,
            'title': self.title,
            'performer': self.performer,
            'waveform': self.waveform,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.voice:
            flags |= (1 << 10)
        if self.title is not None:
            flags |= (1 << 0)
        if self.performer is not None:
            flags |= (1 << 1)
        if self.waveform is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.duration))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.performer is not None:
            buf.write(TLObject.serialize_bytes(self.performer))
        if self.waveform is not None:
            buf.write(TLObject.serialize_bytes(self.waveform))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['voice'] = bool(flags & (1 << 10))
        _val_duration = reader.read_int()
        _args['duration'] = _val_duration
        if flags & (1 << 0):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 1):
            _val_performer = reader.tgread_string()
            _args['performer'] = _val_performer
        else:
            _args['performer'] = None
        if flags & (1 << 2):
            _val_waveform = reader.tgread_bytes()
            _args['waveform'] = _val_waveform
        else:
            _args['waveform'] = None
        return cls(**_args)


class DocumentAttributeCustomEmoji(TLObject):
    """TL type: documentAttributeCustomEmoji"""
    CONSTRUCTOR_ID = 0xfd149899
    SUBCLASS_OF_ID = 0xf729eb9b

    def __init__(self, alt: str, stickerset: 'TypeInputStickerSet', free: Optional[bool] = None, text_color: Optional[bool] = None):
        self.alt = alt
        self.stickerset = stickerset
        self.free = free
        self.text_color = text_color

    def to_dict(self):
        return {
            '_': 'DocumentAttributeCustomEmoji',
            'alt': self.alt,
            'stickerset': self.stickerset,
            'free': self.free,
            'text_color': self.text_color,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.free:
            flags |= (1 << 0)
        if self.text_color:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.alt))
        buf.write(bytes(self.stickerset))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['free'] = bool(flags & (1 << 0))
        _args['text_color'] = bool(flags & (1 << 1))
        _val_alt = reader.tgread_string()
        _args['alt'] = _val_alt
        _val_stickerset = reader.tgread_object()
        _args['stickerset'] = _val_stickerset
        return cls(**_args)


class DocumentAttributeFilename(TLObject):
    """TL type: documentAttributeFilename"""
    CONSTRUCTOR_ID = 0x15590068
    SUBCLASS_OF_ID = 0xf729eb9b

    def __init__(self, file_name: str):
        self.file_name = file_name

    def to_dict(self):
        return {
            '_': 'DocumentAttributeFilename',
            'file_name': self.file_name,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.file_name))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_file_name = reader.tgread_string()
        _args['file_name'] = _val_file_name
        return cls(**_args)


class DocumentAttributeHasStickers(TLObject):
    """TL type: documentAttributeHasStickers"""
    CONSTRUCTOR_ID = 0x9801d2f7
    SUBCLASS_OF_ID = 0xf729eb9b

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'DocumentAttributeHasStickers',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class DocumentAttributeImageSize(TLObject):
    """TL type: documentAttributeImageSize"""
    CONSTRUCTOR_ID = 0x6c37c15c
    SUBCLASS_OF_ID = 0xf729eb9b

    def __init__(self, w: int, h: int):
        self.w = w
        self.h = h

    def to_dict(self):
        return {
            '_': 'DocumentAttributeImageSize',
            'w': self.w,
            'h': self.h,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.w))
        buf.write(struct.pack('<i', self.h))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_w = reader.read_int()
        _args['w'] = _val_w
        _val_h = reader.read_int()
        _args['h'] = _val_h
        return cls(**_args)


class DocumentAttributeSticker(TLObject):
    """TL type: documentAttributeSticker"""
    CONSTRUCTOR_ID = 0x6319d612
    SUBCLASS_OF_ID = 0xf729eb9b

    def __init__(self, alt: str, stickerset: 'TypeInputStickerSet', mask: Optional[bool] = None, mask_coords: Optional['TypeMaskCoords'] = None):
        self.alt = alt
        self.stickerset = stickerset
        self.mask = mask
        self.mask_coords = mask_coords

    def to_dict(self):
        return {
            '_': 'DocumentAttributeSticker',
            'alt': self.alt,
            'stickerset': self.stickerset,
            'mask': self.mask,
            'mask_coords': self.mask_coords,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.mask:
            flags |= (1 << 1)
        if self.mask_coords is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.alt))
        buf.write(bytes(self.stickerset))
        if self.mask_coords is not None:
            buf.write(bytes(self.mask_coords))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['mask'] = bool(flags & (1 << 1))
        _val_alt = reader.tgread_string()
        _args['alt'] = _val_alt
        _val_stickerset = reader.tgread_object()
        _args['stickerset'] = _val_stickerset
        if flags & (1 << 0):
            _val_mask_coords = reader.tgread_object()
            _args['mask_coords'] = _val_mask_coords
        else:
            _args['mask_coords'] = None
        return cls(**_args)


class DocumentAttributeVideo(TLObject):
    """TL type: documentAttributeVideo"""
    CONSTRUCTOR_ID = 0x43c57c48
    SUBCLASS_OF_ID = 0xf729eb9b

    def __init__(self, duration: float, w: int, h: int, round_message: Optional[bool] = None, supports_streaming: Optional[bool] = None, nosound: Optional[bool] = None, preload_prefix_size: Optional[int] = None, video_start_ts: Optional[float] = None, video_codec: Optional[str] = None):
        self.duration = duration
        self.w = w
        self.h = h
        self.round_message = round_message
        self.supports_streaming = supports_streaming
        self.nosound = nosound
        self.preload_prefix_size = preload_prefix_size
        self.video_start_ts = video_start_ts
        self.video_codec = video_codec

    def to_dict(self):
        return {
            '_': 'DocumentAttributeVideo',
            'duration': self.duration,
            'w': self.w,
            'h': self.h,
            'round_message': self.round_message,
            'supports_streaming': self.supports_streaming,
            'nosound': self.nosound,
            'preload_prefix_size': self.preload_prefix_size,
            'video_start_ts': self.video_start_ts,
            'video_codec': self.video_codec,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.round_message:
            flags |= (1 << 0)
        if self.supports_streaming:
            flags |= (1 << 1)
        if self.nosound:
            flags |= (1 << 3)
        if self.preload_prefix_size is not None:
            flags |= (1 << 2)
        if self.video_start_ts is not None:
            flags |= (1 << 4)
        if self.video_codec is not None:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<d', self.duration))
        buf.write(struct.pack('<i', self.w))
        buf.write(struct.pack('<i', self.h))
        if self.preload_prefix_size is not None:
            buf.write(struct.pack('<i', self.preload_prefix_size))
        if self.video_start_ts is not None:
            buf.write(struct.pack('<d', self.video_start_ts))
        if self.video_codec is not None:
            buf.write(TLObject.serialize_bytes(self.video_codec))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['round_message'] = bool(flags & (1 << 0))
        _args['supports_streaming'] = bool(flags & (1 << 1))
        _args['nosound'] = bool(flags & (1 << 3))
        _val_duration = reader.read_double()
        _args['duration'] = _val_duration
        _val_w = reader.read_int()
        _args['w'] = _val_w
        _val_h = reader.read_int()
        _args['h'] = _val_h
        if flags & (1 << 2):
            _val_preload_prefix_size = reader.read_int()
            _args['preload_prefix_size'] = _val_preload_prefix_size
        else:
            _args['preload_prefix_size'] = None
        if flags & (1 << 4):
            _val_video_start_ts = reader.read_double()
            _args['video_start_ts'] = _val_video_start_ts
        else:
            _args['video_start_ts'] = None
        if flags & (1 << 5):
            _val_video_codec = reader.tgread_string()
            _args['video_codec'] = _val_video_codec
        else:
            _args['video_codec'] = None
        return cls(**_args)


class DocumentEmpty(TLObject):
    """TL type: documentEmpty"""
    CONSTRUCTOR_ID = 0x36f8c871
    SUBCLASS_OF_ID = 0x211fe820

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'DocumentEmpty',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        return cls(**_args)


class DraftMessage(TLObject):
    """TL type: draftMessage"""
    CONSTRUCTOR_ID = 0x96eaa5eb
    SUBCLASS_OF_ID = 0x33d47f45

    def __init__(self, message: str, date: Optional[datetime], no_webpage: Optional[bool] = None, invert_media: Optional[bool] = None, reply_to: Optional['TypeInputReplyTo'] = None, entities: Optional[List['TypeMessageEntity']] = None, media: Optional['TypeInputMedia'] = None, effect: Optional[int] = None, suggested_post: Optional['TypeSuggestedPost'] = None):
        self.message = message
        self.date = date
        self.no_webpage = no_webpage
        self.invert_media = invert_media
        self.reply_to = reply_to
        self.entities = entities
        self.media = media
        self.effect = effect
        self.suggested_post = suggested_post

    def to_dict(self):
        return {
            '_': 'DraftMessage',
            'message': self.message,
            'date': self.date,
            'no_webpage': self.no_webpage,
            'invert_media': self.invert_media,
            'reply_to': self.reply_to,
            'entities': self.entities,
            'media': self.media,
            'effect': self.effect,
            'suggested_post': self.suggested_post,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.no_webpage:
            flags |= (1 << 1)
        if self.invert_media:
            flags |= (1 << 6)
        if self.reply_to is not None:
            flags |= (1 << 4)
        if self.entities is not None:
            flags |= (1 << 3)
        if self.media is not None:
            flags |= (1 << 5)
        if self.effect is not None:
            flags |= (1 << 7)
        if self.suggested_post is not None:
            flags |= (1 << 8)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.message))
        buf.write(struct.pack('<i', self.date))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.media is not None:
            buf.write(bytes(self.media))
        if self.effect is not None:
            buf.write(struct.pack('<q', self.effect))
        if self.suggested_post is not None:
            buf.write(bytes(self.suggested_post))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['no_webpage'] = bool(flags & (1 << 1))
        _args['invert_media'] = bool(flags & (1 << 6))
        if flags & (1 << 4):
            _val_reply_to = reader.tgread_object()
            _args['reply_to'] = _val_reply_to
        else:
            _args['reply_to'] = None
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 3):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 5):
            _val_media = reader.tgread_object()
            _args['media'] = _val_media
        else:
            _args['media'] = None
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 7):
            _val_effect = reader.read_long()
            _args['effect'] = _val_effect
        else:
            _args['effect'] = None
        if flags & (1 << 8):
            _val_suggested_post = reader.tgread_object()
            _args['suggested_post'] = _val_suggested_post
        else:
            _args['suggested_post'] = None
        return cls(**_args)


class DraftMessageEmpty(TLObject):
    """TL type: draftMessageEmpty"""
    CONSTRUCTOR_ID = 0x1b0c841a
    SUBCLASS_OF_ID = 0x33d47f45

    def __init__(self, date: Optional[datetime] = None):
        self.date = date

    def to_dict(self):
        return {
            '_': 'DraftMessageEmpty',
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.date is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        if self.date is not None:
            buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_date = reader.read_int()
            _args['date'] = _val_date
        else:
            _args['date'] = None
        return cls(**_args)


class EmailVerificationApple(TLObject):
    """TL type: emailVerificationApple"""
    CONSTRUCTOR_ID = 0x96d074fd
    SUBCLASS_OF_ID = 0x241ee240

    def __init__(self, token: str):
        self.token = token

    def to_dict(self):
        return {
            '_': 'EmailVerificationApple',
            'token': self.token,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.token))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_token = reader.tgread_string()
        _args['token'] = _val_token
        return cls(**_args)


class EmailVerificationCode(TLObject):
    """TL type: emailVerificationCode"""
    CONSTRUCTOR_ID = 0x922e55a9
    SUBCLASS_OF_ID = 0x241ee240

    def __init__(self, code: str):
        self.code = code

    def to_dict(self):
        return {
            '_': 'EmailVerificationCode',
            'code': self.code,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.code))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_code = reader.tgread_string()
        _args['code'] = _val_code
        return cls(**_args)


class EmailVerificationGoogle(TLObject):
    """TL type: emailVerificationGoogle"""
    CONSTRUCTOR_ID = 0xdb909ec2
    SUBCLASS_OF_ID = 0x241ee240

    def __init__(self, token: str):
        self.token = token

    def to_dict(self):
        return {
            '_': 'EmailVerificationGoogle',
            'token': self.token,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.token))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_token = reader.tgread_string()
        _args['token'] = _val_token
        return cls(**_args)


class EmailVerifyPurposeLoginChange(TLObject):
    """TL type: emailVerifyPurposeLoginChange"""
    CONSTRUCTOR_ID = 0x527d22eb
    SUBCLASS_OF_ID = 0xb9686ae8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'EmailVerifyPurposeLoginChange',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class EmailVerifyPurposeLoginSetup(TLObject):
    """TL type: emailVerifyPurposeLoginSetup"""
    CONSTRUCTOR_ID = 0x4345be73
    SUBCLASS_OF_ID = 0xb9686ae8

    def __init__(self, phone_number: str, phone_code_hash: str):
        self.phone_number = phone_number
        self.phone_code_hash = phone_code_hash

    def to_dict(self):
        return {
            '_': 'EmailVerifyPurposeLoginSetup',
            'phone_number': self.phone_number,
            'phone_code_hash': self.phone_code_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.phone_code_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_phone_code_hash = reader.tgread_string()
        _args['phone_code_hash'] = _val_phone_code_hash
        return cls(**_args)


class EmailVerifyPurposePassport(TLObject):
    """TL type: emailVerifyPurposePassport"""
    CONSTRUCTOR_ID = 0xbbf51685
    SUBCLASS_OF_ID = 0xb9686ae8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'EmailVerifyPurposePassport',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class EmojiGroup(TLObject):
    """TL type: emojiGroup"""
    CONSTRUCTOR_ID = 0x7a9abda9
    SUBCLASS_OF_ID = 0x55e0a193

    def __init__(self, title: str, icon_emoji_id: int, emoticons: List[str]):
        self.title = title
        self.icon_emoji_id = icon_emoji_id
        self.emoticons = emoticons

    def to_dict(self):
        return {
            '_': 'EmojiGroup',
            'title': self.title,
            'icon_emoji_id': self.icon_emoji_id,
            'emoticons': self.emoticons,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(struct.pack('<q', self.icon_emoji_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.emoticons)))
        for item in self.emoticons:
            buf.write(TLObject.serialize_bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_icon_emoji_id = reader.read_long()
        _args['icon_emoji_id'] = _val_icon_emoji_id
        reader.read_int(signed=False)  # skip vector id
        _count_emoticons = reader.read_int()
        _list_emoticons = []
        for _ in range(_count_emoticons):
            _item_emoticons = reader.tgread_string()
            _list_emoticons.append(_item_emoticons)
        _args['emoticons'] = _list_emoticons
        return cls(**_args)


class EmojiGroupGreeting(TLObject):
    """TL type: emojiGroupGreeting"""
    CONSTRUCTOR_ID = 0x80d26cc7
    SUBCLASS_OF_ID = 0x55e0a193

    def __init__(self, title: str, icon_emoji_id: int, emoticons: List[str]):
        self.title = title
        self.icon_emoji_id = icon_emoji_id
        self.emoticons = emoticons

    def to_dict(self):
        return {
            '_': 'EmojiGroupGreeting',
            'title': self.title,
            'icon_emoji_id': self.icon_emoji_id,
            'emoticons': self.emoticons,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(struct.pack('<q', self.icon_emoji_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.emoticons)))
        for item in self.emoticons:
            buf.write(TLObject.serialize_bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_icon_emoji_id = reader.read_long()
        _args['icon_emoji_id'] = _val_icon_emoji_id
        reader.read_int(signed=False)  # skip vector id
        _count_emoticons = reader.read_int()
        _list_emoticons = []
        for _ in range(_count_emoticons):
            _item_emoticons = reader.tgread_string()
            _list_emoticons.append(_item_emoticons)
        _args['emoticons'] = _list_emoticons
        return cls(**_args)


class EmojiGroupPremium(TLObject):
    """TL type: emojiGroupPremium"""
    CONSTRUCTOR_ID = 0x093bcf34
    SUBCLASS_OF_ID = 0x55e0a193

    def __init__(self, title: str, icon_emoji_id: int):
        self.title = title
        self.icon_emoji_id = icon_emoji_id

    def to_dict(self):
        return {
            '_': 'EmojiGroupPremium',
            'title': self.title,
            'icon_emoji_id': self.icon_emoji_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(struct.pack('<q', self.icon_emoji_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_icon_emoji_id = reader.read_long()
        _args['icon_emoji_id'] = _val_icon_emoji_id
        return cls(**_args)


class EmojiKeyword(TLObject):
    """TL type: emojiKeyword"""
    CONSTRUCTOR_ID = 0xd5b3b9f9
    SUBCLASS_OF_ID = 0x6612a53e

    def __init__(self, keyword: str, emoticons: List[str]):
        self.keyword = keyword
        self.emoticons = emoticons

    def to_dict(self):
        return {
            '_': 'EmojiKeyword',
            'keyword': self.keyword,
            'emoticons': self.emoticons,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.keyword))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.emoticons)))
        for item in self.emoticons:
            buf.write(TLObject.serialize_bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_keyword = reader.tgread_string()
        _args['keyword'] = _val_keyword
        reader.read_int(signed=False)  # skip vector id
        _count_emoticons = reader.read_int()
        _list_emoticons = []
        for _ in range(_count_emoticons):
            _item_emoticons = reader.tgread_string()
            _list_emoticons.append(_item_emoticons)
        _args['emoticons'] = _list_emoticons
        return cls(**_args)


class EmojiKeywordDeleted(TLObject):
    """TL type: emojiKeywordDeleted"""
    CONSTRUCTOR_ID = 0x236df622
    SUBCLASS_OF_ID = 0x6612a53e

    def __init__(self, keyword: str, emoticons: List[str]):
        self.keyword = keyword
        self.emoticons = emoticons

    def to_dict(self):
        return {
            '_': 'EmojiKeywordDeleted',
            'keyword': self.keyword,
            'emoticons': self.emoticons,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.keyword))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.emoticons)))
        for item in self.emoticons:
            buf.write(TLObject.serialize_bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_keyword = reader.tgread_string()
        _args['keyword'] = _val_keyword
        reader.read_int(signed=False)  # skip vector id
        _count_emoticons = reader.read_int()
        _list_emoticons = []
        for _ in range(_count_emoticons):
            _item_emoticons = reader.tgread_string()
            _list_emoticons.append(_item_emoticons)
        _args['emoticons'] = _list_emoticons
        return cls(**_args)


class EmojiKeywordsDifference(TLObject):
    """TL type: emojiKeywordsDifference"""
    CONSTRUCTOR_ID = 0x5cc761bd
    SUBCLASS_OF_ID = 0xd279c672

    def __init__(self, lang_code: str, from_version: int, version: int, keywords: List['TypeEmojiKeyword']):
        self.lang_code = lang_code
        self.from_version = from_version
        self.version = version
        self.keywords = keywords

    def to_dict(self):
        return {
            '_': 'EmojiKeywordsDifference',
            'lang_code': self.lang_code,
            'from_version': self.from_version,
            'version': self.version,
            'keywords': self.keywords,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.lang_code))
        buf.write(struct.pack('<i', self.from_version))
        buf.write(struct.pack('<i', self.version))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.keywords)))
        for item in self.keywords:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        _val_from_version = reader.read_int()
        _args['from_version'] = _val_from_version
        _val_version = reader.read_int()
        _args['version'] = _val_version
        reader.read_int(signed=False)  # skip vector id
        _count_keywords = reader.read_int()
        _list_keywords = []
        for _ in range(_count_keywords):
            _item_keywords = reader.tgread_object()
            _list_keywords.append(_item_keywords)
        _args['keywords'] = _list_keywords
        return cls(**_args)


class EmojiLanguage(TLObject):
    """TL type: emojiLanguage"""
    CONSTRUCTOR_ID = 0xb3fb5361
    SUBCLASS_OF_ID = 0xa48d04ee

    def __init__(self, lang_code: str):
        self.lang_code = lang_code

    def to_dict(self):
        return {
            '_': 'EmojiLanguage',
            'lang_code': self.lang_code,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.lang_code))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        return cls(**_args)


class EmojiList(TLObject):
    """TL type: emojiList"""
    CONSTRUCTOR_ID = 0x7a1e11d1
    SUBCLASS_OF_ID = 0xbcef6aba

    def __init__(self, hash: int, document_id: List[int]):
        self.hash = hash
        self.document_id = document_id

    def to_dict(self):
        return {
            '_': 'EmojiList',
            'hash': self.hash,
            'document_id': self.document_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.hash))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.document_id)))
        for item in self.document_id:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        reader.read_int(signed=False)  # skip vector id
        _count_document_id = reader.read_int()
        _list_document_id = []
        for _ in range(_count_document_id):
            _item_document_id = reader.read_long()
            _list_document_id.append(_item_document_id)
        _args['document_id'] = _list_document_id
        return cls(**_args)


class EmojiListNotModified(TLObject):
    """TL type: emojiListNotModified"""
    CONSTRUCTOR_ID = 0x481eadfa
    SUBCLASS_OF_ID = 0xbcef6aba

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'EmojiListNotModified',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class EmojiStatus(TLObject):
    """TL type: emojiStatus"""
    CONSTRUCTOR_ID = 0xe7ff068a
    SUBCLASS_OF_ID = 0xf930b138

    def __init__(self, document_id: int, until: Optional[datetime] = None):
        self.document_id = document_id
        self.until = until

    def to_dict(self):
        return {
            '_': 'EmojiStatus',
            'document_id': self.document_id,
            'until': self.until,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.until is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.document_id))
        if self.until is not None:
            buf.write(struct.pack('<i', self.until))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_document_id = reader.read_long()
        _args['document_id'] = _val_document_id
        if flags & (1 << 0):
            _val_until = reader.read_int()
            _args['until'] = _val_until
        else:
            _args['until'] = None
        return cls(**_args)


class EmojiStatusCollectible(TLObject):
    """TL type: emojiStatusCollectible"""
    CONSTRUCTOR_ID = 0x7184603b
    SUBCLASS_OF_ID = 0xf930b138

    def __init__(self, collectible_id: int, document_id: int, title: str, slug: str, pattern_document_id: int, center_color: int, edge_color: int, pattern_color: int, text_color: int, until: Optional[datetime] = None):
        self.collectible_id = collectible_id
        self.document_id = document_id
        self.title = title
        self.slug = slug
        self.pattern_document_id = pattern_document_id
        self.center_color = center_color
        self.edge_color = edge_color
        self.pattern_color = pattern_color
        self.text_color = text_color
        self.until = until

    def to_dict(self):
        return {
            '_': 'EmojiStatusCollectible',
            'collectible_id': self.collectible_id,
            'document_id': self.document_id,
            'title': self.title,
            'slug': self.slug,
            'pattern_document_id': self.pattern_document_id,
            'center_color': self.center_color,
            'edge_color': self.edge_color,
            'pattern_color': self.pattern_color,
            'text_color': self.text_color,
            'until': self.until,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.until is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.collectible_id))
        buf.write(struct.pack('<q', self.document_id))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.slug))
        buf.write(struct.pack('<q', self.pattern_document_id))
        buf.write(struct.pack('<i', self.center_color))
        buf.write(struct.pack('<i', self.edge_color))
        buf.write(struct.pack('<i', self.pattern_color))
        buf.write(struct.pack('<i', self.text_color))
        if self.until is not None:
            buf.write(struct.pack('<i', self.until))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_collectible_id = reader.read_long()
        _args['collectible_id'] = _val_collectible_id
        _val_document_id = reader.read_long()
        _args['document_id'] = _val_document_id
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        _val_pattern_document_id = reader.read_long()
        _args['pattern_document_id'] = _val_pattern_document_id
        _val_center_color = reader.read_int()
        _args['center_color'] = _val_center_color
        _val_edge_color = reader.read_int()
        _args['edge_color'] = _val_edge_color
        _val_pattern_color = reader.read_int()
        _args['pattern_color'] = _val_pattern_color
        _val_text_color = reader.read_int()
        _args['text_color'] = _val_text_color
        if flags & (1 << 0):
            _val_until = reader.read_int()
            _args['until'] = _val_until
        else:
            _args['until'] = None
        return cls(**_args)


class EmojiStatusEmpty(TLObject):
    """TL type: emojiStatusEmpty"""
    CONSTRUCTOR_ID = 0x2de11aae
    SUBCLASS_OF_ID = 0xf930b138

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'EmojiStatusEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class EmojiUrl(TLObject):
    """TL type: emojiURL"""
    CONSTRUCTOR_ID = 0xa575739d
    SUBCLASS_OF_ID = 0x1fa08a19

    def __init__(self, url: str):
        self.url = url

    def to_dict(self):
        return {
            '_': 'EmojiUrl',
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class EncryptedChat(TLObject):
    """TL type: encryptedChat"""
    CONSTRUCTOR_ID = 0x61f0d4c7
    SUBCLASS_OF_ID = 0x6d28a37a

    def __init__(self, id: int, access_hash: int, date: Optional[datetime], admin_id: int, participant_id: int, g_a_or_b: bytes, key_fingerprint: int):
        self.id = id
        self.access_hash = access_hash
        self.date = date
        self.admin_id = admin_id
        self.participant_id = participant_id
        self.g_a_or_b = g_a_or_b
        self.key_fingerprint = key_fingerprint

    def to_dict(self):
        return {
            '_': 'EncryptedChat',
            'id': self.id,
            'access_hash': self.access_hash,
            'date': self.date,
            'admin_id': self.admin_id,
            'participant_id': self.participant_id,
            'g_a_or_b': self.g_a_or_b,
            'key_fingerprint': self.key_fingerprint,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.admin_id))
        buf.write(struct.pack('<q', self.participant_id))
        buf.write(TLObject.serialize_bytes(self.g_a_or_b))
        buf.write(struct.pack('<q', self.key_fingerprint))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_admin_id = reader.read_long()
        _args['admin_id'] = _val_admin_id
        _val_participant_id = reader.read_long()
        _args['participant_id'] = _val_participant_id
        _val_g_a_or_b = reader.tgread_bytes()
        _args['g_a_or_b'] = _val_g_a_or_b
        _val_key_fingerprint = reader.read_long()
        _args['key_fingerprint'] = _val_key_fingerprint
        return cls(**_args)


class EncryptedChatDiscarded(TLObject):
    """TL type: encryptedChatDiscarded"""
    CONSTRUCTOR_ID = 0x1e1c7c45
    SUBCLASS_OF_ID = 0x6d28a37a

    def __init__(self, id: int, history_deleted: Optional[bool] = None):
        self.id = id
        self.history_deleted = history_deleted

    def to_dict(self):
        return {
            '_': 'EncryptedChatDiscarded',
            'id': self.id,
            'history_deleted': self.history_deleted,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.history_deleted:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['history_deleted'] = bool(flags & (1 << 0))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        return cls(**_args)


class EncryptedChatEmpty(TLObject):
    """TL type: encryptedChatEmpty"""
    CONSTRUCTOR_ID = 0xab7ec0a0
    SUBCLASS_OF_ID = 0x6d28a37a

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'EncryptedChatEmpty',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        return cls(**_args)


class EncryptedChatRequested(TLObject):
    """TL type: encryptedChatRequested"""
    CONSTRUCTOR_ID = 0x48f1d94c
    SUBCLASS_OF_ID = 0x6d28a37a

    def __init__(self, id: int, access_hash: int, date: Optional[datetime], admin_id: int, participant_id: int, g_a: bytes, folder_id: Optional[int] = None):
        self.id = id
        self.access_hash = access_hash
        self.date = date
        self.admin_id = admin_id
        self.participant_id = participant_id
        self.g_a = g_a
        self.folder_id = folder_id

    def to_dict(self):
        return {
            '_': 'EncryptedChatRequested',
            'id': self.id,
            'access_hash': self.access_hash,
            'date': self.date,
            'admin_id': self.admin_id,
            'participant_id': self.participant_id,
            'g_a': self.g_a,
            'folder_id': self.folder_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.folder_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.admin_id))
        buf.write(struct.pack('<q', self.participant_id))
        buf.write(TLObject.serialize_bytes(self.g_a))
        if self.folder_id is not None:
            buf.write(struct.pack('<i', self.folder_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_folder_id = reader.read_int()
            _args['folder_id'] = _val_folder_id
        else:
            _args['folder_id'] = None
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_admin_id = reader.read_long()
        _args['admin_id'] = _val_admin_id
        _val_participant_id = reader.read_long()
        _args['participant_id'] = _val_participant_id
        _val_g_a = reader.tgread_bytes()
        _args['g_a'] = _val_g_a
        return cls(**_args)


class EncryptedChatWaiting(TLObject):
    """TL type: encryptedChatWaiting"""
    CONSTRUCTOR_ID = 0x66b25953
    SUBCLASS_OF_ID = 0x6d28a37a

    def __init__(self, id: int, access_hash: int, date: Optional[datetime], admin_id: int, participant_id: int):
        self.id = id
        self.access_hash = access_hash
        self.date = date
        self.admin_id = admin_id
        self.participant_id = participant_id

    def to_dict(self):
        return {
            '_': 'EncryptedChatWaiting',
            'id': self.id,
            'access_hash': self.access_hash,
            'date': self.date,
            'admin_id': self.admin_id,
            'participant_id': self.participant_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.admin_id))
        buf.write(struct.pack('<q', self.participant_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_admin_id = reader.read_long()
        _args['admin_id'] = _val_admin_id
        _val_participant_id = reader.read_long()
        _args['participant_id'] = _val_participant_id
        return cls(**_args)


class EncryptedFile(TLObject):
    """TL type: encryptedFile"""
    CONSTRUCTOR_ID = 0xa8008cd8
    SUBCLASS_OF_ID = 0x842a67c0

    def __init__(self, id: int, access_hash: int, size: int, dc_id: int, key_fingerprint: int):
        self.id = id
        self.access_hash = access_hash
        self.size = size
        self.dc_id = dc_id
        self.key_fingerprint = key_fingerprint

    def to_dict(self):
        return {
            '_': 'EncryptedFile',
            'id': self.id,
            'access_hash': self.access_hash,
            'size': self.size,
            'dc_id': self.dc_id,
            'key_fingerprint': self.key_fingerprint,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<q', self.size))
        buf.write(struct.pack('<i', self.dc_id))
        buf.write(struct.pack('<i', self.key_fingerprint))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_size = reader.read_long()
        _args['size'] = _val_size
        _val_dc_id = reader.read_int()
        _args['dc_id'] = _val_dc_id
        _val_key_fingerprint = reader.read_int()
        _args['key_fingerprint'] = _val_key_fingerprint
        return cls(**_args)


class EncryptedFileEmpty(TLObject):
    """TL type: encryptedFileEmpty"""
    CONSTRUCTOR_ID = 0xc21f497e
    SUBCLASS_OF_ID = 0x842a67c0

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'EncryptedFileEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class EncryptedMessage(TLObject):
    """TL type: encryptedMessage"""
    CONSTRUCTOR_ID = 0xed18c118
    SUBCLASS_OF_ID = 0x239f2e51

    def __init__(self, chat_id: int, date: Optional[datetime], bytes: bytes, file: 'TypeEncryptedFile', random_id: int = None):
        self.chat_id = chat_id
        self.date = date
        self.bytes = bytes
        self.file = file
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'EncryptedMessage',
            'chat_id': self.chat_id,
            'date': self.date,
            'bytes': self.bytes,
            'file': self.file,
            'random_id': self.random_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.chat_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(TLObject.serialize_bytes(self.bytes))
        buf.write(bytes(self.file))
        buf.write(struct.pack('<q', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_chat_id = reader.read_int()
        _args['chat_id'] = _val_chat_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_bytes = reader.tgread_bytes()
        _args['bytes'] = _val_bytes
        _val_file = reader.tgread_object()
        _args['file'] = _val_file
        return cls(**_args)


class EncryptedMessageService(TLObject):
    """TL type: encryptedMessageService"""
    CONSTRUCTOR_ID = 0x23734b06
    SUBCLASS_OF_ID = 0x239f2e51

    def __init__(self, chat_id: int, date: Optional[datetime], bytes: bytes, random_id: int = None):
        self.chat_id = chat_id
        self.date = date
        self.bytes = bytes
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'EncryptedMessageService',
            'chat_id': self.chat_id,
            'date': self.date,
            'bytes': self.bytes,
            'random_id': self.random_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.chat_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(TLObject.serialize_bytes(self.bytes))
        buf.write(struct.pack('<q', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_chat_id = reader.read_int()
        _args['chat_id'] = _val_chat_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_bytes = reader.tgread_bytes()
        _args['bytes'] = _val_bytes
        return cls(**_args)


class ExportedChatlistInvite(TLObject):
    """TL type: exportedChatlistInvite"""
    CONSTRUCTOR_ID = 0x0c5181ac
    SUBCLASS_OF_ID = 0x7711f8ff

    def __init__(self, title: str, url: str, peers: List['TypePeer']):
        self.title = title
        self.url = url
        self.peers = peers

    def to_dict(self):
        return {
            '_': 'ExportedChatlistInvite',
            'title': self.title,
            'url': self.url,
            'peers': self.peers,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.peers)))
        for item in self.peers:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        reader.read_int(signed=False)  # skip vector id
        _count_peers = reader.read_int()
        _list_peers = []
        for _ in range(_count_peers):
            _item_peers = reader.tgread_object()
            _list_peers.append(_item_peers)
        _args['peers'] = _list_peers
        return cls(**_args)


class ExportedContactToken(TLObject):
    """TL type: exportedContactToken"""
    CONSTRUCTOR_ID = 0x41bf109b
    SUBCLASS_OF_ID = 0x86ddbed1

    def __init__(self, url: str, expires: Optional[datetime]):
        self.url = url
        self.expires = expires

    def to_dict(self):
        return {
            '_': 'ExportedContactToken',
            'url': self.url,
            'expires': self.expires,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<i', self.expires))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_expires = reader.read_int()
        _args['expires'] = _val_expires
        return cls(**_args)


class ExportedMessageLink(TLObject):
    """TL type: exportedMessageLink"""
    CONSTRUCTOR_ID = 0x5dab1af4
    SUBCLASS_OF_ID = 0xdee644cc

    def __init__(self, link: str, html: str):
        self.link = link
        self.html = html

    def to_dict(self):
        return {
            '_': 'ExportedMessageLink',
            'link': self.link,
            'html': self.html,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.link))
        buf.write(TLObject.serialize_bytes(self.html))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_link = reader.tgread_string()
        _args['link'] = _val_link
        _val_html = reader.tgread_string()
        _args['html'] = _val_html
        return cls(**_args)


class ExportedStoryLink(TLObject):
    """TL type: exportedStoryLink"""
    CONSTRUCTOR_ID = 0x3fc9053b
    SUBCLASS_OF_ID = 0x0fc541a6

    def __init__(self, link: str):
        self.link = link

    def to_dict(self):
        return {
            '_': 'ExportedStoryLink',
            'link': self.link,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.link))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_link = reader.tgread_string()
        _args['link'] = _val_link
        return cls(**_args)


class FactCheck(TLObject):
    """TL type: factCheck"""
    CONSTRUCTOR_ID = 0xb89bfccf
    SUBCLASS_OF_ID = 0x4640a3a3

    def __init__(self, hash: int, need_check: Optional[bool] = None, country: Optional[str] = None, text: Optional['TypeTextWithEntities'] = None):
        self.hash = hash
        self.need_check = need_check
        self.country = country
        self.text = text

    def to_dict(self):
        return {
            '_': 'FactCheck',
            'hash': self.hash,
            'need_check': self.need_check,
            'country': self.country,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.need_check:
            flags |= (1 << 0)
        if self.text is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.hash))
        if self.country is not None:
            buf.write(TLObject.serialize_bytes(self.country))
        if self.text is not None:
            buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['need_check'] = bool(flags & (1 << 0))
        if flags & (1 << 1):
            _val_country = reader.tgread_string()
            _args['country'] = _val_country
        else:
            _args['country'] = None
        if flags & (1 << 1):
            _val_text = reader.tgread_object()
            _args['text'] = _val_text
        else:
            _args['text'] = None
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class FileHash(TLObject):
    """TL type: fileHash"""
    CONSTRUCTOR_ID = 0xf39b035c
    SUBCLASS_OF_ID = 0xead438b3

    def __init__(self, offset: int, limit: int, hash: bytes):
        self.offset = offset
        self.limit = limit
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'FileHash',
            'offset': self.offset,
            'limit': self.limit,
            'hash': self.hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.offset))
        buf.write(struct.pack('<i', self.limit))
        buf.write(TLObject.serialize_bytes(self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_long()
        _args['offset'] = _val_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_hash = reader.tgread_bytes()
        _args['hash'] = _val_hash
        return cls(**_args)


class Folder(TLObject):
    """TL type: folder"""
    CONSTRUCTOR_ID = 0xff544e65
    SUBCLASS_OF_ID = 0xeb0e0cfb

    def __init__(self, id: int, title: str, autofill_new_broadcasts: Optional[bool] = None, autofill_public_groups: Optional[bool] = None, autofill_new_correspondents: Optional[bool] = None, photo: Optional['TypeChatPhoto'] = None):
        self.id = id
        self.title = title
        self.autofill_new_broadcasts = autofill_new_broadcasts
        self.autofill_public_groups = autofill_public_groups
        self.autofill_new_correspondents = autofill_new_correspondents
        self.photo = photo

    def to_dict(self):
        return {
            '_': 'Folder',
            'id': self.id,
            'title': self.title,
            'autofill_new_broadcasts': self.autofill_new_broadcasts,
            'autofill_public_groups': self.autofill_public_groups,
            'autofill_new_correspondents': self.autofill_new_correspondents,
            'photo': self.photo,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.autofill_new_broadcasts:
            flags |= (1 << 0)
        if self.autofill_public_groups:
            flags |= (1 << 1)
        if self.autofill_new_correspondents:
            flags |= (1 << 2)
        if self.photo is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(TLObject.serialize_bytes(self.title))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['autofill_new_broadcasts'] = bool(flags & (1 << 0))
        _args['autofill_public_groups'] = bool(flags & (1 << 1))
        _args['autofill_new_correspondents'] = bool(flags & (1 << 2))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        if flags & (1 << 3):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        return cls(**_args)


class FolderPeer(TLObject):
    """TL type: folderPeer"""
    CONSTRUCTOR_ID = 0xe9baa668
    SUBCLASS_OF_ID = 0xf3f2283b

    def __init__(self, peer: 'TypePeer', folder_id: int):
        self.peer = peer
        self.folder_id = folder_id

    def to_dict(self):
        return {
            '_': 'FolderPeer',
            'peer': self.peer,
            'folder_id': self.folder_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.folder_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_folder_id = reader.read_int()
        _args['folder_id'] = _val_folder_id
        return cls(**_args)


class ForumTopic(TLObject):
    """TL type: forumTopic"""
    CONSTRUCTOR_ID = 0xcdff0eca
    SUBCLASS_OF_ID = 0x8d182203

    def __init__(self, id: int, date: Optional[datetime], peer: 'TypePeer', title: str, icon_color: int, top_message: int, read_inbox_max_id: int, read_outbox_max_id: int, unread_count: int, unread_mentions_count: int, unread_reactions_count: int, from_id: 'TypePeer', notify_settings: 'TypePeerNotifySettings', my: Optional[bool] = None, closed: Optional[bool] = None, pinned: Optional[bool] = None, short: Optional[bool] = None, hidden: Optional[bool] = None, title_missing: Optional[bool] = None, icon_emoji_id: Optional[int] = None, draft: Optional['TypeDraftMessage'] = None):
        self.id = id
        self.date = date
        self.peer = peer
        self.title = title
        self.icon_color = icon_color
        self.top_message = top_message
        self.read_inbox_max_id = read_inbox_max_id
        self.read_outbox_max_id = read_outbox_max_id
        self.unread_count = unread_count
        self.unread_mentions_count = unread_mentions_count
        self.unread_reactions_count = unread_reactions_count
        self.from_id = from_id
        self.notify_settings = notify_settings
        self.my = my
        self.closed = closed
        self.pinned = pinned
        self.short = short
        self.hidden = hidden
        self.title_missing = title_missing
        self.icon_emoji_id = icon_emoji_id
        self.draft = draft

    def to_dict(self):
        return {
            '_': 'ForumTopic',
            'id': self.id,
            'date': self.date,
            'peer': self.peer,
            'title': self.title,
            'icon_color': self.icon_color,
            'top_message': self.top_message,
            'read_inbox_max_id': self.read_inbox_max_id,
            'read_outbox_max_id': self.read_outbox_max_id,
            'unread_count': self.unread_count,
            'unread_mentions_count': self.unread_mentions_count,
            'unread_reactions_count': self.unread_reactions_count,
            'from_id': self.from_id,
            'notify_settings': self.notify_settings,
            'my': self.my,
            'closed': self.closed,
            'pinned': self.pinned,
            'short': self.short,
            'hidden': self.hidden,
            'title_missing': self.title_missing,
            'icon_emoji_id': self.icon_emoji_id,
            'draft': self.draft,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.my:
            flags |= (1 << 1)
        if self.closed:
            flags |= (1 << 2)
        if self.pinned:
            flags |= (1 << 3)
        if self.short:
            flags |= (1 << 5)
        if self.hidden:
            flags |= (1 << 6)
        if self.title_missing:
            flags |= (1 << 7)
        if self.icon_emoji_id is not None:
            flags |= (1 << 0)
        if self.draft is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<i', self.date))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(struct.pack('<i', self.icon_color))
        buf.write(struct.pack('<i', self.top_message))
        buf.write(struct.pack('<i', self.read_inbox_max_id))
        buf.write(struct.pack('<i', self.read_outbox_max_id))
        buf.write(struct.pack('<i', self.unread_count))
        buf.write(struct.pack('<i', self.unread_mentions_count))
        buf.write(struct.pack('<i', self.unread_reactions_count))
        buf.write(bytes(self.from_id))
        buf.write(bytes(self.notify_settings))
        if self.icon_emoji_id is not None:
            buf.write(struct.pack('<q', self.icon_emoji_id))
        if self.draft is not None:
            buf.write(bytes(self.draft))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['my'] = bool(flags & (1 << 1))
        _args['closed'] = bool(flags & (1 << 2))
        _args['pinned'] = bool(flags & (1 << 3))
        _args['short'] = bool(flags & (1 << 5))
        _args['hidden'] = bool(flags & (1 << 6))
        _args['title_missing'] = bool(flags & (1 << 7))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_icon_color = reader.read_int()
        _args['icon_color'] = _val_icon_color
        if flags & (1 << 0):
            _val_icon_emoji_id = reader.read_long()
            _args['icon_emoji_id'] = _val_icon_emoji_id
        else:
            _args['icon_emoji_id'] = None
        _val_top_message = reader.read_int()
        _args['top_message'] = _val_top_message
        _val_read_inbox_max_id = reader.read_int()
        _args['read_inbox_max_id'] = _val_read_inbox_max_id
        _val_read_outbox_max_id = reader.read_int()
        _args['read_outbox_max_id'] = _val_read_outbox_max_id
        _val_unread_count = reader.read_int()
        _args['unread_count'] = _val_unread_count
        _val_unread_mentions_count = reader.read_int()
        _args['unread_mentions_count'] = _val_unread_mentions_count
        _val_unread_reactions_count = reader.read_int()
        _args['unread_reactions_count'] = _val_unread_reactions_count
        _val_from_id = reader.tgread_object()
        _args['from_id'] = _val_from_id
        _val_notify_settings = reader.tgread_object()
        _args['notify_settings'] = _val_notify_settings
        if flags & (1 << 4):
            _val_draft = reader.tgread_object()
            _args['draft'] = _val_draft
        else:
            _args['draft'] = None
        return cls(**_args)


class ForumTopicDeleted(TLObject):
    """TL type: forumTopicDeleted"""
    CONSTRUCTOR_ID = 0x023f109b
    SUBCLASS_OF_ID = 0x8d182203

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'ForumTopicDeleted',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        return cls(**_args)


class FoundStory(TLObject):
    """TL type: foundStory"""
    CONSTRUCTOR_ID = 0xe87acbc0
    SUBCLASS_OF_ID = 0xb31d68c5

    def __init__(self, peer: 'TypePeer', story: 'TypeStoryItem'):
        self.peer = peer
        self.story = story

    def to_dict(self):
        return {
            '_': 'FoundStory',
            'peer': self.peer,
            'story': self.story,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.story))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_story = reader.tgread_object()
        _args['story'] = _val_story
        return cls(**_args)


class Game(TLObject):
    """TL type: game"""
    CONSTRUCTOR_ID = 0xbdf9653b
    SUBCLASS_OF_ID = 0x83199eb2

    def __init__(self, id: int, access_hash: int, short_name: str, title: str, description: str, photo: 'TypePhoto', document: Optional['TypeDocument'] = None):
        self.id = id
        self.access_hash = access_hash
        self.short_name = short_name
        self.title = title
        self.description = description
        self.photo = photo
        self.document = document

    def to_dict(self):
        return {
            '_': 'Game',
            'id': self.id,
            'access_hash': self.access_hash,
            'short_name': self.short_name,
            'title': self.title,
            'description': self.description,
            'photo': self.photo,
            'document': self.document,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.document is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.short_name))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.description))
        buf.write(bytes(self.photo))
        if self.document is not None:
            buf.write(bytes(self.document))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_short_name = reader.tgread_string()
        _args['short_name'] = _val_short_name
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_description = reader.tgread_string()
        _args['description'] = _val_description
        _val_photo = reader.tgread_object()
        _args['photo'] = _val_photo
        if flags & (1 << 0):
            _val_document = reader.tgread_object()
            _args['document'] = _val_document
        else:
            _args['document'] = None
        return cls(**_args)


class GeoPoint(TLObject):
    """TL type: geoPoint"""
    CONSTRUCTOR_ID = 0xb2a2f663
    SUBCLASS_OF_ID = 0xd610e16d

    def __init__(self, long: float, lat: float, access_hash: int, accuracy_radius: Optional[int] = None):
        self.long = long
        self.lat = lat
        self.access_hash = access_hash
        self.accuracy_radius = accuracy_radius

    def to_dict(self):
        return {
            '_': 'GeoPoint',
            'long': self.long,
            'lat': self.lat,
            'access_hash': self.access_hash,
            'accuracy_radius': self.accuracy_radius,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.accuracy_radius is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<d', self.long))
        buf.write(struct.pack('<d', self.lat))
        buf.write(struct.pack('<q', self.access_hash))
        if self.accuracy_radius is not None:
            buf.write(struct.pack('<i', self.accuracy_radius))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_long = reader.read_double()
        _args['long'] = _val_long
        _val_lat = reader.read_double()
        _args['lat'] = _val_lat
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        if flags & (1 << 0):
            _val_accuracy_radius = reader.read_int()
            _args['accuracy_radius'] = _val_accuracy_radius
        else:
            _args['accuracy_radius'] = None
        return cls(**_args)


class GeoPointAddress(TLObject):
    """TL type: geoPointAddress"""
    CONSTRUCTOR_ID = 0xde4c5d93
    SUBCLASS_OF_ID = 0x9655c2d8

    def __init__(self, country_iso2: str, state: Optional[str] = None, city: Optional[str] = None, street: Optional[str] = None):
        self.country_iso2 = country_iso2
        self.state = state
        self.city = city
        self.street = street

    def to_dict(self):
        return {
            '_': 'GeoPointAddress',
            'country_iso2': self.country_iso2,
            'state': self.state,
            'city': self.city,
            'street': self.street,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.state is not None:
            flags |= (1 << 0)
        if self.city is not None:
            flags |= (1 << 1)
        if self.street is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.country_iso2))
        if self.state is not None:
            buf.write(TLObject.serialize_bytes(self.state))
        if self.city is not None:
            buf.write(TLObject.serialize_bytes(self.city))
        if self.street is not None:
            buf.write(TLObject.serialize_bytes(self.street))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_country_iso2 = reader.tgread_string()
        _args['country_iso2'] = _val_country_iso2
        if flags & (1 << 0):
            _val_state = reader.tgread_string()
            _args['state'] = _val_state
        else:
            _args['state'] = None
        if flags & (1 << 1):
            _val_city = reader.tgread_string()
            _args['city'] = _val_city
        else:
            _args['city'] = None
        if flags & (1 << 2):
            _val_street = reader.tgread_string()
            _args['street'] = _val_street
        else:
            _args['street'] = None
        return cls(**_args)


class GeoPointEmpty(TLObject):
    """TL type: geoPointEmpty"""
    CONSTRUCTOR_ID = 0x1117dd5f
    SUBCLASS_OF_ID = 0xd610e16d

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'GeoPointEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class GlobalPrivacySettings(TLObject):
    """TL type: globalPrivacySettings"""
    CONSTRUCTOR_ID = 0xfe41b34f
    SUBCLASS_OF_ID = 0xc90e5770

    def __init__(self, archive_and_mute_new_noncontact_peers: Optional[bool] = None, keep_archived_unmuted: Optional[bool] = None, keep_archived_folders: Optional[bool] = None, hide_read_marks: Optional[bool] = None, new_noncontact_peers_require_premium: Optional[bool] = None, display_gifts_button: Optional[bool] = None, noncontact_peers_paid_stars: Optional[int] = None, disallowed_gifts: Optional['TypeDisallowedGiftsSettings'] = None):
        self.archive_and_mute_new_noncontact_peers = archive_and_mute_new_noncontact_peers
        self.keep_archived_unmuted = keep_archived_unmuted
        self.keep_archived_folders = keep_archived_folders
        self.hide_read_marks = hide_read_marks
        self.new_noncontact_peers_require_premium = new_noncontact_peers_require_premium
        self.display_gifts_button = display_gifts_button
        self.noncontact_peers_paid_stars = noncontact_peers_paid_stars
        self.disallowed_gifts = disallowed_gifts

    def to_dict(self):
        return {
            '_': 'GlobalPrivacySettings',
            'archive_and_mute_new_noncontact_peers': self.archive_and_mute_new_noncontact_peers,
            'keep_archived_unmuted': self.keep_archived_unmuted,
            'keep_archived_folders': self.keep_archived_folders,
            'hide_read_marks': self.hide_read_marks,
            'new_noncontact_peers_require_premium': self.new_noncontact_peers_require_premium,
            'display_gifts_button': self.display_gifts_button,
            'noncontact_peers_paid_stars': self.noncontact_peers_paid_stars,
            'disallowed_gifts': self.disallowed_gifts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.archive_and_mute_new_noncontact_peers:
            flags |= (1 << 0)
        if self.keep_archived_unmuted:
            flags |= (1 << 1)
        if self.keep_archived_folders:
            flags |= (1 << 2)
        if self.hide_read_marks:
            flags |= (1 << 3)
        if self.new_noncontact_peers_require_premium:
            flags |= (1 << 4)
        if self.display_gifts_button:
            flags |= (1 << 7)
        if self.noncontact_peers_paid_stars is not None:
            flags |= (1 << 5)
        if self.disallowed_gifts is not None:
            flags |= (1 << 6)
        buf.write(struct.pack('<I', flags))
        if self.noncontact_peers_paid_stars is not None:
            buf.write(struct.pack('<q', self.noncontact_peers_paid_stars))
        if self.disallowed_gifts is not None:
            buf.write(bytes(self.disallowed_gifts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['archive_and_mute_new_noncontact_peers'] = bool(flags & (1 << 0))
        _args['keep_archived_unmuted'] = bool(flags & (1 << 1))
        _args['keep_archived_folders'] = bool(flags & (1 << 2))
        _args['hide_read_marks'] = bool(flags & (1 << 3))
        _args['new_noncontact_peers_require_premium'] = bool(flags & (1 << 4))
        _args['display_gifts_button'] = bool(flags & (1 << 7))
        if flags & (1 << 5):
            _val_noncontact_peers_paid_stars = reader.read_long()
            _args['noncontact_peers_paid_stars'] = _val_noncontact_peers_paid_stars
        else:
            _args['noncontact_peers_paid_stars'] = None
        if flags & (1 << 6):
            _val_disallowed_gifts = reader.tgread_object()
            _args['disallowed_gifts'] = _val_disallowed_gifts
        else:
            _args['disallowed_gifts'] = None
        return cls(**_args)


class GroupCall(TLObject):
    """TL type: groupCall"""
    CONSTRUCTOR_ID = 0xefb2b617
    SUBCLASS_OF_ID = 0x20b4f320

    def __init__(self, id: int, access_hash: int, participants_count: int, unmuted_video_limit: int, version: int, join_muted: Optional[bool] = None, can_change_join_muted: Optional[bool] = None, join_date_asc: Optional[bool] = None, schedule_start_subscribed: Optional[bool] = None, can_start_video: Optional[bool] = None, record_video_active: Optional[bool] = None, rtmp_stream: Optional[bool] = None, listeners_hidden: Optional[bool] = None, conference: Optional[bool] = None, creator: Optional[bool] = None, messages_enabled: Optional[bool] = None, can_change_messages_enabled: Optional[bool] = None, min: Optional[bool] = None, title: Optional[str] = None, stream_dc_id: Optional[int] = None, record_start_date: Optional[datetime] = None, schedule_date: Optional[datetime] = None, unmuted_video_count: Optional[int] = None, invite_link: Optional[str] = None, send_paid_messages_stars: Optional[int] = None, default_send_as: Optional['TypePeer'] = None):
        self.id = id
        self.access_hash = access_hash
        self.participants_count = participants_count
        self.unmuted_video_limit = unmuted_video_limit
        self.version = version
        self.join_muted = join_muted
        self.can_change_join_muted = can_change_join_muted
        self.join_date_asc = join_date_asc
        self.schedule_start_subscribed = schedule_start_subscribed
        self.can_start_video = can_start_video
        self.record_video_active = record_video_active
        self.rtmp_stream = rtmp_stream
        self.listeners_hidden = listeners_hidden
        self.conference = conference
        self.creator = creator
        self.messages_enabled = messages_enabled
        self.can_change_messages_enabled = can_change_messages_enabled
        self.min = min
        self.title = title
        self.stream_dc_id = stream_dc_id
        self.record_start_date = record_start_date
        self.schedule_date = schedule_date
        self.unmuted_video_count = unmuted_video_count
        self.invite_link = invite_link
        self.send_paid_messages_stars = send_paid_messages_stars
        self.default_send_as = default_send_as

    def to_dict(self):
        return {
            '_': 'GroupCall',
            'id': self.id,
            'access_hash': self.access_hash,
            'participants_count': self.participants_count,
            'unmuted_video_limit': self.unmuted_video_limit,
            'version': self.version,
            'join_muted': self.join_muted,
            'can_change_join_muted': self.can_change_join_muted,
            'join_date_asc': self.join_date_asc,
            'schedule_start_subscribed': self.schedule_start_subscribed,
            'can_start_video': self.can_start_video,
            'record_video_active': self.record_video_active,
            'rtmp_stream': self.rtmp_stream,
            'listeners_hidden': self.listeners_hidden,
            'conference': self.conference,
            'creator': self.creator,
            'messages_enabled': self.messages_enabled,
            'can_change_messages_enabled': self.can_change_messages_enabled,
            'min': self.min,
            'title': self.title,
            'stream_dc_id': self.stream_dc_id,
            'record_start_date': self.record_start_date,
            'schedule_date': self.schedule_date,
            'unmuted_video_count': self.unmuted_video_count,
            'invite_link': self.invite_link,
            'send_paid_messages_stars': self.send_paid_messages_stars,
            'default_send_as': self.default_send_as,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.join_muted:
            flags |= (1 << 1)
        if self.can_change_join_muted:
            flags |= (1 << 2)
        if self.join_date_asc:
            flags |= (1 << 6)
        if self.schedule_start_subscribed:
            flags |= (1 << 8)
        if self.can_start_video:
            flags |= (1 << 9)
        if self.record_video_active:
            flags |= (1 << 11)
        if self.rtmp_stream:
            flags |= (1 << 12)
        if self.listeners_hidden:
            flags |= (1 << 13)
        if self.conference:
            flags |= (1 << 14)
        if self.creator:
            flags |= (1 << 15)
        if self.messages_enabled:
            flags |= (1 << 17)
        if self.can_change_messages_enabled:
            flags |= (1 << 18)
        if self.min:
            flags |= (1 << 19)
        if self.title is not None:
            flags |= (1 << 3)
        if self.stream_dc_id is not None:
            flags |= (1 << 4)
        if self.record_start_date is not None:
            flags |= (1 << 5)
        if self.schedule_date is not None:
            flags |= (1 << 7)
        if self.unmuted_video_count is not None:
            flags |= (1 << 10)
        if self.invite_link is not None:
            flags |= (1 << 16)
        if self.send_paid_messages_stars is not None:
            flags |= (1 << 20)
        if self.default_send_as is not None:
            flags |= (1 << 21)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<i', self.participants_count))
        buf.write(struct.pack('<i', self.unmuted_video_limit))
        buf.write(struct.pack('<i', self.version))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.stream_dc_id is not None:
            buf.write(struct.pack('<i', self.stream_dc_id))
        if self.record_start_date is not None:
            buf.write(struct.pack('<i', self.record_start_date))
        if self.schedule_date is not None:
            buf.write(struct.pack('<i', self.schedule_date))
        if self.unmuted_video_count is not None:
            buf.write(struct.pack('<i', self.unmuted_video_count))
        if self.invite_link is not None:
            buf.write(TLObject.serialize_bytes(self.invite_link))
        if self.send_paid_messages_stars is not None:
            buf.write(struct.pack('<q', self.send_paid_messages_stars))
        if self.default_send_as is not None:
            buf.write(bytes(self.default_send_as))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['join_muted'] = bool(flags & (1 << 1))
        _args['can_change_join_muted'] = bool(flags & (1 << 2))
        _args['join_date_asc'] = bool(flags & (1 << 6))
        _args['schedule_start_subscribed'] = bool(flags & (1 << 8))
        _args['can_start_video'] = bool(flags & (1 << 9))
        _args['record_video_active'] = bool(flags & (1 << 11))
        _args['rtmp_stream'] = bool(flags & (1 << 12))
        _args['listeners_hidden'] = bool(flags & (1 << 13))
        _args['conference'] = bool(flags & (1 << 14))
        _args['creator'] = bool(flags & (1 << 15))
        _args['messages_enabled'] = bool(flags & (1 << 17))
        _args['can_change_messages_enabled'] = bool(flags & (1 << 18))
        _args['min'] = bool(flags & (1 << 19))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_participants_count = reader.read_int()
        _args['participants_count'] = _val_participants_count
        if flags & (1 << 3):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 4):
            _val_stream_dc_id = reader.read_int()
            _args['stream_dc_id'] = _val_stream_dc_id
        else:
            _args['stream_dc_id'] = None
        if flags & (1 << 5):
            _val_record_start_date = reader.read_int()
            _args['record_start_date'] = _val_record_start_date
        else:
            _args['record_start_date'] = None
        if flags & (1 << 7):
            _val_schedule_date = reader.read_int()
            _args['schedule_date'] = _val_schedule_date
        else:
            _args['schedule_date'] = None
        if flags & (1 << 10):
            _val_unmuted_video_count = reader.read_int()
            _args['unmuted_video_count'] = _val_unmuted_video_count
        else:
            _args['unmuted_video_count'] = None
        _val_unmuted_video_limit = reader.read_int()
        _args['unmuted_video_limit'] = _val_unmuted_video_limit
        _val_version = reader.read_int()
        _args['version'] = _val_version
        if flags & (1 << 16):
            _val_invite_link = reader.tgread_string()
            _args['invite_link'] = _val_invite_link
        else:
            _args['invite_link'] = None
        if flags & (1 << 20):
            _val_send_paid_messages_stars = reader.read_long()
            _args['send_paid_messages_stars'] = _val_send_paid_messages_stars
        else:
            _args['send_paid_messages_stars'] = None
        if flags & (1 << 21):
            _val_default_send_as = reader.tgread_object()
            _args['default_send_as'] = _val_default_send_as
        else:
            _args['default_send_as'] = None
        return cls(**_args)


class GroupCallDiscarded(TLObject):
    """TL type: groupCallDiscarded"""
    CONSTRUCTOR_ID = 0x7780bcb4
    SUBCLASS_OF_ID = 0x20b4f320

    def __init__(self, id: int, access_hash: int, duration: int):
        self.id = id
        self.access_hash = access_hash
        self.duration = duration

    def to_dict(self):
        return {
            '_': 'GroupCallDiscarded',
            'id': self.id,
            'access_hash': self.access_hash,
            'duration': self.duration,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<i', self.duration))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_duration = reader.read_int()
        _args['duration'] = _val_duration
        return cls(**_args)


class GroupCallDonor(TLObject):
    """TL type: groupCallDonor"""
    CONSTRUCTOR_ID = 0xee430c85
    SUBCLASS_OF_ID = 0x14f28bb0

    def __init__(self, stars: int, top: Optional[bool] = None, my: Optional[bool] = None, peer_id: Optional['TypePeer'] = None):
        self.stars = stars
        self.top = top
        self.my = my
        self.peer_id = peer_id

    def to_dict(self):
        return {
            '_': 'GroupCallDonor',
            'stars': self.stars,
            'top': self.top,
            'my': self.my,
            'peer_id': self.peer_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.top:
            flags |= (1 << 0)
        if self.my:
            flags |= (1 << 1)
        if self.peer_id is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.stars))
        if self.peer_id is not None:
            buf.write(bytes(self.peer_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['top'] = bool(flags & (1 << 0))
        _args['my'] = bool(flags & (1 << 1))
        if flags & (1 << 3):
            _val_peer_id = reader.tgread_object()
            _args['peer_id'] = _val_peer_id
        else:
            _args['peer_id'] = None
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        return cls(**_args)


class GroupCallMessage(TLObject):
    """TL type: groupCallMessage"""
    CONSTRUCTOR_ID = 0x1a8afc7e
    SUBCLASS_OF_ID = 0x60ce5a22

    def __init__(self, id: int, from_id: 'TypePeer', date: Optional[datetime], message: 'TypeTextWithEntities', from_admin: Optional[bool] = None, paid_message_stars: Optional[int] = None):
        self.id = id
        self.from_id = from_id
        self.date = date
        self.message = message
        self.from_admin = from_admin
        self.paid_message_stars = paid_message_stars

    def to_dict(self):
        return {
            '_': 'GroupCallMessage',
            'id': self.id,
            'from_id': self.from_id,
            'date': self.date,
            'message': self.message,
            'from_admin': self.from_admin,
            'paid_message_stars': self.paid_message_stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.from_admin:
            flags |= (1 << 1)
        if self.paid_message_stars is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(bytes(self.from_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(bytes(self.message))
        if self.paid_message_stars is not None:
            buf.write(struct.pack('<q', self.paid_message_stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['from_admin'] = bool(flags & (1 << 1))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_from_id = reader.tgread_object()
        _args['from_id'] = _val_from_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        if flags & (1 << 0):
            _val_paid_message_stars = reader.read_long()
            _args['paid_message_stars'] = _val_paid_message_stars
        else:
            _args['paid_message_stars'] = None
        return cls(**_args)


class GroupCallParticipant(TLObject):
    """TL type: groupCallParticipant"""
    CONSTRUCTOR_ID = 0x2a3dc7ac
    SUBCLASS_OF_ID = 0xc01aaf4c

    def __init__(self, peer: 'TypePeer', date: Optional[datetime], source: int, muted: Optional[bool] = None, left: Optional[bool] = None, can_self_unmute: Optional[bool] = None, just_joined: Optional[bool] = None, versioned: Optional[bool] = None, min: Optional[bool] = None, muted_by_you: Optional[bool] = None, volume_by_admin: Optional[bool] = None, is_self: Optional[bool] = None, video_joined: Optional[bool] = None, active_date: Optional[datetime] = None, volume: Optional[int] = None, about: Optional[str] = None, raise_hand_rating: Optional[int] = None, video: Optional['TypeGroupCallParticipantVideo'] = None, presentation: Optional['TypeGroupCallParticipantVideo'] = None, paid_stars_total: Optional[int] = None):
        self.peer = peer
        self.date = date
        self.source = source
        self.muted = muted
        self.left = left
        self.can_self_unmute = can_self_unmute
        self.just_joined = just_joined
        self.versioned = versioned
        self.min = min
        self.muted_by_you = muted_by_you
        self.volume_by_admin = volume_by_admin
        self.is_self = is_self
        self.video_joined = video_joined
        self.active_date = active_date
        self.volume = volume
        self.about = about
        self.raise_hand_rating = raise_hand_rating
        self.video = video
        self.presentation = presentation
        self.paid_stars_total = paid_stars_total

    def to_dict(self):
        return {
            '_': 'GroupCallParticipant',
            'peer': self.peer,
            'date': self.date,
            'source': self.source,
            'muted': self.muted,
            'left': self.left,
            'can_self_unmute': self.can_self_unmute,
            'just_joined': self.just_joined,
            'versioned': self.versioned,
            'min': self.min,
            'muted_by_you': self.muted_by_you,
            'volume_by_admin': self.volume_by_admin,
            'is_self': self.is_self,
            'video_joined': self.video_joined,
            'active_date': self.active_date,
            'volume': self.volume,
            'about': self.about,
            'raise_hand_rating': self.raise_hand_rating,
            'video': self.video,
            'presentation': self.presentation,
            'paid_stars_total': self.paid_stars_total,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.muted:
            flags |= (1 << 0)
        if self.left:
            flags |= (1 << 1)
        if self.can_self_unmute:
            flags |= (1 << 2)
        if self.just_joined:
            flags |= (1 << 4)
        if self.versioned:
            flags |= (1 << 5)
        if self.min:
            flags |= (1 << 8)
        if self.muted_by_you:
            flags |= (1 << 9)
        if self.volume_by_admin:
            flags |= (1 << 10)
        if self.is_self:
            flags |= (1 << 12)
        if self.video_joined:
            flags |= (1 << 15)
        if self.active_date is not None:
            flags |= (1 << 3)
        if self.volume is not None:
            flags |= (1 << 7)
        if self.about is not None:
            flags |= (1 << 11)
        if self.raise_hand_rating is not None:
            flags |= (1 << 13)
        if self.video is not None:
            flags |= (1 << 6)
        if self.presentation is not None:
            flags |= (1 << 14)
        if self.paid_stars_total is not None:
            flags |= (1 << 16)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.source))
        if self.active_date is not None:
            buf.write(struct.pack('<i', self.active_date))
        if self.volume is not None:
            buf.write(struct.pack('<i', self.volume))
        if self.about is not None:
            buf.write(TLObject.serialize_bytes(self.about))
        if self.raise_hand_rating is not None:
            buf.write(struct.pack('<q', self.raise_hand_rating))
        if self.video is not None:
            buf.write(bytes(self.video))
        if self.presentation is not None:
            buf.write(bytes(self.presentation))
        if self.paid_stars_total is not None:
            buf.write(struct.pack('<q', self.paid_stars_total))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['muted'] = bool(flags & (1 << 0))
        _args['left'] = bool(flags & (1 << 1))
        _args['can_self_unmute'] = bool(flags & (1 << 2))
        _args['just_joined'] = bool(flags & (1 << 4))
        _args['versioned'] = bool(flags & (1 << 5))
        _args['min'] = bool(flags & (1 << 8))
        _args['muted_by_you'] = bool(flags & (1 << 9))
        _args['volume_by_admin'] = bool(flags & (1 << 10))
        _args['is_self'] = bool(flags & (1 << 12))
        _args['video_joined'] = bool(flags & (1 << 15))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 3):
            _val_active_date = reader.read_int()
            _args['active_date'] = _val_active_date
        else:
            _args['active_date'] = None
        _val_source = reader.read_int()
        _args['source'] = _val_source
        if flags & (1 << 7):
            _val_volume = reader.read_int()
            _args['volume'] = _val_volume
        else:
            _args['volume'] = None
        if flags & (1 << 11):
            _val_about = reader.tgread_string()
            _args['about'] = _val_about
        else:
            _args['about'] = None
        if flags & (1 << 13):
            _val_raise_hand_rating = reader.read_long()
            _args['raise_hand_rating'] = _val_raise_hand_rating
        else:
            _args['raise_hand_rating'] = None
        if flags & (1 << 6):
            _val_video = reader.tgread_object()
            _args['video'] = _val_video
        else:
            _args['video'] = None
        if flags & (1 << 14):
            _val_presentation = reader.tgread_object()
            _args['presentation'] = _val_presentation
        else:
            _args['presentation'] = None
        if flags & (1 << 16):
            _val_paid_stars_total = reader.read_long()
            _args['paid_stars_total'] = _val_paid_stars_total
        else:
            _args['paid_stars_total'] = None
        return cls(**_args)


class GroupCallParticipantVideo(TLObject):
    """TL type: groupCallParticipantVideo"""
    CONSTRUCTOR_ID = 0x67753ac8
    SUBCLASS_OF_ID = 0xef46b8db

    def __init__(self, endpoint: str, source_groups: List['TypeGroupCallParticipantVideoSourceGroup'], paused: Optional[bool] = None, audio_source: Optional[int] = None):
        self.endpoint = endpoint
        self.source_groups = source_groups
        self.paused = paused
        self.audio_source = audio_source

    def to_dict(self):
        return {
            '_': 'GroupCallParticipantVideo',
            'endpoint': self.endpoint,
            'source_groups': self.source_groups,
            'paused': self.paused,
            'audio_source': self.audio_source,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.paused:
            flags |= (1 << 0)
        if self.audio_source is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.endpoint))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.source_groups)))
        for item in self.source_groups:
            buf.write(bytes(self.item))
        if self.audio_source is not None:
            buf.write(struct.pack('<i', self.audio_source))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['paused'] = bool(flags & (1 << 0))
        _val_endpoint = reader.tgread_string()
        _args['endpoint'] = _val_endpoint
        reader.read_int(signed=False)  # skip vector id
        _count_source_groups = reader.read_int()
        _list_source_groups = []
        for _ in range(_count_source_groups):
            _item_source_groups = reader.tgread_object()
            _list_source_groups.append(_item_source_groups)
        _args['source_groups'] = _list_source_groups
        if flags & (1 << 1):
            _val_audio_source = reader.read_int()
            _args['audio_source'] = _val_audio_source
        else:
            _args['audio_source'] = None
        return cls(**_args)


class GroupCallParticipantVideoSourceGroup(TLObject):
    """TL type: groupCallParticipantVideoSourceGroup"""
    CONSTRUCTOR_ID = 0xdcb118b7
    SUBCLASS_OF_ID = 0x3015f87c

    def __init__(self, semantics: str, sources: List[int]):
        self.semantics = semantics
        self.sources = sources

    def to_dict(self):
        return {
            '_': 'GroupCallParticipantVideoSourceGroup',
            'semantics': self.semantics,
            'sources': self.sources,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.semantics))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.sources)))
        for item in self.sources:
            buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_semantics = reader.tgread_string()
        _args['semantics'] = _val_semantics
        reader.read_int(signed=False)  # skip vector id
        _count_sources = reader.read_int()
        _list_sources = []
        for _ in range(_count_sources):
            _item_sources = reader.read_int()
            _list_sources.append(_item_sources)
        _args['sources'] = _list_sources
        return cls(**_args)


class GroupCallStreamChannel(TLObject):
    """TL type: groupCallStreamChannel"""
    CONSTRUCTOR_ID = 0x80eb48af
    SUBCLASS_OF_ID = 0xdd44b258

    def __init__(self, channel: int, scale: int, last_timestamp_ms: int):
        self.channel = channel
        self.scale = scale
        self.last_timestamp_ms = last_timestamp_ms

    def to_dict(self):
        return {
            '_': 'GroupCallStreamChannel',
            'channel': self.channel,
            'scale': self.scale,
            'last_timestamp_ms': self.last_timestamp_ms,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.channel))
        buf.write(struct.pack('<i', self.scale))
        buf.write(struct.pack('<q', self.last_timestamp_ms))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel = reader.read_int()
        _args['channel'] = _val_channel
        _val_scale = reader.read_int()
        _args['scale'] = _val_scale
        _val_last_timestamp_ms = reader.read_long()
        _args['last_timestamp_ms'] = _val_last_timestamp_ms
        return cls(**_args)


class HighScore(TLObject):
    """TL type: highScore"""
    CONSTRUCTOR_ID = 0x73a379eb
    SUBCLASS_OF_ID = 0xd32b1e35

    def __init__(self, pos: int, user_id: int, score: int):
        self.pos = pos
        self.user_id = user_id
        self.score = score

    def to_dict(self):
        return {
            '_': 'HighScore',
            'pos': self.pos,
            'user_id': self.user_id,
            'score': self.score,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.pos))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.score))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_pos = reader.read_int()
        _args['pos'] = _val_pos
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_score = reader.read_int()
        _args['score'] = _val_score
        return cls(**_args)


class ImportedContact(TLObject):
    """TL type: importedContact"""
    CONSTRUCTOR_ID = 0xc13e3c50
    SUBCLASS_OF_ID = 0xb545bbda

    def __init__(self, user_id: int, client_id: int):
        self.user_id = user_id
        self.client_id = client_id

    def to_dict(self):
        return {
            '_': 'ImportedContact',
            'user_id': self.user_id,
            'client_id': self.client_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<q', self.client_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_client_id = reader.read_long()
        _args['client_id'] = _val_client_id
        return cls(**_args)


class InlineBotSwitchPm(TLObject):
    """TL type: inlineBotSwitchPM"""
    CONSTRUCTOR_ID = 0x3c20629f
    SUBCLASS_OF_ID = 0x82b1f73b

    def __init__(self, text: str, start_param: str):
        self.text = text
        self.start_param = start_param

    def to_dict(self):
        return {
            '_': 'InlineBotSwitchPm',
            'text': self.text,
            'start_param': self.start_param,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.start_param))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_start_param = reader.tgread_string()
        _args['start_param'] = _val_start_param
        return cls(**_args)


class InlineBotWebView(TLObject):
    """TL type: inlineBotWebView"""
    CONSTRUCTOR_ID = 0xb57295d5
    SUBCLASS_OF_ID = 0x6ce015ea

    def __init__(self, text: str, url: str):
        self.text = text
        self.url = url

    def to_dict(self):
        return {
            '_': 'InlineBotWebView',
            'text': self.text,
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class InlineQueryPeerTypeBotPm(TLObject):
    """TL type: inlineQueryPeerTypeBotPM"""
    CONSTRUCTOR_ID = 0x0e3b2d0c
    SUBCLASS_OF_ID = 0xafb0fa1f

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InlineQueryPeerTypeBotPm',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InlineQueryPeerTypeBroadcast(TLObject):
    """TL type: inlineQueryPeerTypeBroadcast"""
    CONSTRUCTOR_ID = 0x6334ee9a
    SUBCLASS_OF_ID = 0xafb0fa1f

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InlineQueryPeerTypeBroadcast',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InlineQueryPeerTypeChat(TLObject):
    """TL type: inlineQueryPeerTypeChat"""
    CONSTRUCTOR_ID = 0xd766c50a
    SUBCLASS_OF_ID = 0xafb0fa1f

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InlineQueryPeerTypeChat',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InlineQueryPeerTypeMegagroup(TLObject):
    """TL type: inlineQueryPeerTypeMegagroup"""
    CONSTRUCTOR_ID = 0x5ec4be43
    SUBCLASS_OF_ID = 0xafb0fa1f

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InlineQueryPeerTypeMegagroup',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InlineQueryPeerTypePm(TLObject):
    """TL type: inlineQueryPeerTypePM"""
    CONSTRUCTOR_ID = 0x833c0fac
    SUBCLASS_OF_ID = 0xafb0fa1f

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InlineQueryPeerTypePm',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InlineQueryPeerTypeSameBotPm(TLObject):
    """TL type: inlineQueryPeerTypeSameBotPM"""
    CONSTRUCTOR_ID = 0x3081ed9d
    SUBCLASS_OF_ID = 0xafb0fa1f

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InlineQueryPeerTypeSameBotPm',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputAppEvent(TLObject):
    """TL type: inputAppEvent"""
    CONSTRUCTOR_ID = 0x1d1b1245
    SUBCLASS_OF_ID = 0x89322106

    def __init__(self, time: float, type: str, peer: int, data: 'TypeJSONValue'):
        self.time = time
        self.type = type
        self.peer = peer
        self.data = data

    def to_dict(self):
        return {
            '_': 'InputAppEvent',
            'time': self.time,
            'type': self.type,
            'peer': self.peer,
            'data': self.data,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<d', self.time))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(struct.pack('<q', self.peer))
        buf.write(bytes(self.data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_time = reader.read_double()
        _args['time'] = _val_time
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        _val_peer = reader.read_long()
        _args['peer'] = _val_peer
        _val_data = reader.tgread_object()
        _args['data'] = _val_data
        return cls(**_args)


class InputBotAppId(TLObject):
    """TL type: inputBotAppID"""
    CONSTRUCTOR_ID = 0xa920bd7a
    SUBCLASS_OF_ID = 0xb6559951

    def __init__(self, id: int, access_hash: int):
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputBotAppId',
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputBotAppShortName(TLObject):
    """TL type: inputBotAppShortName"""
    CONSTRUCTOR_ID = 0x908c0407
    SUBCLASS_OF_ID = 0xb6559951

    def __init__(self, bot_id: 'TypeInputUser', short_name: str):
        self.bot_id = bot_id
        self.short_name = short_name

    def to_dict(self):
        return {
            '_': 'InputBotAppShortName',
            'bot_id': self.bot_id,
            'short_name': self.short_name,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.bot_id))
        buf.write(TLObject.serialize_bytes(self.short_name))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot_id = reader.tgread_object()
        _args['bot_id'] = _val_bot_id
        _val_short_name = reader.tgread_string()
        _args['short_name'] = _val_short_name
        return cls(**_args)


class InputBotInlineMessageGame(TLObject):
    """TL type: inputBotInlineMessageGame"""
    CONSTRUCTOR_ID = 0x4b425864
    SUBCLASS_OF_ID = 0x53fb4010

    def __init__(self, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'InputBotInlineMessageGame',
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class InputBotInlineMessageId(TLObject):
    """TL type: inputBotInlineMessageID"""
    CONSTRUCTOR_ID = 0x890c3d89
    SUBCLASS_OF_ID = 0x2dcd6300

    def __init__(self, dc_id: int, id: int, access_hash: int):
        self.dc_id = dc_id
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputBotInlineMessageId',
            'dc_id': self.dc_id,
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.dc_id))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_dc_id = reader.read_int()
        _args['dc_id'] = _val_dc_id
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputBotInlineMessageId64(TLObject):
    """TL type: inputBotInlineMessageID64"""
    CONSTRUCTOR_ID = 0xb6d915d7
    SUBCLASS_OF_ID = 0x2dcd6300

    def __init__(self, dc_id: int, owner_id: int, id: int, access_hash: int):
        self.dc_id = dc_id
        self.owner_id = owner_id
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputBotInlineMessageId64',
            'dc_id': self.dc_id,
            'owner_id': self.owner_id,
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.dc_id))
        buf.write(struct.pack('<q', self.owner_id))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_dc_id = reader.read_int()
        _args['dc_id'] = _val_dc_id
        _val_owner_id = reader.read_long()
        _args['owner_id'] = _val_owner_id
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputBotInlineMessageMediaAuto(TLObject):
    """TL type: inputBotInlineMessageMediaAuto"""
    CONSTRUCTOR_ID = 0x3380c786
    SUBCLASS_OF_ID = 0x53fb4010

    def __init__(self, message: str, invert_media: Optional[bool] = None, entities: Optional[List['TypeMessageEntity']] = None, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.message = message
        self.invert_media = invert_media
        self.entities = entities
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'InputBotInlineMessageMediaAuto',
            'message': self.message,
            'invert_media': self.invert_media,
            'entities': self.entities,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.invert_media:
            flags |= (1 << 3)
        if self.entities is not None:
            flags |= (1 << 1)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.message))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['invert_media'] = bool(flags & (1 << 3))
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class InputBotInlineMessageMediaContact(TLObject):
    """TL type: inputBotInlineMessageMediaContact"""
    CONSTRUCTOR_ID = 0xa6edbffd
    SUBCLASS_OF_ID = 0x53fb4010

    def __init__(self, phone_number: str, first_name: str, last_name: str, vcard: str, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.phone_number = phone_number
        self.first_name = first_name
        self.last_name = last_name
        self.vcard = vcard
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'InputBotInlineMessageMediaContact',
            'phone_number': self.phone_number,
            'first_name': self.first_name,
            'last_name': self.last_name,
            'vcard': self.vcard,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.first_name))
        buf.write(TLObject.serialize_bytes(self.last_name))
        buf.write(TLObject.serialize_bytes(self.vcard))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_first_name = reader.tgread_string()
        _args['first_name'] = _val_first_name
        _val_last_name = reader.tgread_string()
        _args['last_name'] = _val_last_name
        _val_vcard = reader.tgread_string()
        _args['vcard'] = _val_vcard
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class InputBotInlineMessageMediaGeo(TLObject):
    """TL type: inputBotInlineMessageMediaGeo"""
    CONSTRUCTOR_ID = 0x96929a85
    SUBCLASS_OF_ID = 0x53fb4010

    def __init__(self, geo_point: 'TypeInputGeoPoint', heading: Optional[int] = None, period: Optional[int] = None, proximity_notification_radius: Optional[int] = None, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.geo_point = geo_point
        self.heading = heading
        self.period = period
        self.proximity_notification_radius = proximity_notification_radius
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'InputBotInlineMessageMediaGeo',
            'geo_point': self.geo_point,
            'heading': self.heading,
            'period': self.period,
            'proximity_notification_radius': self.proximity_notification_radius,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.heading is not None:
            flags |= (1 << 0)
        if self.period is not None:
            flags |= (1 << 1)
        if self.proximity_notification_radius is not None:
            flags |= (1 << 3)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.geo_point))
        if self.heading is not None:
            buf.write(struct.pack('<i', self.heading))
        if self.period is not None:
            buf.write(struct.pack('<i', self.period))
        if self.proximity_notification_radius is not None:
            buf.write(struct.pack('<i', self.proximity_notification_radius))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_geo_point = reader.tgread_object()
        _args['geo_point'] = _val_geo_point
        if flags & (1 << 0):
            _val_heading = reader.read_int()
            _args['heading'] = _val_heading
        else:
            _args['heading'] = None
        if flags & (1 << 1):
            _val_period = reader.read_int()
            _args['period'] = _val_period
        else:
            _args['period'] = None
        if flags & (1 << 3):
            _val_proximity_notification_radius = reader.read_int()
            _args['proximity_notification_radius'] = _val_proximity_notification_radius
        else:
            _args['proximity_notification_radius'] = None
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class InputBotInlineMessageMediaInvoice(TLObject):
    """TL type: inputBotInlineMessageMediaInvoice"""
    CONSTRUCTOR_ID = 0xd7e78225
    SUBCLASS_OF_ID = 0x53fb4010

    def __init__(self, title: str, description: str, invoice: 'TypeInvoice', payload: bytes, provider: str, provider_data: 'TypeDataJSON', photo: Optional['TypeInputWebDocument'] = None, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.title = title
        self.description = description
        self.invoice = invoice
        self.payload = payload
        self.provider = provider
        self.provider_data = provider_data
        self.photo = photo
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'InputBotInlineMessageMediaInvoice',
            'title': self.title,
            'description': self.description,
            'invoice': self.invoice,
            'payload': self.payload,
            'provider': self.provider,
            'provider_data': self.provider_data,
            'photo': self.photo,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.photo is not None:
            flags |= (1 << 0)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.description))
        buf.write(bytes(self.invoice))
        buf.write(TLObject.serialize_bytes(self.payload))
        buf.write(TLObject.serialize_bytes(self.provider))
        buf.write(bytes(self.provider_data))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_description = reader.tgread_string()
        _args['description'] = _val_description
        if flags & (1 << 0):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        _val_invoice = reader.tgread_object()
        _args['invoice'] = _val_invoice
        _val_payload = reader.tgread_bytes()
        _args['payload'] = _val_payload
        _val_provider = reader.tgread_string()
        _args['provider'] = _val_provider
        _val_provider_data = reader.tgread_object()
        _args['provider_data'] = _val_provider_data
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class InputBotInlineMessageMediaVenue(TLObject):
    """TL type: inputBotInlineMessageMediaVenue"""
    CONSTRUCTOR_ID = 0x417bbf11
    SUBCLASS_OF_ID = 0x53fb4010

    def __init__(self, geo_point: 'TypeInputGeoPoint', title: str, address: str, provider: str, venue_id: str, venue_type: str, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.geo_point = geo_point
        self.title = title
        self.address = address
        self.provider = provider
        self.venue_id = venue_id
        self.venue_type = venue_type
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'InputBotInlineMessageMediaVenue',
            'geo_point': self.geo_point,
            'title': self.title,
            'address': self.address,
            'provider': self.provider,
            'venue_id': self.venue_id,
            'venue_type': self.venue_type,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.geo_point))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.address))
        buf.write(TLObject.serialize_bytes(self.provider))
        buf.write(TLObject.serialize_bytes(self.venue_id))
        buf.write(TLObject.serialize_bytes(self.venue_type))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_geo_point = reader.tgread_object()
        _args['geo_point'] = _val_geo_point
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_address = reader.tgread_string()
        _args['address'] = _val_address
        _val_provider = reader.tgread_string()
        _args['provider'] = _val_provider
        _val_venue_id = reader.tgread_string()
        _args['venue_id'] = _val_venue_id
        _val_venue_type = reader.tgread_string()
        _args['venue_type'] = _val_venue_type
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class InputBotInlineMessageMediaWebPage(TLObject):
    """TL type: inputBotInlineMessageMediaWebPage"""
    CONSTRUCTOR_ID = 0xbddcc510
    SUBCLASS_OF_ID = 0x53fb4010

    def __init__(self, message: str, url: str, invert_media: Optional[bool] = None, force_large_media: Optional[bool] = None, force_small_media: Optional[bool] = None, optional: Optional[bool] = None, entities: Optional[List['TypeMessageEntity']] = None, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.message = message
        self.url = url
        self.invert_media = invert_media
        self.force_large_media = force_large_media
        self.force_small_media = force_small_media
        self.optional = optional
        self.entities = entities
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'InputBotInlineMessageMediaWebPage',
            'message': self.message,
            'url': self.url,
            'invert_media': self.invert_media,
            'force_large_media': self.force_large_media,
            'force_small_media': self.force_small_media,
            'optional': self.optional,
            'entities': self.entities,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.invert_media:
            flags |= (1 << 3)
        if self.force_large_media:
            flags |= (1 << 4)
        if self.force_small_media:
            flags |= (1 << 5)
        if self.optional:
            flags |= (1 << 6)
        if self.entities is not None:
            flags |= (1 << 1)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.message))
        buf.write(TLObject.serialize_bytes(self.url))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['invert_media'] = bool(flags & (1 << 3))
        _args['force_large_media'] = bool(flags & (1 << 4))
        _args['force_small_media'] = bool(flags & (1 << 5))
        _args['optional'] = bool(flags & (1 << 6))
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class InputBotInlineMessageText(TLObject):
    """TL type: inputBotInlineMessageText"""
    CONSTRUCTOR_ID = 0x3dcd7a87
    SUBCLASS_OF_ID = 0x53fb4010

    def __init__(self, message: str, no_webpage: Optional[bool] = None, invert_media: Optional[bool] = None, entities: Optional[List['TypeMessageEntity']] = None, reply_markup: Optional['TypeReplyMarkup'] = None):
        self.message = message
        self.no_webpage = no_webpage
        self.invert_media = invert_media
        self.entities = entities
        self.reply_markup = reply_markup

    def to_dict(self):
        return {
            '_': 'InputBotInlineMessageText',
            'message': self.message,
            'no_webpage': self.no_webpage,
            'invert_media': self.invert_media,
            'entities': self.entities,
            'reply_markup': self.reply_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.no_webpage:
            flags |= (1 << 0)
        if self.invert_media:
            flags |= (1 << 3)
        if self.entities is not None:
            flags |= (1 << 1)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.message))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['no_webpage'] = bool(flags & (1 << 0))
        _args['invert_media'] = bool(flags & (1 << 3))
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        return cls(**_args)


class InputBotInlineResult(TLObject):
    """TL type: inputBotInlineResult"""
    CONSTRUCTOR_ID = 0x88bf9319
    SUBCLASS_OF_ID = 0x80a4a3de

    def __init__(self, id: str, type: str, send_message: 'TypeInputBotInlineMessage', title: Optional[str] = None, description: Optional[str] = None, url: Optional[str] = None, thumb: Optional['TypeInputWebDocument'] = None, content: Optional['TypeInputWebDocument'] = None):
        self.id = id
        self.type = type
        self.send_message = send_message
        self.title = title
        self.description = description
        self.url = url
        self.thumb = thumb
        self.content = content

    def to_dict(self):
        return {
            '_': 'InputBotInlineResult',
            'id': self.id,
            'type': self.type,
            'send_message': self.send_message,
            'title': self.title,
            'description': self.description,
            'url': self.url,
            'thumb': self.thumb,
            'content': self.content,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.title is not None:
            flags |= (1 << 1)
        if self.description is not None:
            flags |= (1 << 2)
        if self.url is not None:
            flags |= (1 << 3)
        if self.thumb is not None:
            flags |= (1 << 4)
        if self.content is not None:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(bytes(self.send_message))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.description is not None:
            buf.write(TLObject.serialize_bytes(self.description))
        if self.url is not None:
            buf.write(TLObject.serialize_bytes(self.url))
        if self.thumb is not None:
            buf.write(bytes(self.thumb))
        if self.content is not None:
            buf.write(bytes(self.content))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        if flags & (1 << 1):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 2):
            _val_description = reader.tgread_string()
            _args['description'] = _val_description
        else:
            _args['description'] = None
        if flags & (1 << 3):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        if flags & (1 << 4):
            _val_thumb = reader.tgread_object()
            _args['thumb'] = _val_thumb
        else:
            _args['thumb'] = None
        if flags & (1 << 5):
            _val_content = reader.tgread_object()
            _args['content'] = _val_content
        else:
            _args['content'] = None
        _val_send_message = reader.tgread_object()
        _args['send_message'] = _val_send_message
        return cls(**_args)


class InputBotInlineResultDocument(TLObject):
    """TL type: inputBotInlineResultDocument"""
    CONSTRUCTOR_ID = 0xfff8fdc4
    SUBCLASS_OF_ID = 0x80a4a3de

    def __init__(self, id: str, type: str, document: 'TypeInputDocument', send_message: 'TypeInputBotInlineMessage', title: Optional[str] = None, description: Optional[str] = None):
        self.id = id
        self.type = type
        self.document = document
        self.send_message = send_message
        self.title = title
        self.description = description

    def to_dict(self):
        return {
            '_': 'InputBotInlineResultDocument',
            'id': self.id,
            'type': self.type,
            'document': self.document,
            'send_message': self.send_message,
            'title': self.title,
            'description': self.description,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.title is not None:
            flags |= (1 << 1)
        if self.description is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(bytes(self.document))
        buf.write(bytes(self.send_message))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.description is not None:
            buf.write(TLObject.serialize_bytes(self.description))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        if flags & (1 << 1):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 2):
            _val_description = reader.tgread_string()
            _args['description'] = _val_description
        else:
            _args['description'] = None
        _val_document = reader.tgread_object()
        _args['document'] = _val_document
        _val_send_message = reader.tgread_object()
        _args['send_message'] = _val_send_message
        return cls(**_args)


class InputBotInlineResultGame(TLObject):
    """TL type: inputBotInlineResultGame"""
    CONSTRUCTOR_ID = 0x4fa417f2
    SUBCLASS_OF_ID = 0x80a4a3de

    def __init__(self, id: str, short_name: str, send_message: 'TypeInputBotInlineMessage'):
        self.id = id
        self.short_name = short_name
        self.send_message = send_message

    def to_dict(self):
        return {
            '_': 'InputBotInlineResultGame',
            'id': self.id,
            'short_name': self.short_name,
            'send_message': self.send_message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.short_name))
        buf.write(bytes(self.send_message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_short_name = reader.tgread_string()
        _args['short_name'] = _val_short_name
        _val_send_message = reader.tgread_object()
        _args['send_message'] = _val_send_message
        return cls(**_args)


class InputBotInlineResultPhoto(TLObject):
    """TL type: inputBotInlineResultPhoto"""
    CONSTRUCTOR_ID = 0xa8d864a7
    SUBCLASS_OF_ID = 0x80a4a3de

    def __init__(self, id: str, type: str, photo: 'TypeInputPhoto', send_message: 'TypeInputBotInlineMessage'):
        self.id = id
        self.type = type
        self.photo = photo
        self.send_message = send_message

    def to_dict(self):
        return {
            '_': 'InputBotInlineResultPhoto',
            'id': self.id,
            'type': self.type,
            'photo': self.photo,
            'send_message': self.send_message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(bytes(self.photo))
        buf.write(bytes(self.send_message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        _val_photo = reader.tgread_object()
        _args['photo'] = _val_photo
        _val_send_message = reader.tgread_object()
        _args['send_message'] = _val_send_message
        return cls(**_args)


class InputBusinessAwayMessage(TLObject):
    """TL type: inputBusinessAwayMessage"""
    CONSTRUCTOR_ID = 0x832175e0
    SUBCLASS_OF_ID = 0xd8559c77

    def __init__(self, shortcut_id: int, schedule: 'TypeBusinessAwayMessageSchedule', recipients: 'TypeInputBusinessRecipients', offline_only: Optional[bool] = None):
        self.shortcut_id = shortcut_id
        self.schedule = schedule
        self.recipients = recipients
        self.offline_only = offline_only

    def to_dict(self):
        return {
            '_': 'InputBusinessAwayMessage',
            'shortcut_id': self.shortcut_id,
            'schedule': self.schedule,
            'recipients': self.recipients,
            'offline_only': self.offline_only,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.offline_only:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.shortcut_id))
        buf.write(bytes(self.schedule))
        buf.write(bytes(self.recipients))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['offline_only'] = bool(flags & (1 << 0))
        _val_shortcut_id = reader.read_int()
        _args['shortcut_id'] = _val_shortcut_id
        _val_schedule = reader.tgread_object()
        _args['schedule'] = _val_schedule
        _val_recipients = reader.tgread_object()
        _args['recipients'] = _val_recipients
        return cls(**_args)


class InputBusinessBotRecipients(TLObject):
    """TL type: inputBusinessBotRecipients"""
    CONSTRUCTOR_ID = 0xc4e5921e
    SUBCLASS_OF_ID = 0xa9d3f55b

    def __init__(self, existing_chats: Optional[bool] = None, new_chats: Optional[bool] = None, contacts: Optional[bool] = None, non_contacts: Optional[bool] = None, exclude_selected: Optional[bool] = None, users: Optional[List['TypeInputUser']] = None, exclude_users: Optional[List['TypeInputUser']] = None):
        self.existing_chats = existing_chats
        self.new_chats = new_chats
        self.contacts = contacts
        self.non_contacts = non_contacts
        self.exclude_selected = exclude_selected
        self.users = users
        self.exclude_users = exclude_users

    def to_dict(self):
        return {
            '_': 'InputBusinessBotRecipients',
            'existing_chats': self.existing_chats,
            'new_chats': self.new_chats,
            'contacts': self.contacts,
            'non_contacts': self.non_contacts,
            'exclude_selected': self.exclude_selected,
            'users': self.users,
            'exclude_users': self.exclude_users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.existing_chats:
            flags |= (1 << 0)
        if self.new_chats:
            flags |= (1 << 1)
        if self.contacts:
            flags |= (1 << 2)
        if self.non_contacts:
            flags |= (1 << 3)
        if self.exclude_selected:
            flags |= (1 << 5)
        if self.users is not None:
            flags |= (1 << 4)
        if self.exclude_users is not None:
            flags |= (1 << 6)
        buf.write(struct.pack('<I', flags))
        if self.users is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.users)))
            for item in self.users:
                buf.write(bytes(self.item))
        if self.exclude_users is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.exclude_users)))
            for item in self.exclude_users:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['existing_chats'] = bool(flags & (1 << 0))
        _args['new_chats'] = bool(flags & (1 << 1))
        _args['contacts'] = bool(flags & (1 << 2))
        _args['non_contacts'] = bool(flags & (1 << 3))
        _args['exclude_selected'] = bool(flags & (1 << 5))
        if flags & (1 << 4):
            reader.read_int(signed=False)  # skip vector id
            _count_users = reader.read_int()
            _list_users = []
            for _ in range(_count_users):
                _item_users = reader.tgread_object()
                _list_users.append(_item_users)
            _args['users'] = _list_users
        else:
            _args['users'] = None
        if flags & (1 << 6):
            reader.read_int(signed=False)  # skip vector id
            _count_exclude_users = reader.read_int()
            _list_exclude_users = []
            for _ in range(_count_exclude_users):
                _item_exclude_users = reader.tgread_object()
                _list_exclude_users.append(_item_exclude_users)
            _args['exclude_users'] = _list_exclude_users
        else:
            _args['exclude_users'] = None
        return cls(**_args)


class InputBusinessChatLink(TLObject):
    """TL type: inputBusinessChatLink"""
    CONSTRUCTOR_ID = 0x11679fa7
    SUBCLASS_OF_ID = 0xab670513

    def __init__(self, message: str, entities: Optional[List['TypeMessageEntity']] = None, title: Optional[str] = None):
        self.message = message
        self.entities = entities
        self.title = title

    def to_dict(self):
        return {
            '_': 'InputBusinessChatLink',
            'message': self.message,
            'entities': self.entities,
            'title': self.title,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.entities is not None:
            flags |= (1 << 0)
        if self.title is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.message))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 1):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        return cls(**_args)


class InputBusinessGreetingMessage(TLObject):
    """TL type: inputBusinessGreetingMessage"""
    CONSTRUCTOR_ID = 0x0194cb3b
    SUBCLASS_OF_ID = 0x6278dcdd

    def __init__(self, shortcut_id: int, recipients: 'TypeInputBusinessRecipients', no_activity_days: int):
        self.shortcut_id = shortcut_id
        self.recipients = recipients
        self.no_activity_days = no_activity_days

    def to_dict(self):
        return {
            '_': 'InputBusinessGreetingMessage',
            'shortcut_id': self.shortcut_id,
            'recipients': self.recipients,
            'no_activity_days': self.no_activity_days,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.shortcut_id))
        buf.write(bytes(self.recipients))
        buf.write(struct.pack('<i', self.no_activity_days))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_shortcut_id = reader.read_int()
        _args['shortcut_id'] = _val_shortcut_id
        _val_recipients = reader.tgread_object()
        _args['recipients'] = _val_recipients
        _val_no_activity_days = reader.read_int()
        _args['no_activity_days'] = _val_no_activity_days
        return cls(**_args)


class InputBusinessIntro(TLObject):
    """TL type: inputBusinessIntro"""
    CONSTRUCTOR_ID = 0x09c469cd
    SUBCLASS_OF_ID = 0x645a767d

    def __init__(self, title: str, description: str, sticker: Optional['TypeInputDocument'] = None):
        self.title = title
        self.description = description
        self.sticker = sticker

    def to_dict(self):
        return {
            '_': 'InputBusinessIntro',
            'title': self.title,
            'description': self.description,
            'sticker': self.sticker,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.sticker is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.description))
        if self.sticker is not None:
            buf.write(bytes(self.sticker))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_description = reader.tgread_string()
        _args['description'] = _val_description
        if flags & (1 << 0):
            _val_sticker = reader.tgread_object()
            _args['sticker'] = _val_sticker
        else:
            _args['sticker'] = None
        return cls(**_args)


class InputBusinessRecipients(TLObject):
    """TL type: inputBusinessRecipients"""
    CONSTRUCTOR_ID = 0x6f8b32aa
    SUBCLASS_OF_ID = 0x0d7ee53f

    def __init__(self, existing_chats: Optional[bool] = None, new_chats: Optional[bool] = None, contacts: Optional[bool] = None, non_contacts: Optional[bool] = None, exclude_selected: Optional[bool] = None, users: Optional[List['TypeInputUser']] = None):
        self.existing_chats = existing_chats
        self.new_chats = new_chats
        self.contacts = contacts
        self.non_contacts = non_contacts
        self.exclude_selected = exclude_selected
        self.users = users

    def to_dict(self):
        return {
            '_': 'InputBusinessRecipients',
            'existing_chats': self.existing_chats,
            'new_chats': self.new_chats,
            'contacts': self.contacts,
            'non_contacts': self.non_contacts,
            'exclude_selected': self.exclude_selected,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.existing_chats:
            flags |= (1 << 0)
        if self.new_chats:
            flags |= (1 << 1)
        if self.contacts:
            flags |= (1 << 2)
        if self.non_contacts:
            flags |= (1 << 3)
        if self.exclude_selected:
            flags |= (1 << 5)
        if self.users is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        if self.users is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.users)))
            for item in self.users:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['existing_chats'] = bool(flags & (1 << 0))
        _args['new_chats'] = bool(flags & (1 << 1))
        _args['contacts'] = bool(flags & (1 << 2))
        _args['non_contacts'] = bool(flags & (1 << 3))
        _args['exclude_selected'] = bool(flags & (1 << 5))
        if flags & (1 << 4):
            reader.read_int(signed=False)  # skip vector id
            _count_users = reader.read_int()
            _list_users = []
            for _ in range(_count_users):
                _item_users = reader.tgread_object()
                _list_users.append(_item_users)
            _args['users'] = _list_users
        else:
            _args['users'] = None
        return cls(**_args)


class InputChannel(TLObject):
    """TL type: inputChannel"""
    CONSTRUCTOR_ID = 0xf35aec28
    SUBCLASS_OF_ID = 0x40f202fd

    def __init__(self, channel_id: int, access_hash: int):
        self.channel_id = channel_id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputChannel',
            'channel_id': self.channel_id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputChannelEmpty(TLObject):
    """TL type: inputChannelEmpty"""
    CONSTRUCTOR_ID = 0xee8c1e86
    SUBCLASS_OF_ID = 0x40f202fd

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputChannelEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputChannelFromMessage(TLObject):
    """TL type: inputChannelFromMessage"""
    CONSTRUCTOR_ID = 0x5b934f9d
    SUBCLASS_OF_ID = 0x40f202fd

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, channel_id: int):
        self.peer = peer
        self.msg_id = msg_id
        self.channel_id = channel_id

    def to_dict(self):
        return {
            '_': 'InputChannelFromMessage',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'channel_id': self.channel_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<q', self.channel_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        return cls(**_args)


class InputChatPhoto(TLObject):
    """TL type: inputChatPhoto"""
    CONSTRUCTOR_ID = 0x8953ad37
    SUBCLASS_OF_ID = 0xd4eb2d74

    def __init__(self, id: 'TypeInputPhoto'):
        self.id = id

    def to_dict(self):
        return {
            '_': 'InputChatPhoto',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        return cls(**_args)


class InputChatPhotoEmpty(TLObject):
    """TL type: inputChatPhotoEmpty"""
    CONSTRUCTOR_ID = 0x1ca48f57
    SUBCLASS_OF_ID = 0xd4eb2d74

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputChatPhotoEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputChatTheme(TLObject):
    """TL type: inputChatTheme"""
    CONSTRUCTOR_ID = 0xc93de95c
    SUBCLASS_OF_ID = 0x57294e64

    def __init__(self, emoticon: str):
        self.emoticon = emoticon

    def to_dict(self):
        return {
            '_': 'InputChatTheme',
            'emoticon': self.emoticon,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.emoticon))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        return cls(**_args)


class InputChatThemeEmpty(TLObject):
    """TL type: inputChatThemeEmpty"""
    CONSTRUCTOR_ID = 0x83268483
    SUBCLASS_OF_ID = 0x57294e64

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputChatThemeEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputChatThemeUniqueGift(TLObject):
    """TL type: inputChatThemeUniqueGift"""
    CONSTRUCTOR_ID = 0x87e5dfe4
    SUBCLASS_OF_ID = 0x57294e64

    def __init__(self, slug: str):
        self.slug = slug

    def to_dict(self):
        return {
            '_': 'InputChatThemeUniqueGift',
            'slug': self.slug,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.slug))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        return cls(**_args)


class InputChatUploadedPhoto(TLObject):
    """TL type: inputChatUploadedPhoto"""
    CONSTRUCTOR_ID = 0xbdcdaec0
    SUBCLASS_OF_ID = 0xd4eb2d74

    def __init__(self, file: Optional['TypeInputFile'] = None, video: Optional['TypeInputFile'] = None, video_start_ts: Optional[float] = None, video_emoji_markup: Optional['TypeVideoSize'] = None):
        self.file = file
        self.video = video
        self.video_start_ts = video_start_ts
        self.video_emoji_markup = video_emoji_markup

    def to_dict(self):
        return {
            '_': 'InputChatUploadedPhoto',
            'file': self.file,
            'video': self.video,
            'video_start_ts': self.video_start_ts,
            'video_emoji_markup': self.video_emoji_markup,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.file is not None:
            flags |= (1 << 0)
        if self.video is not None:
            flags |= (1 << 1)
        if self.video_start_ts is not None:
            flags |= (1 << 2)
        if self.video_emoji_markup is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        if self.file is not None:
            buf.write(bytes(self.file))
        if self.video is not None:
            buf.write(bytes(self.video))
        if self.video_start_ts is not None:
            buf.write(struct.pack('<d', self.video_start_ts))
        if self.video_emoji_markup is not None:
            buf.write(bytes(self.video_emoji_markup))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_file = reader.tgread_object()
            _args['file'] = _val_file
        else:
            _args['file'] = None
        if flags & (1 << 1):
            _val_video = reader.tgread_object()
            _args['video'] = _val_video
        else:
            _args['video'] = None
        if flags & (1 << 2):
            _val_video_start_ts = reader.read_double()
            _args['video_start_ts'] = _val_video_start_ts
        else:
            _args['video_start_ts'] = None
        if flags & (1 << 3):
            _val_video_emoji_markup = reader.tgread_object()
            _args['video_emoji_markup'] = _val_video_emoji_markup
        else:
            _args['video_emoji_markup'] = None
        return cls(**_args)


class InputChatlistDialogFilter(TLObject):
    """TL type: inputChatlistDialogFilter"""
    CONSTRUCTOR_ID = 0xf3e0da33
    SUBCLASS_OF_ID = 0x023f9659

    def __init__(self, filter_id: int):
        self.filter_id = filter_id

    def to_dict(self):
        return {
            '_': 'InputChatlistDialogFilter',
            'filter_id': self.filter_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.filter_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_filter_id = reader.read_int()
        _args['filter_id'] = _val_filter_id
        return cls(**_args)


class InputCheckPasswordEmpty(TLObject):
    """TL type: inputCheckPasswordEmpty"""
    CONSTRUCTOR_ID = 0x9880f658
    SUBCLASS_OF_ID = 0xd41af560

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputCheckPasswordEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputCheckPasswordSrp(TLObject):
    """TL type: inputCheckPasswordSRP"""
    CONSTRUCTOR_ID = 0xd27ff082
    SUBCLASS_OF_ID = 0xd41af560

    def __init__(self, srp_id: int, A: bytes, M1: bytes):
        self.srp_id = srp_id
        self.A = A
        self.M1 = M1

    def to_dict(self):
        return {
            '_': 'InputCheckPasswordSrp',
            'srp_id': self.srp_id,
            'A': self.A,
            'M1': self.M1,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.srp_id))
        buf.write(TLObject.serialize_bytes(self.A))
        buf.write(TLObject.serialize_bytes(self.M1))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_srp_id = reader.read_long()
        _args['srp_id'] = _val_srp_id
        _val_A = reader.tgread_bytes()
        _args['A'] = _val_A
        _val_M1 = reader.tgread_bytes()
        _args['M1'] = _val_M1
        return cls(**_args)


class InputClientProxy(TLObject):
    """TL type: inputClientProxy"""
    CONSTRUCTOR_ID = 0x75588b3f
    SUBCLASS_OF_ID = 0x091a4346

    def __init__(self, address: str, port: int):
        self.address = address
        self.port = port

    def to_dict(self):
        return {
            '_': 'InputClientProxy',
            'address': self.address,
            'port': self.port,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.address))
        buf.write(struct.pack('<i', self.port))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_address = reader.tgread_string()
        _args['address'] = _val_address
        _val_port = reader.read_int()
        _args['port'] = _val_port
        return cls(**_args)


class InputCollectiblePhone(TLObject):
    """TL type: inputCollectiblePhone"""
    CONSTRUCTOR_ID = 0xa2e214a4
    SUBCLASS_OF_ID = 0x2a0f81eb

    def __init__(self, phone: str):
        self.phone = phone

    def to_dict(self):
        return {
            '_': 'InputCollectiblePhone',
            'phone': self.phone,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.phone))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone = reader.tgread_string()
        _args['phone'] = _val_phone
        return cls(**_args)


class InputCollectibleUsername(TLObject):
    """TL type: inputCollectibleUsername"""
    CONSTRUCTOR_ID = 0xe39460a9
    SUBCLASS_OF_ID = 0x2a0f81eb

    def __init__(self, username: str):
        self.username = username

    def to_dict(self):
        return {
            '_': 'InputCollectibleUsername',
            'username': self.username,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.username))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_username = reader.tgread_string()
        _args['username'] = _val_username
        return cls(**_args)


class InputDialogPeer(TLObject):
    """TL type: inputDialogPeer"""
    CONSTRUCTOR_ID = 0xfcaafeb7
    SUBCLASS_OF_ID = 0xa21c9795

    def __init__(self, peer: 'TypeInputPeer'):
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'InputDialogPeer',
            'peer': self.peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class InputDialogPeerFolder(TLObject):
    """TL type: inputDialogPeerFolder"""
    CONSTRUCTOR_ID = 0x64600527
    SUBCLASS_OF_ID = 0xa21c9795

    def __init__(self, folder_id: int):
        self.folder_id = folder_id

    def to_dict(self):
        return {
            '_': 'InputDialogPeerFolder',
            'folder_id': self.folder_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.folder_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_folder_id = reader.read_int()
        _args['folder_id'] = _val_folder_id
        return cls(**_args)


class InputDocument(TLObject):
    """TL type: inputDocument"""
    CONSTRUCTOR_ID = 0x1abfb575
    SUBCLASS_OF_ID = 0xf33fdb68

    def __init__(self, id: int, access_hash: int, file_reference: bytes):
        self.id = id
        self.access_hash = access_hash
        self.file_reference = file_reference

    def to_dict(self):
        return {
            '_': 'InputDocument',
            'id': self.id,
            'access_hash': self.access_hash,
            'file_reference': self.file_reference,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.file_reference))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_file_reference = reader.tgread_bytes()
        _args['file_reference'] = _val_file_reference
        return cls(**_args)


class InputDocumentEmpty(TLObject):
    """TL type: inputDocumentEmpty"""
    CONSTRUCTOR_ID = 0x72f0eaae
    SUBCLASS_OF_ID = 0xf33fdb68

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputDocumentEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputDocumentFileLocation(TLObject):
    """TL type: inputDocumentFileLocation"""
    CONSTRUCTOR_ID = 0xbad07584
    SUBCLASS_OF_ID = 0x1523d462

    def __init__(self, id: int, access_hash: int, file_reference: bytes, thumb_size: str):
        self.id = id
        self.access_hash = access_hash
        self.file_reference = file_reference
        self.thumb_size = thumb_size

    def to_dict(self):
        return {
            '_': 'InputDocumentFileLocation',
            'id': self.id,
            'access_hash': self.access_hash,
            'file_reference': self.file_reference,
            'thumb_size': self.thumb_size,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.file_reference))
        buf.write(TLObject.serialize_bytes(self.thumb_size))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_file_reference = reader.tgread_bytes()
        _args['file_reference'] = _val_file_reference
        _val_thumb_size = reader.tgread_string()
        _args['thumb_size'] = _val_thumb_size
        return cls(**_args)


class InputEmojiStatusCollectible(TLObject):
    """TL type: inputEmojiStatusCollectible"""
    CONSTRUCTOR_ID = 0x07141dbf
    SUBCLASS_OF_ID = 0xf930b138

    def __init__(self, collectible_id: int, until: Optional[datetime] = None):
        self.collectible_id = collectible_id
        self.until = until

    def to_dict(self):
        return {
            '_': 'InputEmojiStatusCollectible',
            'collectible_id': self.collectible_id,
            'until': self.until,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.until is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.collectible_id))
        if self.until is not None:
            buf.write(struct.pack('<i', self.until))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_collectible_id = reader.read_long()
        _args['collectible_id'] = _val_collectible_id
        if flags & (1 << 0):
            _val_until = reader.read_int()
            _args['until'] = _val_until
        else:
            _args['until'] = None
        return cls(**_args)


class InputEncryptedChat(TLObject):
    """TL type: inputEncryptedChat"""
    CONSTRUCTOR_ID = 0xf141b5e1
    SUBCLASS_OF_ID = 0x6c7606c0

    def __init__(self, chat_id: int, access_hash: int):
        self.chat_id = chat_id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputEncryptedChat',
            'chat_id': self.chat_id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.chat_id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_int()
        _args['chat_id'] = _val_chat_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputEncryptedFile(TLObject):
    """TL type: inputEncryptedFile"""
    CONSTRUCTOR_ID = 0x5a17b5e5
    SUBCLASS_OF_ID = 0x8574c27a

    def __init__(self, id: int, access_hash: int):
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputEncryptedFile',
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputEncryptedFileBigUploaded(TLObject):
    """TL type: inputEncryptedFileBigUploaded"""
    CONSTRUCTOR_ID = 0x2dc173c8
    SUBCLASS_OF_ID = 0x8574c27a

    def __init__(self, id: int, parts: int, key_fingerprint: int):
        self.id = id
        self.parts = parts
        self.key_fingerprint = key_fingerprint

    def to_dict(self):
        return {
            '_': 'InputEncryptedFileBigUploaded',
            'id': self.id,
            'parts': self.parts,
            'key_fingerprint': self.key_fingerprint,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<i', self.parts))
        buf.write(struct.pack('<i', self.key_fingerprint))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_parts = reader.read_int()
        _args['parts'] = _val_parts
        _val_key_fingerprint = reader.read_int()
        _args['key_fingerprint'] = _val_key_fingerprint
        return cls(**_args)


class InputEncryptedFileEmpty(TLObject):
    """TL type: inputEncryptedFileEmpty"""
    CONSTRUCTOR_ID = 0x1837c364
    SUBCLASS_OF_ID = 0x8574c27a

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputEncryptedFileEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputEncryptedFileLocation(TLObject):
    """TL type: inputEncryptedFileLocation"""
    CONSTRUCTOR_ID = 0xf5235d55
    SUBCLASS_OF_ID = 0x1523d462

    def __init__(self, id: int, access_hash: int):
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputEncryptedFileLocation',
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputEncryptedFileUploaded(TLObject):
    """TL type: inputEncryptedFileUploaded"""
    CONSTRUCTOR_ID = 0x64bd0306
    SUBCLASS_OF_ID = 0x8574c27a

    def __init__(self, id: int, parts: int, md5_checksum: str, key_fingerprint: int):
        self.id = id
        self.parts = parts
        self.md5_checksum = md5_checksum
        self.key_fingerprint = key_fingerprint

    def to_dict(self):
        return {
            '_': 'InputEncryptedFileUploaded',
            'id': self.id,
            'parts': self.parts,
            'md5_checksum': self.md5_checksum,
            'key_fingerprint': self.key_fingerprint,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<i', self.parts))
        buf.write(TLObject.serialize_bytes(self.md5_checksum))
        buf.write(struct.pack('<i', self.key_fingerprint))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_parts = reader.read_int()
        _args['parts'] = _val_parts
        _val_md5_checksum = reader.tgread_string()
        _args['md5_checksum'] = _val_md5_checksum
        _val_key_fingerprint = reader.read_int()
        _args['key_fingerprint'] = _val_key_fingerprint
        return cls(**_args)


class InputFile(TLObject):
    """TL type: inputFile"""
    CONSTRUCTOR_ID = 0xf52ff27f
    SUBCLASS_OF_ID = 0xe7655f1f

    def __init__(self, id: int, parts: int, name: str, md5_checksum: str):
        self.id = id
        self.parts = parts
        self.name = name
        self.md5_checksum = md5_checksum

    def to_dict(self):
        return {
            '_': 'InputFile',
            'id': self.id,
            'parts': self.parts,
            'name': self.name,
            'md5_checksum': self.md5_checksum,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<i', self.parts))
        buf.write(TLObject.serialize_bytes(self.name))
        buf.write(TLObject.serialize_bytes(self.md5_checksum))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_parts = reader.read_int()
        _args['parts'] = _val_parts
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        _val_md5_checksum = reader.tgread_string()
        _args['md5_checksum'] = _val_md5_checksum
        return cls(**_args)


class InputFileBig(TLObject):
    """TL type: inputFileBig"""
    CONSTRUCTOR_ID = 0xfa4f0bb5
    SUBCLASS_OF_ID = 0xe7655f1f

    def __init__(self, id: int, parts: int, name: str):
        self.id = id
        self.parts = parts
        self.name = name

    def to_dict(self):
        return {
            '_': 'InputFileBig',
            'id': self.id,
            'parts': self.parts,
            'name': self.name,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<i', self.parts))
        buf.write(TLObject.serialize_bytes(self.name))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_parts = reader.read_int()
        _args['parts'] = _val_parts
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        return cls(**_args)


class InputFileLocation(TLObject):
    """TL type: inputFileLocation"""
    CONSTRUCTOR_ID = 0xdfdaabe1
    SUBCLASS_OF_ID = 0x1523d462

    def __init__(self, volume_id: int, local_id: int, secret: int, file_reference: bytes):
        self.volume_id = volume_id
        self.local_id = local_id
        self.secret = secret
        self.file_reference = file_reference

    def to_dict(self):
        return {
            '_': 'InputFileLocation',
            'volume_id': self.volume_id,
            'local_id': self.local_id,
            'secret': self.secret,
            'file_reference': self.file_reference,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.volume_id))
        buf.write(struct.pack('<i', self.local_id))
        buf.write(struct.pack('<q', self.secret))
        buf.write(TLObject.serialize_bytes(self.file_reference))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_volume_id = reader.read_long()
        _args['volume_id'] = _val_volume_id
        _val_local_id = reader.read_int()
        _args['local_id'] = _val_local_id
        _val_secret = reader.read_long()
        _args['secret'] = _val_secret
        _val_file_reference = reader.tgread_bytes()
        _args['file_reference'] = _val_file_reference
        return cls(**_args)


class InputFileStoryDocument(TLObject):
    """TL type: inputFileStoryDocument"""
    CONSTRUCTOR_ID = 0x62dc8b48
    SUBCLASS_OF_ID = 0xe7655f1f

    def __init__(self, id: 'TypeInputDocument'):
        self.id = id

    def to_dict(self):
        return {
            '_': 'InputFileStoryDocument',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        return cls(**_args)


class InputFolderPeer(TLObject):
    """TL type: inputFolderPeer"""
    CONSTRUCTOR_ID = 0xfbd2c296
    SUBCLASS_OF_ID = 0x74825e00

    def __init__(self, peer: 'TypeInputPeer', folder_id: int):
        self.peer = peer
        self.folder_id = folder_id

    def to_dict(self):
        return {
            '_': 'InputFolderPeer',
            'peer': self.peer,
            'folder_id': self.folder_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.folder_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_folder_id = reader.read_int()
        _args['folder_id'] = _val_folder_id
        return cls(**_args)


class InputGameId(TLObject):
    """TL type: inputGameID"""
    CONSTRUCTOR_ID = 0x032c3e77
    SUBCLASS_OF_ID = 0x48d15883

    def __init__(self, id: int, access_hash: int):
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputGameId',
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputGameShortName(TLObject):
    """TL type: inputGameShortName"""
    CONSTRUCTOR_ID = 0xc331e80a
    SUBCLASS_OF_ID = 0x48d15883

    def __init__(self, bot_id: 'TypeInputUser', short_name: str):
        self.bot_id = bot_id
        self.short_name = short_name

    def to_dict(self):
        return {
            '_': 'InputGameShortName',
            'bot_id': self.bot_id,
            'short_name': self.short_name,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.bot_id))
        buf.write(TLObject.serialize_bytes(self.short_name))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot_id = reader.tgread_object()
        _args['bot_id'] = _val_bot_id
        _val_short_name = reader.tgread_string()
        _args['short_name'] = _val_short_name
        return cls(**_args)


class InputGeoPoint(TLObject):
    """TL type: inputGeoPoint"""
    CONSTRUCTOR_ID = 0x48222faf
    SUBCLASS_OF_ID = 0x0430d225

    def __init__(self, lat: float, long: float, accuracy_radius: Optional[int] = None):
        self.lat = lat
        self.long = long
        self.accuracy_radius = accuracy_radius

    def to_dict(self):
        return {
            '_': 'InputGeoPoint',
            'lat': self.lat,
            'long': self.long,
            'accuracy_radius': self.accuracy_radius,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.accuracy_radius is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<d', self.lat))
        buf.write(struct.pack('<d', self.long))
        if self.accuracy_radius is not None:
            buf.write(struct.pack('<i', self.accuracy_radius))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_lat = reader.read_double()
        _args['lat'] = _val_lat
        _val_long = reader.read_double()
        _args['long'] = _val_long
        if flags & (1 << 0):
            _val_accuracy_radius = reader.read_int()
            _args['accuracy_radius'] = _val_accuracy_radius
        else:
            _args['accuracy_radius'] = None
        return cls(**_args)


class InputGeoPointEmpty(TLObject):
    """TL type: inputGeoPointEmpty"""
    CONSTRUCTOR_ID = 0xe4c123d6
    SUBCLASS_OF_ID = 0x0430d225

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputGeoPointEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputGroupCall(TLObject):
    """TL type: inputGroupCall"""
    CONSTRUCTOR_ID = 0xd8aa840f
    SUBCLASS_OF_ID = 0x58611ab1

    def __init__(self, id: int, access_hash: int):
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputGroupCall',
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputGroupCallInviteMessage(TLObject):
    """TL type: inputGroupCallInviteMessage"""
    CONSTRUCTOR_ID = 0x8c10603f
    SUBCLASS_OF_ID = 0x58611ab1

    def __init__(self, msg_id: int):
        self.msg_id = msg_id

    def to_dict(self):
        return {
            '_': 'InputGroupCallInviteMessage',
            'msg_id': self.msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        return cls(**_args)


class InputGroupCallSlug(TLObject):
    """TL type: inputGroupCallSlug"""
    CONSTRUCTOR_ID = 0xfe06823f
    SUBCLASS_OF_ID = 0x58611ab1

    def __init__(self, slug: str):
        self.slug = slug

    def to_dict(self):
        return {
            '_': 'InputGroupCallSlug',
            'slug': self.slug,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.slug))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        return cls(**_args)


class InputGroupCallStream(TLObject):
    """TL type: inputGroupCallStream"""
    CONSTRUCTOR_ID = 0x0598a92a
    SUBCLASS_OF_ID = 0x1523d462

    def __init__(self, call: 'TypeInputGroupCall', time_ms: int, scale: int, video_channel: Optional[int] = None, video_quality: Optional[int] = None):
        self.call = call
        self.time_ms = time_ms
        self.scale = scale
        self.video_channel = video_channel
        self.video_quality = video_quality

    def to_dict(self):
        return {
            '_': 'InputGroupCallStream',
            'call': self.call,
            'time_ms': self.time_ms,
            'scale': self.scale,
            'video_channel': self.video_channel,
            'video_quality': self.video_quality,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.video_quality is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.call))
        buf.write(struct.pack('<q', self.time_ms))
        buf.write(struct.pack('<i', self.scale))
        if self.video_channel is not None:
            buf.write(struct.pack('<i', self.video_channel))
        if self.video_quality is not None:
            buf.write(struct.pack('<i', self.video_quality))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_time_ms = reader.read_long()
        _args['time_ms'] = _val_time_ms
        _val_scale = reader.read_int()
        _args['scale'] = _val_scale
        if flags & (1 << 0):
            _val_video_channel = reader.read_int()
            _args['video_channel'] = _val_video_channel
        else:
            _args['video_channel'] = None
        if flags & (1 << 0):
            _val_video_quality = reader.read_int()
            _args['video_quality'] = _val_video_quality
        else:
            _args['video_quality'] = None
        return cls(**_args)


class InputInvoiceBusinessBotTransferStars(TLObject):
    """TL type: inputInvoiceBusinessBotTransferStars"""
    CONSTRUCTOR_ID = 0xf4997e42
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, bot: 'TypeInputUser', stars: int):
        self.bot = bot
        self.stars = stars

    def to_dict(self):
        return {
            '_': 'InputInvoiceBusinessBotTransferStars',
            'bot': self.bot,
            'stars': self.stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.bot))
        buf.write(struct.pack('<q', self.stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        return cls(**_args)


class InputInvoiceChatInviteSubscription(TLObject):
    """TL type: inputInvoiceChatInviteSubscription"""
    CONSTRUCTOR_ID = 0x34e793f1
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, hash: str):
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'InputInvoiceChatInviteSubscription',
            'hash': self.hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_hash = reader.tgread_string()
        _args['hash'] = _val_hash
        return cls(**_args)


class InputInvoiceMessage(TLObject):
    """TL type: inputInvoiceMessage"""
    CONSTRUCTOR_ID = 0xc5b56859
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, peer: 'TypeInputPeer', msg_id: int):
        self.peer = peer
        self.msg_id = msg_id

    def to_dict(self):
        return {
            '_': 'InputInvoiceMessage',
            'peer': self.peer,
            'msg_id': self.msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        return cls(**_args)


class InputInvoicePremiumAuthCode(TLObject):
    """TL type: inputInvoicePremiumAuthCode"""
    CONSTRUCTOR_ID = 0x3e77f614
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, purpose: 'TypeInputStorePaymentPurpose'):
        self.purpose = purpose

    def to_dict(self):
        return {
            '_': 'InputInvoicePremiumAuthCode',
            'purpose': self.purpose,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.purpose))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_purpose = reader.tgread_object()
        _args['purpose'] = _val_purpose
        return cls(**_args)


class InputInvoicePremiumGiftCode(TLObject):
    """TL type: inputInvoicePremiumGiftCode"""
    CONSTRUCTOR_ID = 0x98986c0d
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, purpose: 'TypeInputStorePaymentPurpose', option: 'TypePremiumGiftCodeOption'):
        self.purpose = purpose
        self.option = option

    def to_dict(self):
        return {
            '_': 'InputInvoicePremiumGiftCode',
            'purpose': self.purpose,
            'option': self.option,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.purpose))
        buf.write(bytes(self.option))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_purpose = reader.tgread_object()
        _args['purpose'] = _val_purpose
        _val_option = reader.tgread_object()
        _args['option'] = _val_option
        return cls(**_args)


class InputInvoicePremiumGiftStars(TLObject):
    """TL type: inputInvoicePremiumGiftStars"""
    CONSTRUCTOR_ID = 0xdabab2ef
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, user_id: 'TypeInputUser', months: int, message: Optional['TypeTextWithEntities'] = None):
        self.user_id = user_id
        self.months = months
        self.message = message

    def to_dict(self):
        return {
            '_': 'InputInvoicePremiumGiftStars',
            'user_id': self.user_id,
            'months': self.months,
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.message is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.user_id))
        buf.write(struct.pack('<i', self.months))
        if self.message is not None:
            buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        _val_months = reader.read_int()
        _args['months'] = _val_months
        if flags & (1 << 0):
            _val_message = reader.tgread_object()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        return cls(**_args)


class InputInvoiceSlug(TLObject):
    """TL type: inputInvoiceSlug"""
    CONSTRUCTOR_ID = 0xc326caef
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, slug: str):
        self.slug = slug

    def to_dict(self):
        return {
            '_': 'InputInvoiceSlug',
            'slug': self.slug,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.slug))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        return cls(**_args)


class InputInvoiceStarGift(TLObject):
    """TL type: inputInvoiceStarGift"""
    CONSTRUCTOR_ID = 0xe8625e92
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, peer: 'TypeInputPeer', gift_id: int, hide_name: Optional[bool] = None, include_upgrade: Optional[bool] = None, message: Optional['TypeTextWithEntities'] = None):
        self.peer = peer
        self.gift_id = gift_id
        self.hide_name = hide_name
        self.include_upgrade = include_upgrade
        self.message = message

    def to_dict(self):
        return {
            '_': 'InputInvoiceStarGift',
            'peer': self.peer,
            'gift_id': self.gift_id,
            'hide_name': self.hide_name,
            'include_upgrade': self.include_upgrade,
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.hide_name:
            flags |= (1 << 0)
        if self.include_upgrade:
            flags |= (1 << 2)
        if self.message is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<q', self.gift_id))
        if self.message is not None:
            buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['hide_name'] = bool(flags & (1 << 0))
        _args['include_upgrade'] = bool(flags & (1 << 2))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_gift_id = reader.read_long()
        _args['gift_id'] = _val_gift_id
        if flags & (1 << 1):
            _val_message = reader.tgread_object()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        return cls(**_args)


class InputInvoiceStarGiftAuctionBid(TLObject):
    """TL type: inputInvoiceStarGiftAuctionBid"""
    CONSTRUCTOR_ID = 0x1ecafa10
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, gift_id: int, bid_amount: int, hide_name: Optional[bool] = None, update_bid: Optional[bool] = None, peer: Optional['TypeInputPeer'] = None, message: Optional['TypeTextWithEntities'] = None):
        self.gift_id = gift_id
        self.bid_amount = bid_amount
        self.hide_name = hide_name
        self.update_bid = update_bid
        self.peer = peer
        self.message = message

    def to_dict(self):
        return {
            '_': 'InputInvoiceStarGiftAuctionBid',
            'gift_id': self.gift_id,
            'bid_amount': self.bid_amount,
            'hide_name': self.hide_name,
            'update_bid': self.update_bid,
            'peer': self.peer,
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.hide_name:
            flags |= (1 << 0)
        if self.update_bid:
            flags |= (1 << 2)
        if self.peer is not None:
            flags |= (1 << 3)
        if self.message is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.gift_id))
        buf.write(struct.pack('<q', self.bid_amount))
        if self.peer is not None:
            buf.write(bytes(self.peer))
        if self.message is not None:
            buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['hide_name'] = bool(flags & (1 << 0))
        _args['update_bid'] = bool(flags & (1 << 2))
        if flags & (1 << 3):
            _val_peer = reader.tgread_object()
            _args['peer'] = _val_peer
        else:
            _args['peer'] = None
        _val_gift_id = reader.read_long()
        _args['gift_id'] = _val_gift_id
        _val_bid_amount = reader.read_long()
        _args['bid_amount'] = _val_bid_amount
        if flags & (1 << 1):
            _val_message = reader.tgread_object()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        return cls(**_args)


class InputInvoiceStarGiftDropOriginalDetails(TLObject):
    """TL type: inputInvoiceStarGiftDropOriginalDetails"""
    CONSTRUCTOR_ID = 0x0923d8d1
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, stargift: 'TypeInputSavedStarGift'):
        self.stargift = stargift

    def to_dict(self):
        return {
            '_': 'InputInvoiceStarGiftDropOriginalDetails',
            'stargift': self.stargift,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.stargift))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_stargift = reader.tgread_object()
        _args['stargift'] = _val_stargift
        return cls(**_args)


class InputInvoiceStarGiftPrepaidUpgrade(TLObject):
    """TL type: inputInvoiceStarGiftPrepaidUpgrade"""
    CONSTRUCTOR_ID = 0x9a0b48b8
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, peer: 'TypeInputPeer', hash: str):
        self.peer = peer
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'InputInvoiceStarGiftPrepaidUpgrade',
            'peer': self.peer,
            'hash': self.hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_hash = reader.tgread_string()
        _args['hash'] = _val_hash
        return cls(**_args)


class InputInvoiceStarGiftResale(TLObject):
    """TL type: inputInvoiceStarGiftResale"""
    CONSTRUCTOR_ID = 0xc39f5324
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, slug: str, to_id: 'TypeInputPeer', ton: Optional[bool] = None):
        self.slug = slug
        self.to_id = to_id
        self.ton = ton

    def to_dict(self):
        return {
            '_': 'InputInvoiceStarGiftResale',
            'slug': self.slug,
            'to_id': self.to_id,
            'ton': self.ton,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.ton:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.slug))
        buf.write(bytes(self.to_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['ton'] = bool(flags & (1 << 0))
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        _val_to_id = reader.tgread_object()
        _args['to_id'] = _val_to_id
        return cls(**_args)


class InputInvoiceStarGiftTransfer(TLObject):
    """TL type: inputInvoiceStarGiftTransfer"""
    CONSTRUCTOR_ID = 0x4a5f5bd9
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, stargift: 'TypeInputSavedStarGift', to_id: 'TypeInputPeer'):
        self.stargift = stargift
        self.to_id = to_id

    def to_dict(self):
        return {
            '_': 'InputInvoiceStarGiftTransfer',
            'stargift': self.stargift,
            'to_id': self.to_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.stargift))
        buf.write(bytes(self.to_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_stargift = reader.tgread_object()
        _args['stargift'] = _val_stargift
        _val_to_id = reader.tgread_object()
        _args['to_id'] = _val_to_id
        return cls(**_args)


class InputInvoiceStarGiftUpgrade(TLObject):
    """TL type: inputInvoiceStarGiftUpgrade"""
    CONSTRUCTOR_ID = 0x4d818d5d
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, stargift: 'TypeInputSavedStarGift', keep_original_details: Optional[bool] = None):
        self.stargift = stargift
        self.keep_original_details = keep_original_details

    def to_dict(self):
        return {
            '_': 'InputInvoiceStarGiftUpgrade',
            'stargift': self.stargift,
            'keep_original_details': self.keep_original_details,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.keep_original_details:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.stargift))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['keep_original_details'] = bool(flags & (1 << 0))
        _val_stargift = reader.tgread_object()
        _args['stargift'] = _val_stargift
        return cls(**_args)


class InputInvoiceStars(TLObject):
    """TL type: inputInvoiceStars"""
    CONSTRUCTOR_ID = 0x65f00ce3
    SUBCLASS_OF_ID = 0x726e9bfe

    def __init__(self, purpose: 'TypeInputStorePaymentPurpose'):
        self.purpose = purpose

    def to_dict(self):
        return {
            '_': 'InputInvoiceStars',
            'purpose': self.purpose,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.purpose))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_purpose = reader.tgread_object()
        _args['purpose'] = _val_purpose
        return cls(**_args)


class InputKeyboardButtonRequestPeer(TLObject):
    """TL type: inputKeyboardButtonRequestPeer"""
    CONSTRUCTOR_ID = 0x02b78156
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, button_id: int, peer_type: 'TypeRequestPeerType', max_quantity: int, name_requested: Optional[bool] = None, username_requested: Optional[bool] = None, photo_requested: Optional[bool] = None, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.button_id = button_id
        self.peer_type = peer_type
        self.max_quantity = max_quantity
        self.name_requested = name_requested
        self.username_requested = username_requested
        self.photo_requested = photo_requested
        self.style = style

    def to_dict(self):
        return {
            '_': 'InputKeyboardButtonRequestPeer',
            'text': self.text,
            'button_id': self.button_id,
            'peer_type': self.peer_type,
            'max_quantity': self.max_quantity,
            'name_requested': self.name_requested,
            'username_requested': self.username_requested,
            'photo_requested': self.photo_requested,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.name_requested:
            flags |= (1 << 0)
        if self.username_requested:
            flags |= (1 << 1)
        if self.photo_requested:
            flags |= (1 << 2)
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(struct.pack('<i', self.button_id))
        buf.write(bytes(self.peer_type))
        buf.write(struct.pack('<i', self.max_quantity))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['name_requested'] = bool(flags & (1 << 0))
        _args['username_requested'] = bool(flags & (1 << 1))
        _args['photo_requested'] = bool(flags & (1 << 2))
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_button_id = reader.read_int()
        _args['button_id'] = _val_button_id
        _val_peer_type = reader.tgread_object()
        _args['peer_type'] = _val_peer_type
        _val_max_quantity = reader.read_int()
        _args['max_quantity'] = _val_max_quantity
        return cls(**_args)


class InputKeyboardButtonRequestPeer(TLObject):
    """TL type: inputKeyboardButtonRequestPeer"""
    CONSTRUCTOR_ID = 0xc9662d05
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, button_id: int, peer_type: 'TypeRequestPeerType', max_quantity: int, name_requested: Optional[bool] = None, username_requested: Optional[bool] = None, photo_requested: Optional[bool] = None):
        self.text = text
        self.button_id = button_id
        self.peer_type = peer_type
        self.max_quantity = max_quantity
        self.name_requested = name_requested
        self.username_requested = username_requested
        self.photo_requested = photo_requested

    def to_dict(self):
        return {
            '_': 'InputKeyboardButtonRequestPeer',
            'text': self.text,
            'button_id': self.button_id,
            'peer_type': self.peer_type,
            'max_quantity': self.max_quantity,
            'name_requested': self.name_requested,
            'username_requested': self.username_requested,
            'photo_requested': self.photo_requested,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.name_requested:
            flags |= (1 << 0)
        if self.username_requested:
            flags |= (1 << 1)
        if self.photo_requested:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(struct.pack('<i', self.button_id))
        buf.write(bytes(self.peer_type))
        buf.write(struct.pack('<i', self.max_quantity))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['name_requested'] = bool(flags & (1 << 0))
        _args['username_requested'] = bool(flags & (1 << 1))
        _args['photo_requested'] = bool(flags & (1 << 2))
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_button_id = reader.read_int()
        _args['button_id'] = _val_button_id
        _val_peer_type = reader.tgread_object()
        _args['peer_type'] = _val_peer_type
        _val_max_quantity = reader.read_int()
        _args['max_quantity'] = _val_max_quantity
        return cls(**_args)


class InputKeyboardButtonUrlAuth(TLObject):
    """TL type: inputKeyboardButtonUrlAuth"""
    CONSTRUCTOR_ID = 0x68013e72
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, url: str, bot: 'TypeInputUser', request_write_access: Optional[bool] = None, style: Optional['TypeKeyboardButtonStyle'] = None, fwd_text: Optional[str] = None):
        self.text = text
        self.url = url
        self.bot = bot
        self.request_write_access = request_write_access
        self.style = style
        self.fwd_text = fwd_text

    def to_dict(self):
        return {
            '_': 'InputKeyboardButtonUrlAuth',
            'text': self.text,
            'url': self.url,
            'bot': self.bot,
            'request_write_access': self.request_write_access,
            'style': self.style,
            'fwd_text': self.fwd_text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.request_write_access:
            flags |= (1 << 0)
        if self.style is not None:
            flags |= (1 << 10)
        if self.fwd_text is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(bytes(self.bot))
        if self.style is not None:
            buf.write(bytes(self.style))
        if self.fwd_text is not None:
            buf.write(TLObject.serialize_bytes(self.fwd_text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['request_write_access'] = bool(flags & (1 << 0))
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        if flags & (1 << 1):
            _val_fwd_text = reader.tgread_string()
            _args['fwd_text'] = _val_fwd_text
        else:
            _args['fwd_text'] = None
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        return cls(**_args)


class InputKeyboardButtonUserProfile(TLObject):
    """TL type: inputKeyboardButtonUserProfile"""
    CONSTRUCTOR_ID = 0x7d5e07c7
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, user_id: 'TypeInputUser', style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.user_id = user_id
        self.style = style

    def to_dict(self):
        return {
            '_': 'InputKeyboardButtonUserProfile',
            'text': self.text,
            'user_id': self.user_id,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(bytes(self.user_id))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class InputMediaAreaChannelPost(TLObject):
    """TL type: inputMediaAreaChannelPost"""
    CONSTRUCTOR_ID = 0x2271f2bf
    SUBCLASS_OF_ID = 0xf36d7bf2

    def __init__(self, coordinates: 'TypeMediaAreaCoordinates', channel: 'TypeInputChannel', msg_id: int):
        self.coordinates = coordinates
        self.channel = channel
        self.msg_id = msg_id

    def to_dict(self):
        return {
            '_': 'InputMediaAreaChannelPost',
            'coordinates': self.coordinates,
            'channel': self.channel,
            'msg_id': self.msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.coordinates))
        buf.write(bytes(self.channel))
        buf.write(struct.pack('<i', self.msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_coordinates = reader.tgread_object()
        _args['coordinates'] = _val_coordinates
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        return cls(**_args)


class InputMediaAreaVenue(TLObject):
    """TL type: inputMediaAreaVenue"""
    CONSTRUCTOR_ID = 0xb282217f
    SUBCLASS_OF_ID = 0xf36d7bf2

    def __init__(self, coordinates: 'TypeMediaAreaCoordinates', query_id: int, result_id: str):
        self.coordinates = coordinates
        self.query_id = query_id
        self.result_id = result_id

    def to_dict(self):
        return {
            '_': 'InputMediaAreaVenue',
            'coordinates': self.coordinates,
            'query_id': self.query_id,
            'result_id': self.result_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.coordinates))
        buf.write(struct.pack('<q', self.query_id))
        buf.write(TLObject.serialize_bytes(self.result_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_coordinates = reader.tgread_object()
        _args['coordinates'] = _val_coordinates
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        _val_result_id = reader.tgread_string()
        _args['result_id'] = _val_result_id
        return cls(**_args)


class InputMediaContact(TLObject):
    """TL type: inputMediaContact"""
    CONSTRUCTOR_ID = 0xf8ab7dfb
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, phone_number: str, first_name: str, last_name: str, vcard: str):
        self.phone_number = phone_number
        self.first_name = first_name
        self.last_name = last_name
        self.vcard = vcard

    def to_dict(self):
        return {
            '_': 'InputMediaContact',
            'phone_number': self.phone_number,
            'first_name': self.first_name,
            'last_name': self.last_name,
            'vcard': self.vcard,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.first_name))
        buf.write(TLObject.serialize_bytes(self.last_name))
        buf.write(TLObject.serialize_bytes(self.vcard))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_first_name = reader.tgread_string()
        _args['first_name'] = _val_first_name
        _val_last_name = reader.tgread_string()
        _args['last_name'] = _val_last_name
        _val_vcard = reader.tgread_string()
        _args['vcard'] = _val_vcard
        return cls(**_args)


class InputMediaDice(TLObject):
    """TL type: inputMediaDice"""
    CONSTRUCTOR_ID = 0xe66fbf7b
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, emoticon: str):
        self.emoticon = emoticon

    def to_dict(self):
        return {
            '_': 'InputMediaDice',
            'emoticon': self.emoticon,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.emoticon))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        return cls(**_args)


class InputMediaDocument(TLObject):
    """TL type: inputMediaDocument"""
    CONSTRUCTOR_ID = 0xa8763ab5
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, id: 'TypeInputDocument', spoiler: Optional[bool] = None, video_cover: Optional['TypeInputPhoto'] = None, video_timestamp: Optional[int] = None, ttl_seconds: Optional[int] = None, query: Optional[str] = None):
        self.id = id
        self.spoiler = spoiler
        self.video_cover = video_cover
        self.video_timestamp = video_timestamp
        self.ttl_seconds = ttl_seconds
        self.query = query

    def to_dict(self):
        return {
            '_': 'InputMediaDocument',
            'id': self.id,
            'spoiler': self.spoiler,
            'video_cover': self.video_cover,
            'video_timestamp': self.video_timestamp,
            'ttl_seconds': self.ttl_seconds,
            'query': self.query,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.spoiler:
            flags |= (1 << 2)
        if self.video_cover is not None:
            flags |= (1 << 3)
        if self.video_timestamp is not None:
            flags |= (1 << 4)
        if self.ttl_seconds is not None:
            flags |= (1 << 0)
        if self.query is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.id))
        if self.video_cover is not None:
            buf.write(bytes(self.video_cover))
        if self.video_timestamp is not None:
            buf.write(struct.pack('<i', self.video_timestamp))
        if self.ttl_seconds is not None:
            buf.write(struct.pack('<i', self.ttl_seconds))
        if self.query is not None:
            buf.write(TLObject.serialize_bytes(self.query))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['spoiler'] = bool(flags & (1 << 2))
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        if flags & (1 << 3):
            _val_video_cover = reader.tgread_object()
            _args['video_cover'] = _val_video_cover
        else:
            _args['video_cover'] = None
        if flags & (1 << 4):
            _val_video_timestamp = reader.read_int()
            _args['video_timestamp'] = _val_video_timestamp
        else:
            _args['video_timestamp'] = None
        if flags & (1 << 0):
            _val_ttl_seconds = reader.read_int()
            _args['ttl_seconds'] = _val_ttl_seconds
        else:
            _args['ttl_seconds'] = None
        if flags & (1 << 1):
            _val_query = reader.tgread_string()
            _args['query'] = _val_query
        else:
            _args['query'] = None
        return cls(**_args)


class InputMediaDocumentExternal(TLObject):
    """TL type: inputMediaDocumentExternal"""
    CONSTRUCTOR_ID = 0x779600f9
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, url: str, spoiler: Optional[bool] = None, ttl_seconds: Optional[int] = None, video_cover: Optional['TypeInputPhoto'] = None, video_timestamp: Optional[int] = None):
        self.url = url
        self.spoiler = spoiler
        self.ttl_seconds = ttl_seconds
        self.video_cover = video_cover
        self.video_timestamp = video_timestamp

    def to_dict(self):
        return {
            '_': 'InputMediaDocumentExternal',
            'url': self.url,
            'spoiler': self.spoiler,
            'ttl_seconds': self.ttl_seconds,
            'video_cover': self.video_cover,
            'video_timestamp': self.video_timestamp,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.spoiler:
            flags |= (1 << 1)
        if self.ttl_seconds is not None:
            flags |= (1 << 0)
        if self.video_cover is not None:
            flags |= (1 << 2)
        if self.video_timestamp is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.url))
        if self.ttl_seconds is not None:
            buf.write(struct.pack('<i', self.ttl_seconds))
        if self.video_cover is not None:
            buf.write(bytes(self.video_cover))
        if self.video_timestamp is not None:
            buf.write(struct.pack('<i', self.video_timestamp))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['spoiler'] = bool(flags & (1 << 1))
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        if flags & (1 << 0):
            _val_ttl_seconds = reader.read_int()
            _args['ttl_seconds'] = _val_ttl_seconds
        else:
            _args['ttl_seconds'] = None
        if flags & (1 << 2):
            _val_video_cover = reader.tgread_object()
            _args['video_cover'] = _val_video_cover
        else:
            _args['video_cover'] = None
        if flags & (1 << 3):
            _val_video_timestamp = reader.read_int()
            _args['video_timestamp'] = _val_video_timestamp
        else:
            _args['video_timestamp'] = None
        return cls(**_args)


class InputMediaEmpty(TLObject):
    """TL type: inputMediaEmpty"""
    CONSTRUCTOR_ID = 0x9664f57f
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMediaEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMediaGame(TLObject):
    """TL type: inputMediaGame"""
    CONSTRUCTOR_ID = 0xd33f43f3
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, id: 'TypeInputGame'):
        self.id = id

    def to_dict(self):
        return {
            '_': 'InputMediaGame',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        return cls(**_args)


class InputMediaGeoLive(TLObject):
    """TL type: inputMediaGeoLive"""
    CONSTRUCTOR_ID = 0x971fa843
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, geo_point: 'TypeInputGeoPoint', stopped: Optional[bool] = None, heading: Optional[int] = None, period: Optional[int] = None, proximity_notification_radius: Optional[int] = None):
        self.geo_point = geo_point
        self.stopped = stopped
        self.heading = heading
        self.period = period
        self.proximity_notification_radius = proximity_notification_radius

    def to_dict(self):
        return {
            '_': 'InputMediaGeoLive',
            'geo_point': self.geo_point,
            'stopped': self.stopped,
            'heading': self.heading,
            'period': self.period,
            'proximity_notification_radius': self.proximity_notification_radius,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.stopped:
            flags |= (1 << 0)
        if self.heading is not None:
            flags |= (1 << 2)
        if self.period is not None:
            flags |= (1 << 1)
        if self.proximity_notification_radius is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.geo_point))
        if self.heading is not None:
            buf.write(struct.pack('<i', self.heading))
        if self.period is not None:
            buf.write(struct.pack('<i', self.period))
        if self.proximity_notification_radius is not None:
            buf.write(struct.pack('<i', self.proximity_notification_radius))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['stopped'] = bool(flags & (1 << 0))
        _val_geo_point = reader.tgread_object()
        _args['geo_point'] = _val_geo_point
        if flags & (1 << 2):
            _val_heading = reader.read_int()
            _args['heading'] = _val_heading
        else:
            _args['heading'] = None
        if flags & (1 << 1):
            _val_period = reader.read_int()
            _args['period'] = _val_period
        else:
            _args['period'] = None
        if flags & (1 << 3):
            _val_proximity_notification_radius = reader.read_int()
            _args['proximity_notification_radius'] = _val_proximity_notification_radius
        else:
            _args['proximity_notification_radius'] = None
        return cls(**_args)


class InputMediaGeoPoint(TLObject):
    """TL type: inputMediaGeoPoint"""
    CONSTRUCTOR_ID = 0xf9c44144
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, geo_point: 'TypeInputGeoPoint'):
        self.geo_point = geo_point

    def to_dict(self):
        return {
            '_': 'InputMediaGeoPoint',
            'geo_point': self.geo_point,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.geo_point))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_geo_point = reader.tgread_object()
        _args['geo_point'] = _val_geo_point
        return cls(**_args)


class InputMediaInvoice(TLObject):
    """TL type: inputMediaInvoice"""
    CONSTRUCTOR_ID = 0x405fef0d
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, title: str, description: str, invoice: 'TypeInvoice', payload: bytes, provider_data: 'TypeDataJSON', photo: Optional['TypeInputWebDocument'] = None, provider: Optional[str] = None, start_param: Optional[str] = None, extended_media: Optional['TypeInputMedia'] = None):
        self.title = title
        self.description = description
        self.invoice = invoice
        self.payload = payload
        self.provider_data = provider_data
        self.photo = photo
        self.provider = provider
        self.start_param = start_param
        self.extended_media = extended_media

    def to_dict(self):
        return {
            '_': 'InputMediaInvoice',
            'title': self.title,
            'description': self.description,
            'invoice': self.invoice,
            'payload': self.payload,
            'provider_data': self.provider_data,
            'photo': self.photo,
            'provider': self.provider,
            'start_param': self.start_param,
            'extended_media': self.extended_media,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.photo is not None:
            flags |= (1 << 0)
        if self.provider is not None:
            flags |= (1 << 3)
        if self.start_param is not None:
            flags |= (1 << 1)
        if self.extended_media is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.description))
        buf.write(bytes(self.invoice))
        buf.write(TLObject.serialize_bytes(self.payload))
        buf.write(bytes(self.provider_data))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        if self.provider is not None:
            buf.write(TLObject.serialize_bytes(self.provider))
        if self.start_param is not None:
            buf.write(TLObject.serialize_bytes(self.start_param))
        if self.extended_media is not None:
            buf.write(bytes(self.extended_media))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_description = reader.tgread_string()
        _args['description'] = _val_description
        if flags & (1 << 0):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        _val_invoice = reader.tgread_object()
        _args['invoice'] = _val_invoice
        _val_payload = reader.tgread_bytes()
        _args['payload'] = _val_payload
        if flags & (1 << 3):
            _val_provider = reader.tgread_string()
            _args['provider'] = _val_provider
        else:
            _args['provider'] = None
        _val_provider_data = reader.tgread_object()
        _args['provider_data'] = _val_provider_data
        if flags & (1 << 1):
            _val_start_param = reader.tgread_string()
            _args['start_param'] = _val_start_param
        else:
            _args['start_param'] = None
        if flags & (1 << 2):
            _val_extended_media = reader.tgread_object()
            _args['extended_media'] = _val_extended_media
        else:
            _args['extended_media'] = None
        return cls(**_args)


class InputMediaPaidMedia(TLObject):
    """TL type: inputMediaPaidMedia"""
    CONSTRUCTOR_ID = 0xc4103386
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, stars_amount: int, extended_media: List['TypeInputMedia'], payload: Optional[str] = None):
        self.stars_amount = stars_amount
        self.extended_media = extended_media
        self.payload = payload

    def to_dict(self):
        return {
            '_': 'InputMediaPaidMedia',
            'stars_amount': self.stars_amount,
            'extended_media': self.extended_media,
            'payload': self.payload,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.payload is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.stars_amount))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.extended_media)))
        for item in self.extended_media:
            buf.write(bytes(self.item))
        if self.payload is not None:
            buf.write(TLObject.serialize_bytes(self.payload))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_stars_amount = reader.read_long()
        _args['stars_amount'] = _val_stars_amount
        reader.read_int(signed=False)  # skip vector id
        _count_extended_media = reader.read_int()
        _list_extended_media = []
        for _ in range(_count_extended_media):
            _item_extended_media = reader.tgread_object()
            _list_extended_media.append(_item_extended_media)
        _args['extended_media'] = _list_extended_media
        if flags & (1 << 0):
            _val_payload = reader.tgread_string()
            _args['payload'] = _val_payload
        else:
            _args['payload'] = None
        return cls(**_args)


class InputMediaPhoto(TLObject):
    """TL type: inputMediaPhoto"""
    CONSTRUCTOR_ID = 0xb3ba0635
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, id: 'TypeInputPhoto', spoiler: Optional[bool] = None, ttl_seconds: Optional[int] = None):
        self.id = id
        self.spoiler = spoiler
        self.ttl_seconds = ttl_seconds

    def to_dict(self):
        return {
            '_': 'InputMediaPhoto',
            'id': self.id,
            'spoiler': self.spoiler,
            'ttl_seconds': self.ttl_seconds,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.spoiler:
            flags |= (1 << 1)
        if self.ttl_seconds is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.id))
        if self.ttl_seconds is not None:
            buf.write(struct.pack('<i', self.ttl_seconds))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['spoiler'] = bool(flags & (1 << 1))
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        if flags & (1 << 0):
            _val_ttl_seconds = reader.read_int()
            _args['ttl_seconds'] = _val_ttl_seconds
        else:
            _args['ttl_seconds'] = None
        return cls(**_args)


class InputMediaPhotoExternal(TLObject):
    """TL type: inputMediaPhotoExternal"""
    CONSTRUCTOR_ID = 0xe5bbfe1a
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, url: str, spoiler: Optional[bool] = None, ttl_seconds: Optional[int] = None):
        self.url = url
        self.spoiler = spoiler
        self.ttl_seconds = ttl_seconds

    def to_dict(self):
        return {
            '_': 'InputMediaPhotoExternal',
            'url': self.url,
            'spoiler': self.spoiler,
            'ttl_seconds': self.ttl_seconds,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.spoiler:
            flags |= (1 << 1)
        if self.ttl_seconds is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.url))
        if self.ttl_seconds is not None:
            buf.write(struct.pack('<i', self.ttl_seconds))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['spoiler'] = bool(flags & (1 << 1))
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        if flags & (1 << 0):
            _val_ttl_seconds = reader.read_int()
            _args['ttl_seconds'] = _val_ttl_seconds
        else:
            _args['ttl_seconds'] = None
        return cls(**_args)


class InputMediaPoll(TLObject):
    """TL type: inputMediaPoll"""
    CONSTRUCTOR_ID = 0x0f94e5f1
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, poll: 'TypePoll', correct_answers: Optional[List[bytes]] = None, solution: Optional[str] = None, solution_entities: Optional[List['TypeMessageEntity']] = None):
        self.poll = poll
        self.correct_answers = correct_answers
        self.solution = solution
        self.solution_entities = solution_entities

    def to_dict(self):
        return {
            '_': 'InputMediaPoll',
            'poll': self.poll,
            'correct_answers': self.correct_answers,
            'solution': self.solution,
            'solution_entities': self.solution_entities,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.correct_answers is not None:
            flags |= (1 << 0)
        if self.solution_entities is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.poll))
        if self.correct_answers is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.correct_answers)))
            for item in self.correct_answers:
                buf.write(TLObject.serialize_bytes(self.item))
        if self.solution is not None:
            buf.write(TLObject.serialize_bytes(self.solution))
        if self.solution_entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.solution_entities)))
            for item in self.solution_entities:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_poll = reader.tgread_object()
        _args['poll'] = _val_poll
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_correct_answers = reader.read_int()
            _list_correct_answers = []
            for _ in range(_count_correct_answers):
                _item_correct_answers = reader.tgread_bytes()
                _list_correct_answers.append(_item_correct_answers)
            _args['correct_answers'] = _list_correct_answers
        else:
            _args['correct_answers'] = None
        if flags & (1 << 1):
            _val_solution = reader.tgread_string()
            _args['solution'] = _val_solution
        else:
            _args['solution'] = None
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_solution_entities = reader.read_int()
            _list_solution_entities = []
            for _ in range(_count_solution_entities):
                _item_solution_entities = reader.tgread_object()
                _list_solution_entities.append(_item_solution_entities)
            _args['solution_entities'] = _list_solution_entities
        else:
            _args['solution_entities'] = None
        return cls(**_args)


class InputMediaStakeDice(TLObject):
    """TL type: inputMediaStakeDice"""
    CONSTRUCTOR_ID = 0xf3a9244a
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, game_hash: str, ton_amount: int, client_seed: bytes):
        self.game_hash = game_hash
        self.ton_amount = ton_amount
        self.client_seed = client_seed

    def to_dict(self):
        return {
            '_': 'InputMediaStakeDice',
            'game_hash': self.game_hash,
            'ton_amount': self.ton_amount,
            'client_seed': self.client_seed,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.game_hash))
        buf.write(struct.pack('<q', self.ton_amount))
        buf.write(TLObject.serialize_bytes(self.client_seed))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_game_hash = reader.tgread_string()
        _args['game_hash'] = _val_game_hash
        _val_ton_amount = reader.read_long()
        _args['ton_amount'] = _val_ton_amount
        _val_client_seed = reader.tgread_bytes()
        _args['client_seed'] = _val_client_seed
        return cls(**_args)


class InputMediaStory(TLObject):
    """TL type: inputMediaStory"""
    CONSTRUCTOR_ID = 0x89fdd778
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, peer: 'TypeInputPeer', id: int):
        self.peer = peer
        self.id = id

    def to_dict(self):
        return {
            '_': 'InputMediaStory',
            'peer': self.peer,
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_id = reader.read_int()
        _args['id'] = _val_id
        return cls(**_args)


class InputMediaTodo(TLObject):
    """TL type: inputMediaTodo"""
    CONSTRUCTOR_ID = 0x9fc55fde
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, todo: 'TypeTodoList'):
        self.todo = todo

    def to_dict(self):
        return {
            '_': 'InputMediaTodo',
            'todo': self.todo,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.todo))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_todo = reader.tgread_object()
        _args['todo'] = _val_todo
        return cls(**_args)


class InputMediaUploadedDocument(TLObject):
    """TL type: inputMediaUploadedDocument"""
    CONSTRUCTOR_ID = 0x037c9330
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, file: 'TypeInputFile', mime_type: str, attributes: List['TypeDocumentAttribute'], nosound_video: Optional[bool] = None, force_file: Optional[bool] = None, spoiler: Optional[bool] = None, thumb: Optional['TypeInputFile'] = None, stickers: Optional[List['TypeInputDocument']] = None, video_cover: Optional['TypeInputPhoto'] = None, video_timestamp: Optional[int] = None, ttl_seconds: Optional[int] = None):
        self.file = file
        self.mime_type = mime_type
        self.attributes = attributes
        self.nosound_video = nosound_video
        self.force_file = force_file
        self.spoiler = spoiler
        self.thumb = thumb
        self.stickers = stickers
        self.video_cover = video_cover
        self.video_timestamp = video_timestamp
        self.ttl_seconds = ttl_seconds

    def to_dict(self):
        return {
            '_': 'InputMediaUploadedDocument',
            'file': self.file,
            'mime_type': self.mime_type,
            'attributes': self.attributes,
            'nosound_video': self.nosound_video,
            'force_file': self.force_file,
            'spoiler': self.spoiler,
            'thumb': self.thumb,
            'stickers': self.stickers,
            'video_cover': self.video_cover,
            'video_timestamp': self.video_timestamp,
            'ttl_seconds': self.ttl_seconds,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.nosound_video:
            flags |= (1 << 3)
        if self.force_file:
            flags |= (1 << 4)
        if self.spoiler:
            flags |= (1 << 5)
        if self.thumb is not None:
            flags |= (1 << 2)
        if self.stickers is not None:
            flags |= (1 << 0)
        if self.video_cover is not None:
            flags |= (1 << 6)
        if self.video_timestamp is not None:
            flags |= (1 << 7)
        if self.ttl_seconds is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.file))
        buf.write(TLObject.serialize_bytes(self.mime_type))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.attributes)))
        for item in self.attributes:
            buf.write(bytes(self.item))
        if self.thumb is not None:
            buf.write(bytes(self.thumb))
        if self.stickers is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.stickers)))
            for item in self.stickers:
                buf.write(bytes(self.item))
        if self.video_cover is not None:
            buf.write(bytes(self.video_cover))
        if self.video_timestamp is not None:
            buf.write(struct.pack('<i', self.video_timestamp))
        if self.ttl_seconds is not None:
            buf.write(struct.pack('<i', self.ttl_seconds))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['nosound_video'] = bool(flags & (1 << 3))
        _args['force_file'] = bool(flags & (1 << 4))
        _args['spoiler'] = bool(flags & (1 << 5))
        _val_file = reader.tgread_object()
        _args['file'] = _val_file
        if flags & (1 << 2):
            _val_thumb = reader.tgread_object()
            _args['thumb'] = _val_thumb
        else:
            _args['thumb'] = None
        _val_mime_type = reader.tgread_string()
        _args['mime_type'] = _val_mime_type
        reader.read_int(signed=False)  # skip vector id
        _count_attributes = reader.read_int()
        _list_attributes = []
        for _ in range(_count_attributes):
            _item_attributes = reader.tgread_object()
            _list_attributes.append(_item_attributes)
        _args['attributes'] = _list_attributes
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_stickers = reader.read_int()
            _list_stickers = []
            for _ in range(_count_stickers):
                _item_stickers = reader.tgread_object()
                _list_stickers.append(_item_stickers)
            _args['stickers'] = _list_stickers
        else:
            _args['stickers'] = None
        if flags & (1 << 6):
            _val_video_cover = reader.tgread_object()
            _args['video_cover'] = _val_video_cover
        else:
            _args['video_cover'] = None
        if flags & (1 << 7):
            _val_video_timestamp = reader.read_int()
            _args['video_timestamp'] = _val_video_timestamp
        else:
            _args['video_timestamp'] = None
        if flags & (1 << 1):
            _val_ttl_seconds = reader.read_int()
            _args['ttl_seconds'] = _val_ttl_seconds
        else:
            _args['ttl_seconds'] = None
        return cls(**_args)


class InputMediaUploadedPhoto(TLObject):
    """TL type: inputMediaUploadedPhoto"""
    CONSTRUCTOR_ID = 0x1e287d04
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, file: 'TypeInputFile', spoiler: Optional[bool] = None, stickers: Optional[List['TypeInputDocument']] = None, ttl_seconds: Optional[int] = None):
        self.file = file
        self.spoiler = spoiler
        self.stickers = stickers
        self.ttl_seconds = ttl_seconds

    def to_dict(self):
        return {
            '_': 'InputMediaUploadedPhoto',
            'file': self.file,
            'spoiler': self.spoiler,
            'stickers': self.stickers,
            'ttl_seconds': self.ttl_seconds,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.spoiler:
            flags |= (1 << 2)
        if self.stickers is not None:
            flags |= (1 << 0)
        if self.ttl_seconds is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.file))
        if self.stickers is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.stickers)))
            for item in self.stickers:
                buf.write(bytes(self.item))
        if self.ttl_seconds is not None:
            buf.write(struct.pack('<i', self.ttl_seconds))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['spoiler'] = bool(flags & (1 << 2))
        _val_file = reader.tgread_object()
        _args['file'] = _val_file
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_stickers = reader.read_int()
            _list_stickers = []
            for _ in range(_count_stickers):
                _item_stickers = reader.tgread_object()
                _list_stickers.append(_item_stickers)
            _args['stickers'] = _list_stickers
        else:
            _args['stickers'] = None
        if flags & (1 << 1):
            _val_ttl_seconds = reader.read_int()
            _args['ttl_seconds'] = _val_ttl_seconds
        else:
            _args['ttl_seconds'] = None
        return cls(**_args)


class InputMediaVenue(TLObject):
    """TL type: inputMediaVenue"""
    CONSTRUCTOR_ID = 0xc13d1c11
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, geo_point: 'TypeInputGeoPoint', title: str, address: str, provider: str, venue_id: str, venue_type: str):
        self.geo_point = geo_point
        self.title = title
        self.address = address
        self.provider = provider
        self.venue_id = venue_id
        self.venue_type = venue_type

    def to_dict(self):
        return {
            '_': 'InputMediaVenue',
            'geo_point': self.geo_point,
            'title': self.title,
            'address': self.address,
            'provider': self.provider,
            'venue_id': self.venue_id,
            'venue_type': self.venue_type,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.geo_point))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.address))
        buf.write(TLObject.serialize_bytes(self.provider))
        buf.write(TLObject.serialize_bytes(self.venue_id))
        buf.write(TLObject.serialize_bytes(self.venue_type))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_geo_point = reader.tgread_object()
        _args['geo_point'] = _val_geo_point
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_address = reader.tgread_string()
        _args['address'] = _val_address
        _val_provider = reader.tgread_string()
        _args['provider'] = _val_provider
        _val_venue_id = reader.tgread_string()
        _args['venue_id'] = _val_venue_id
        _val_venue_type = reader.tgread_string()
        _args['venue_type'] = _val_venue_type
        return cls(**_args)


class InputMediaWebPage(TLObject):
    """TL type: inputMediaWebPage"""
    CONSTRUCTOR_ID = 0xc21b8849
    SUBCLASS_OF_ID = 0xfaf846f4

    def __init__(self, url: str, force_large_media: Optional[bool] = None, force_small_media: Optional[bool] = None, optional: Optional[bool] = None):
        self.url = url
        self.force_large_media = force_large_media
        self.force_small_media = force_small_media
        self.optional = optional

    def to_dict(self):
        return {
            '_': 'InputMediaWebPage',
            'url': self.url,
            'force_large_media': self.force_large_media,
            'force_small_media': self.force_small_media,
            'optional': self.optional,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.force_large_media:
            flags |= (1 << 0)
        if self.force_small_media:
            flags |= (1 << 1)
        if self.optional:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['force_large_media'] = bool(flags & (1 << 0))
        _args['force_small_media'] = bool(flags & (1 << 1))
        _args['optional'] = bool(flags & (1 << 2))
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class InputMessageCallbackQuery(TLObject):
    """TL type: inputMessageCallbackQuery"""
    CONSTRUCTOR_ID = 0xacfa1a7e
    SUBCLASS_OF_ID = 0x54b6bcc5

    def __init__(self, id: int, query_id: int):
        self.id = id
        self.query_id = query_id

    def to_dict(self):
        return {
            '_': 'InputMessageCallbackQuery',
            'id': self.id,
            'query_id': self.query_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<q', self.query_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        return cls(**_args)


class InputMessageEntityMentionName(TLObject):
    """TL type: inputMessageEntityMentionName"""
    CONSTRUCTOR_ID = 0x208e68c9
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int, user_id: 'TypeInputUser'):
        self.offset = offset
        self.length = length
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'InputMessageEntityMentionName',
            'offset': self.offset,
            'length': self.length,
            'user_id': self.user_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        buf.write(bytes(self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class InputMessageId(TLObject):
    """TL type: inputMessageID"""
    CONSTRUCTOR_ID = 0xa676a322
    SUBCLASS_OF_ID = 0x54b6bcc5

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'InputMessageId',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        return cls(**_args)


class InputMessagePinned(TLObject):
    """TL type: inputMessagePinned"""
    CONSTRUCTOR_ID = 0x86872538
    SUBCLASS_OF_ID = 0x54b6bcc5

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagePinned',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessageReplyTo(TLObject):
    """TL type: inputMessageReplyTo"""
    CONSTRUCTOR_ID = 0xbad88395
    SUBCLASS_OF_ID = 0x54b6bcc5

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'InputMessageReplyTo',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        return cls(**_args)


class InputMessagesFilterChatPhotos(TLObject):
    """TL type: inputMessagesFilterChatPhotos"""
    CONSTRUCTOR_ID = 0x3a20ecb8
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterChatPhotos',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterContacts(TLObject):
    """TL type: inputMessagesFilterContacts"""
    CONSTRUCTOR_ID = 0xe062db83
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterContacts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterDocument(TLObject):
    """TL type: inputMessagesFilterDocument"""
    CONSTRUCTOR_ID = 0x9eddf188
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterDocument',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterEmpty(TLObject):
    """TL type: inputMessagesFilterEmpty"""
    CONSTRUCTOR_ID = 0x57e2f66c
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterGeo(TLObject):
    """TL type: inputMessagesFilterGeo"""
    CONSTRUCTOR_ID = 0xe7026d0d
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterGeo',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterGif(TLObject):
    """TL type: inputMessagesFilterGif"""
    CONSTRUCTOR_ID = 0xffc86587
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterGif',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterMusic(TLObject):
    """TL type: inputMessagesFilterMusic"""
    CONSTRUCTOR_ID = 0x3751b49e
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterMusic',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterMyMentions(TLObject):
    """TL type: inputMessagesFilterMyMentions"""
    CONSTRUCTOR_ID = 0xc1f8e69a
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterMyMentions',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterPhoneCalls(TLObject):
    """TL type: inputMessagesFilterPhoneCalls"""
    CONSTRUCTOR_ID = 0x80c99768
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self, missed: Optional[bool] = None):
        self.missed = missed

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterPhoneCalls',
            'missed': self.missed,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.missed:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['missed'] = bool(flags & (1 << 0))
        return cls(**_args)


class InputMessagesFilterPhotoVideo(TLObject):
    """TL type: inputMessagesFilterPhotoVideo"""
    CONSTRUCTOR_ID = 0x56e9f0e4
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterPhotoVideo',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterPhotoVideoDocuments(TLObject):
    """TL type: inputMessagesFilterPhotoVideoDocuments"""
    CONSTRUCTOR_ID = 0xd95e73bb
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterPhotoVideoDocuments',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterPhotos(TLObject):
    """TL type: inputMessagesFilterPhotos"""
    CONSTRUCTOR_ID = 0x9609a51c
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterPhotos',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterPinned(TLObject):
    """TL type: inputMessagesFilterPinned"""
    CONSTRUCTOR_ID = 0x1bb00451
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterPinned',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterRoundVideo(TLObject):
    """TL type: inputMessagesFilterRoundVideo"""
    CONSTRUCTOR_ID = 0xb549da53
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterRoundVideo',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterRoundVoice(TLObject):
    """TL type: inputMessagesFilterRoundVoice"""
    CONSTRUCTOR_ID = 0x7a7c17a4
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterRoundVoice',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterUrl(TLObject):
    """TL type: inputMessagesFilterUrl"""
    CONSTRUCTOR_ID = 0x7ef0dd87
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterUrl',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterVideo(TLObject):
    """TL type: inputMessagesFilterVideo"""
    CONSTRUCTOR_ID = 0x9fc00e65
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterVideo',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputMessagesFilterVoice(TLObject):
    """TL type: inputMessagesFilterVoice"""
    CONSTRUCTOR_ID = 0x50f5c392
    SUBCLASS_OF_ID = 0x8a36ec14

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputMessagesFilterVoice',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputNotifyBroadcasts(TLObject):
    """TL type: inputNotifyBroadcasts"""
    CONSTRUCTOR_ID = 0xb1db7c7e
    SUBCLASS_OF_ID = 0x58981615

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputNotifyBroadcasts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputNotifyChats(TLObject):
    """TL type: inputNotifyChats"""
    CONSTRUCTOR_ID = 0x4a95e84e
    SUBCLASS_OF_ID = 0x58981615

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputNotifyChats',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputNotifyForumTopic(TLObject):
    """TL type: inputNotifyForumTopic"""
    CONSTRUCTOR_ID = 0x5c467992
    SUBCLASS_OF_ID = 0x58981615

    def __init__(self, peer: 'TypeInputPeer', top_msg_id: int):
        self.peer = peer
        self.top_msg_id = top_msg_id

    def to_dict(self):
        return {
            '_': 'InputNotifyForumTopic',
            'peer': self.peer,
            'top_msg_id': self.top_msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.top_msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_top_msg_id = reader.read_int()
        _args['top_msg_id'] = _val_top_msg_id
        return cls(**_args)


class InputNotifyPeer(TLObject):
    """TL type: inputNotifyPeer"""
    CONSTRUCTOR_ID = 0xb8bc5b0c
    SUBCLASS_OF_ID = 0x58981615

    def __init__(self, peer: 'TypeInputPeer'):
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'InputNotifyPeer',
            'peer': self.peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class InputNotifyUsers(TLObject):
    """TL type: inputNotifyUsers"""
    CONSTRUCTOR_ID = 0x193b4417
    SUBCLASS_OF_ID = 0x58981615

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputNotifyUsers',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPasskeyCredentialFirebasePnv(TLObject):
    """TL type: inputPasskeyCredentialFirebasePNV"""
    CONSTRUCTOR_ID = 0x5b1ccb28
    SUBCLASS_OF_ID = 0x1eb1222e

    def __init__(self, pnv_token: str):
        self.pnv_token = pnv_token

    def to_dict(self):
        return {
            '_': 'InputPasskeyCredentialFirebasePnv',
            'pnv_token': self.pnv_token,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.pnv_token))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_pnv_token = reader.tgread_string()
        _args['pnv_token'] = _val_pnv_token
        return cls(**_args)


class InputPasskeyCredentialPublicKey(TLObject):
    """TL type: inputPasskeyCredentialPublicKey"""
    CONSTRUCTOR_ID = 0x3c27b78f
    SUBCLASS_OF_ID = 0x1eb1222e

    def __init__(self, id: str, raw_id: str, response: 'TypeInputPasskeyResponse'):
        self.id = id
        self.raw_id = raw_id
        self.response = response

    def to_dict(self):
        return {
            '_': 'InputPasskeyCredentialPublicKey',
            'id': self.id,
            'raw_id': self.raw_id,
            'response': self.response,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.raw_id))
        buf.write(bytes(self.response))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_raw_id = reader.tgread_string()
        _args['raw_id'] = _val_raw_id
        _val_response = reader.tgread_object()
        _args['response'] = _val_response
        return cls(**_args)


class InputPasskeyResponseLogin(TLObject):
    """TL type: inputPasskeyResponseLogin"""
    CONSTRUCTOR_ID = 0xc31fc14a
    SUBCLASS_OF_ID = 0x1ef0c7cd

    def __init__(self, client_data: 'TypeDataJSON', authenticator_data: bytes, signature: bytes, user_handle: str):
        self.client_data = client_data
        self.authenticator_data = authenticator_data
        self.signature = signature
        self.user_handle = user_handle

    def to_dict(self):
        return {
            '_': 'InputPasskeyResponseLogin',
            'client_data': self.client_data,
            'authenticator_data': self.authenticator_data,
            'signature': self.signature,
            'user_handle': self.user_handle,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.client_data))
        buf.write(TLObject.serialize_bytes(self.authenticator_data))
        buf.write(TLObject.serialize_bytes(self.signature))
        buf.write(TLObject.serialize_bytes(self.user_handle))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_client_data = reader.tgread_object()
        _args['client_data'] = _val_client_data
        _val_authenticator_data = reader.tgread_bytes()
        _args['authenticator_data'] = _val_authenticator_data
        _val_signature = reader.tgread_bytes()
        _args['signature'] = _val_signature
        _val_user_handle = reader.tgread_string()
        _args['user_handle'] = _val_user_handle
        return cls(**_args)


class InputPasskeyResponseRegister(TLObject):
    """TL type: inputPasskeyResponseRegister"""
    CONSTRUCTOR_ID = 0x3e63935c
    SUBCLASS_OF_ID = 0x1ef0c7cd

    def __init__(self, client_data: 'TypeDataJSON', attestation_data: bytes):
        self.client_data = client_data
        self.attestation_data = attestation_data

    def to_dict(self):
        return {
            '_': 'InputPasskeyResponseRegister',
            'client_data': self.client_data,
            'attestation_data': self.attestation_data,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.client_data))
        buf.write(TLObject.serialize_bytes(self.attestation_data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_client_data = reader.tgread_object()
        _args['client_data'] = _val_client_data
        _val_attestation_data = reader.tgread_bytes()
        _args['attestation_data'] = _val_attestation_data
        return cls(**_args)


class InputPaymentCredentials(TLObject):
    """TL type: inputPaymentCredentials"""
    CONSTRUCTOR_ID = 0x3417d728
    SUBCLASS_OF_ID = 0x2899a53d

    def __init__(self, data: 'TypeDataJSON', save: Optional[bool] = None):
        self.data = data
        self.save = save

    def to_dict(self):
        return {
            '_': 'InputPaymentCredentials',
            'data': self.data,
            'save': self.save,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.save:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['save'] = bool(flags & (1 << 0))
        _val_data = reader.tgread_object()
        _args['data'] = _val_data
        return cls(**_args)


class InputPaymentCredentialsApplePay(TLObject):
    """TL type: inputPaymentCredentialsApplePay"""
    CONSTRUCTOR_ID = 0x0aa1c39f
    SUBCLASS_OF_ID = 0x2899a53d

    def __init__(self, payment_data: 'TypeDataJSON'):
        self.payment_data = payment_data

    def to_dict(self):
        return {
            '_': 'InputPaymentCredentialsApplePay',
            'payment_data': self.payment_data,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.payment_data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_payment_data = reader.tgread_object()
        _args['payment_data'] = _val_payment_data
        return cls(**_args)


class InputPaymentCredentialsGooglePay(TLObject):
    """TL type: inputPaymentCredentialsGooglePay"""
    CONSTRUCTOR_ID = 0x8ac32801
    SUBCLASS_OF_ID = 0x2899a53d

    def __init__(self, payment_token: 'TypeDataJSON'):
        self.payment_token = payment_token

    def to_dict(self):
        return {
            '_': 'InputPaymentCredentialsGooglePay',
            'payment_token': self.payment_token,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.payment_token))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_payment_token = reader.tgread_object()
        _args['payment_token'] = _val_payment_token
        return cls(**_args)


class InputPaymentCredentialsSaved(TLObject):
    """TL type: inputPaymentCredentialsSaved"""
    CONSTRUCTOR_ID = 0xc10eb2cf
    SUBCLASS_OF_ID = 0x2899a53d

    def __init__(self, id: str, tmp_password: bytes):
        self.id = id
        self.tmp_password = tmp_password

    def to_dict(self):
        return {
            '_': 'InputPaymentCredentialsSaved',
            'id': self.id,
            'tmp_password': self.tmp_password,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.tmp_password))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_tmp_password = reader.tgread_bytes()
        _args['tmp_password'] = _val_tmp_password
        return cls(**_args)


class InputPeerChannel(TLObject):
    """TL type: inputPeerChannel"""
    CONSTRUCTOR_ID = 0x27bcbbfc
    SUBCLASS_OF_ID = 0xc91c90b6

    def __init__(self, channel_id: int, access_hash: int):
        self.channel_id = channel_id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputPeerChannel',
            'channel_id': self.channel_id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputPeerChannelFromMessage(TLObject):
    """TL type: inputPeerChannelFromMessage"""
    CONSTRUCTOR_ID = 0xbd2a0840
    SUBCLASS_OF_ID = 0xc91c90b6

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, channel_id: int):
        self.peer = peer
        self.msg_id = msg_id
        self.channel_id = channel_id

    def to_dict(self):
        return {
            '_': 'InputPeerChannelFromMessage',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'channel_id': self.channel_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<q', self.channel_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        return cls(**_args)


class InputPeerChat(TLObject):
    """TL type: inputPeerChat"""
    CONSTRUCTOR_ID = 0x35a95cb9
    SUBCLASS_OF_ID = 0xc91c90b6

    def __init__(self, chat_id: int):
        self.chat_id = chat_id

    def to_dict(self):
        return {
            '_': 'InputPeerChat',
            'chat_id': self.chat_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.chat_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        return cls(**_args)


class InputPeerColorCollectible(TLObject):
    """TL type: inputPeerColorCollectible"""
    CONSTRUCTOR_ID = 0xb8ea86a9
    SUBCLASS_OF_ID = 0xf281a47f

    def __init__(self, collectible_id: int):
        self.collectible_id = collectible_id

    def to_dict(self):
        return {
            '_': 'InputPeerColorCollectible',
            'collectible_id': self.collectible_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.collectible_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_collectible_id = reader.read_long()
        _args['collectible_id'] = _val_collectible_id
        return cls(**_args)


class InputPeerEmpty(TLObject):
    """TL type: inputPeerEmpty"""
    CONSTRUCTOR_ID = 0x7f3b18ea
    SUBCLASS_OF_ID = 0xc91c90b6

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPeerEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPeerNotifySettings(TLObject):
    """TL type: inputPeerNotifySettings"""
    CONSTRUCTOR_ID = 0xcacb6ae2
    SUBCLASS_OF_ID = 0x90db0b0d

    def __init__(self, show_previews: Optional[bool] = None, silent: Optional[bool] = None, mute_until: Optional[datetime] = None, sound: Optional['TypeNotificationSound'] = None, stories_muted: Optional[bool] = None, stories_hide_sender: Optional[bool] = None, stories_sound: Optional['TypeNotificationSound'] = None):
        self.show_previews = show_previews
        self.silent = silent
        self.mute_until = mute_until
        self.sound = sound
        self.stories_muted = stories_muted
        self.stories_hide_sender = stories_hide_sender
        self.stories_sound = stories_sound

    def to_dict(self):
        return {
            '_': 'InputPeerNotifySettings',
            'show_previews': self.show_previews,
            'silent': self.silent,
            'mute_until': self.mute_until,
            'sound': self.sound,
            'stories_muted': self.stories_muted,
            'stories_hide_sender': self.stories_hide_sender,
            'stories_sound': self.stories_sound,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.show_previews is not None:
            flags |= (1 << 0)
        if self.silent is not None:
            flags |= (1 << 1)
        if self.mute_until is not None:
            flags |= (1 << 2)
        if self.sound is not None:
            flags |= (1 << 3)
        if self.stories_muted is not None:
            flags |= (1 << 6)
        if self.stories_hide_sender is not None:
            flags |= (1 << 7)
        if self.stories_sound is not None:
            flags |= (1 << 8)
        buf.write(struct.pack('<I', flags))
        if self.show_previews is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.show_previews else 0xbc799737))
        if self.silent is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.silent else 0xbc799737))
        if self.mute_until is not None:
            buf.write(struct.pack('<i', self.mute_until))
        if self.sound is not None:
            buf.write(bytes(self.sound))
        if self.stories_muted is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.stories_muted else 0xbc799737))
        if self.stories_hide_sender is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.stories_hide_sender else 0xbc799737))
        if self.stories_sound is not None:
            buf.write(bytes(self.stories_sound))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_show_previews = reader.tgread_bool()
            _args['show_previews'] = _val_show_previews
        else:
            _args['show_previews'] = None
        if flags & (1 << 1):
            _val_silent = reader.tgread_bool()
            _args['silent'] = _val_silent
        else:
            _args['silent'] = None
        if flags & (1 << 2):
            _val_mute_until = reader.read_int()
            _args['mute_until'] = _val_mute_until
        else:
            _args['mute_until'] = None
        if flags & (1 << 3):
            _val_sound = reader.tgread_object()
            _args['sound'] = _val_sound
        else:
            _args['sound'] = None
        if flags & (1 << 6):
            _val_stories_muted = reader.tgread_bool()
            _args['stories_muted'] = _val_stories_muted
        else:
            _args['stories_muted'] = None
        if flags & (1 << 7):
            _val_stories_hide_sender = reader.tgread_bool()
            _args['stories_hide_sender'] = _val_stories_hide_sender
        else:
            _args['stories_hide_sender'] = None
        if flags & (1 << 8):
            _val_stories_sound = reader.tgread_object()
            _args['stories_sound'] = _val_stories_sound
        else:
            _args['stories_sound'] = None
        return cls(**_args)


class InputPeerPhotoFileLocation(TLObject):
    """TL type: inputPeerPhotoFileLocation"""
    CONSTRUCTOR_ID = 0x37257e99
    SUBCLASS_OF_ID = 0x1523d462

    def __init__(self, peer: 'TypeInputPeer', photo_id: int, big: Optional[bool] = None):
        self.peer = peer
        self.photo_id = photo_id
        self.big = big

    def to_dict(self):
        return {
            '_': 'InputPeerPhotoFileLocation',
            'peer': self.peer,
            'photo_id': self.photo_id,
            'big': self.big,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.big:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<q', self.photo_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['big'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_photo_id = reader.read_long()
        _args['photo_id'] = _val_photo_id
        return cls(**_args)


class InputPeerSelf(TLObject):
    """TL type: inputPeerSelf"""
    CONSTRUCTOR_ID = 0x7da07ec9
    SUBCLASS_OF_ID = 0xc91c90b6

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPeerSelf',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPeerUser(TLObject):
    """TL type: inputPeerUser"""
    CONSTRUCTOR_ID = 0xdde8a54c
    SUBCLASS_OF_ID = 0xc91c90b6

    def __init__(self, user_id: int, access_hash: int):
        self.user_id = user_id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputPeerUser',
            'user_id': self.user_id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputPeerUserFromMessage(TLObject):
    """TL type: inputPeerUserFromMessage"""
    CONSTRUCTOR_ID = 0xa87b0a1c
    SUBCLASS_OF_ID = 0xc91c90b6

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, user_id: int):
        self.peer = peer
        self.msg_id = msg_id
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'InputPeerUserFromMessage',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'user_id': self.user_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<q', self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class InputPhoneCall(TLObject):
    """TL type: inputPhoneCall"""
    CONSTRUCTOR_ID = 0x1e36fded
    SUBCLASS_OF_ID = 0xbcaaf240

    def __init__(self, id: int, access_hash: int):
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputPhoneCall',
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputPhoneContact(TLObject):
    """TL type: inputPhoneContact"""
    CONSTRUCTOR_ID = 0x6a1dc4be
    SUBCLASS_OF_ID = 0xae696a82

    def __init__(self, client_id: int, phone: str, first_name: str, last_name: str, note: Optional['TypeTextWithEntities'] = None):
        self.client_id = client_id
        self.phone = phone
        self.first_name = first_name
        self.last_name = last_name
        self.note = note

    def to_dict(self):
        return {
            '_': 'InputPhoneContact',
            'client_id': self.client_id,
            'phone': self.phone,
            'first_name': self.first_name,
            'last_name': self.last_name,
            'note': self.note,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.note is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.client_id))
        buf.write(TLObject.serialize_bytes(self.phone))
        buf.write(TLObject.serialize_bytes(self.first_name))
        buf.write(TLObject.serialize_bytes(self.last_name))
        if self.note is not None:
            buf.write(bytes(self.note))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_client_id = reader.read_long()
        _args['client_id'] = _val_client_id
        _val_phone = reader.tgread_string()
        _args['phone'] = _val_phone
        _val_first_name = reader.tgread_string()
        _args['first_name'] = _val_first_name
        _val_last_name = reader.tgread_string()
        _args['last_name'] = _val_last_name
        if flags & (1 << 0):
            _val_note = reader.tgread_object()
            _args['note'] = _val_note
        else:
            _args['note'] = None
        return cls(**_args)


class InputPhoto(TLObject):
    """TL type: inputPhoto"""
    CONSTRUCTOR_ID = 0x3bb3b94a
    SUBCLASS_OF_ID = 0x846363e0

    def __init__(self, id: int, access_hash: int, file_reference: bytes):
        self.id = id
        self.access_hash = access_hash
        self.file_reference = file_reference

    def to_dict(self):
        return {
            '_': 'InputPhoto',
            'id': self.id,
            'access_hash': self.access_hash,
            'file_reference': self.file_reference,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.file_reference))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_file_reference = reader.tgread_bytes()
        _args['file_reference'] = _val_file_reference
        return cls(**_args)


class InputPhotoEmpty(TLObject):
    """TL type: inputPhotoEmpty"""
    CONSTRUCTOR_ID = 0x1cd7bf0d
    SUBCLASS_OF_ID = 0x846363e0

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPhotoEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPhotoFileLocation(TLObject):
    """TL type: inputPhotoFileLocation"""
    CONSTRUCTOR_ID = 0x40181ffe
    SUBCLASS_OF_ID = 0x1523d462

    def __init__(self, id: int, access_hash: int, file_reference: bytes, thumb_size: str):
        self.id = id
        self.access_hash = access_hash
        self.file_reference = file_reference
        self.thumb_size = thumb_size

    def to_dict(self):
        return {
            '_': 'InputPhotoFileLocation',
            'id': self.id,
            'access_hash': self.access_hash,
            'file_reference': self.file_reference,
            'thumb_size': self.thumb_size,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.file_reference))
        buf.write(TLObject.serialize_bytes(self.thumb_size))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_file_reference = reader.tgread_bytes()
        _args['file_reference'] = _val_file_reference
        _val_thumb_size = reader.tgread_string()
        _args['thumb_size'] = _val_thumb_size
        return cls(**_args)


class InputPhotoLegacyFileLocation(TLObject):
    """TL type: inputPhotoLegacyFileLocation"""
    CONSTRUCTOR_ID = 0xd83466f3
    SUBCLASS_OF_ID = 0x1523d462

    def __init__(self, id: int, access_hash: int, file_reference: bytes, volume_id: int, local_id: int, secret: int):
        self.id = id
        self.access_hash = access_hash
        self.file_reference = file_reference
        self.volume_id = volume_id
        self.local_id = local_id
        self.secret = secret

    def to_dict(self):
        return {
            '_': 'InputPhotoLegacyFileLocation',
            'id': self.id,
            'access_hash': self.access_hash,
            'file_reference': self.file_reference,
            'volume_id': self.volume_id,
            'local_id': self.local_id,
            'secret': self.secret,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.file_reference))
        buf.write(struct.pack('<q', self.volume_id))
        buf.write(struct.pack('<i', self.local_id))
        buf.write(struct.pack('<q', self.secret))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_file_reference = reader.tgread_bytes()
        _args['file_reference'] = _val_file_reference
        _val_volume_id = reader.read_long()
        _args['volume_id'] = _val_volume_id
        _val_local_id = reader.read_int()
        _args['local_id'] = _val_local_id
        _val_secret = reader.read_long()
        _args['secret'] = _val_secret
        return cls(**_args)


class InputPrivacyKeyAbout(TLObject):
    """TL type: inputPrivacyKeyAbout"""
    CONSTRUCTOR_ID = 0x3823cc40
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyAbout',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyAddedByPhone(TLObject):
    """TL type: inputPrivacyKeyAddedByPhone"""
    CONSTRUCTOR_ID = 0xd1219bdd
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyAddedByPhone',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyBirthday(TLObject):
    """TL type: inputPrivacyKeyBirthday"""
    CONSTRUCTOR_ID = 0xd65a11cc
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyBirthday',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyChatInvite(TLObject):
    """TL type: inputPrivacyKeyChatInvite"""
    CONSTRUCTOR_ID = 0xbdfb0426
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyChatInvite',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyForwards(TLObject):
    """TL type: inputPrivacyKeyForwards"""
    CONSTRUCTOR_ID = 0xa4dd4c08
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyForwards',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyNoPaidMessages(TLObject):
    """TL type: inputPrivacyKeyNoPaidMessages"""
    CONSTRUCTOR_ID = 0xbdc597b4
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyNoPaidMessages',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyPhoneCall(TLObject):
    """TL type: inputPrivacyKeyPhoneCall"""
    CONSTRUCTOR_ID = 0xfabadc5f
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyPhoneCall',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyPhoneNumber(TLObject):
    """TL type: inputPrivacyKeyPhoneNumber"""
    CONSTRUCTOR_ID = 0x0352dafa
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyPhoneNumber',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyPhoneP2p(TLObject):
    """TL type: inputPrivacyKeyPhoneP2P"""
    CONSTRUCTOR_ID = 0xdb9e70d2
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyPhoneP2p',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyProfilePhoto(TLObject):
    """TL type: inputPrivacyKeyProfilePhoto"""
    CONSTRUCTOR_ID = 0x5719bacc
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyProfilePhoto',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeySavedMusic(TLObject):
    """TL type: inputPrivacyKeySavedMusic"""
    CONSTRUCTOR_ID = 0x4dbe9226
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeySavedMusic',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyStarGiftsAutoSave(TLObject):
    """TL type: inputPrivacyKeyStarGiftsAutoSave"""
    CONSTRUCTOR_ID = 0xe1732341
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyStarGiftsAutoSave',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyStatusTimestamp(TLObject):
    """TL type: inputPrivacyKeyStatusTimestamp"""
    CONSTRUCTOR_ID = 0x4f96cb18
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyStatusTimestamp',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyKeyVoiceMessages(TLObject):
    """TL type: inputPrivacyKeyVoiceMessages"""
    CONSTRUCTOR_ID = 0xaee69d68
    SUBCLASS_OF_ID = 0x053627f8

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyKeyVoiceMessages',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyValueAllowAll(TLObject):
    """TL type: inputPrivacyValueAllowAll"""
    CONSTRUCTOR_ID = 0x184b35ce
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueAllowAll',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyValueAllowBots(TLObject):
    """TL type: inputPrivacyValueAllowBots"""
    CONSTRUCTOR_ID = 0x5a4fcce5
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueAllowBots',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyValueAllowChatParticipants(TLObject):
    """TL type: inputPrivacyValueAllowChatParticipants"""
    CONSTRUCTOR_ID = 0x840649cf
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self, chats: List[int]):
        self.chats = chats

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueAllowChatParticipants',
            'chats': self.chats,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.read_long()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        return cls(**_args)


class InputPrivacyValueAllowCloseFriends(TLObject):
    """TL type: inputPrivacyValueAllowCloseFriends"""
    CONSTRUCTOR_ID = 0x2f453e49
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueAllowCloseFriends',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyValueAllowContacts(TLObject):
    """TL type: inputPrivacyValueAllowContacts"""
    CONSTRUCTOR_ID = 0x0d09e07b
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueAllowContacts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyValueAllowPremium(TLObject):
    """TL type: inputPrivacyValueAllowPremium"""
    CONSTRUCTOR_ID = 0x77cdc9f1
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueAllowPremium',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyValueAllowUsers(TLObject):
    """TL type: inputPrivacyValueAllowUsers"""
    CONSTRUCTOR_ID = 0x131cc67f
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self, users: List['TypeInputUser']):
        self.users = users

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueAllowUsers',
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class InputPrivacyValueDisallowAll(TLObject):
    """TL type: inputPrivacyValueDisallowAll"""
    CONSTRUCTOR_ID = 0xd66b66c9
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueDisallowAll',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyValueDisallowBots(TLObject):
    """TL type: inputPrivacyValueDisallowBots"""
    CONSTRUCTOR_ID = 0xc4e57915
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueDisallowBots',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyValueDisallowChatParticipants(TLObject):
    """TL type: inputPrivacyValueDisallowChatParticipants"""
    CONSTRUCTOR_ID = 0xe94f0f86
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self, chats: List[int]):
        self.chats = chats

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueDisallowChatParticipants',
            'chats': self.chats,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.read_long()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        return cls(**_args)


class InputPrivacyValueDisallowContacts(TLObject):
    """TL type: inputPrivacyValueDisallowContacts"""
    CONSTRUCTOR_ID = 0x0ba52007
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueDisallowContacts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputPrivacyValueDisallowUsers(TLObject):
    """TL type: inputPrivacyValueDisallowUsers"""
    CONSTRUCTOR_ID = 0x90110467
    SUBCLASS_OF_ID = 0x5a3b6b22

    def __init__(self, users: List['TypeInputUser']):
        self.users = users

    def to_dict(self):
        return {
            '_': 'InputPrivacyValueDisallowUsers',
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class InputQuickReplyShortcut(TLObject):
    """TL type: inputQuickReplyShortcut"""
    CONSTRUCTOR_ID = 0x24596d41
    SUBCLASS_OF_ID = 0xa5687c57

    def __init__(self, shortcut: str):
        self.shortcut = shortcut

    def to_dict(self):
        return {
            '_': 'InputQuickReplyShortcut',
            'shortcut': self.shortcut,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.shortcut))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_shortcut = reader.tgread_string()
        _args['shortcut'] = _val_shortcut
        return cls(**_args)


class InputQuickReplyShortcutId(TLObject):
    """TL type: inputQuickReplyShortcutId"""
    CONSTRUCTOR_ID = 0x01190cf1
    SUBCLASS_OF_ID = 0xa5687c57

    def __init__(self, shortcut_id: int):
        self.shortcut_id = shortcut_id

    def to_dict(self):
        return {
            '_': 'InputQuickReplyShortcutId',
            'shortcut_id': self.shortcut_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.shortcut_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_shortcut_id = reader.read_int()
        _args['shortcut_id'] = _val_shortcut_id
        return cls(**_args)


class InputReplyToMessage(TLObject):
    """TL type: inputReplyToMessage"""
    CONSTRUCTOR_ID = 0x869fbe10
    SUBCLASS_OF_ID = 0x8c71131d

    def __init__(self, reply_to_msg_id: int, top_msg_id: Optional[int] = None, reply_to_peer_id: Optional['TypeInputPeer'] = None, quote_text: Optional[str] = None, quote_entities: Optional[List['TypeMessageEntity']] = None, quote_offset: Optional[int] = None, monoforum_peer_id: Optional['TypeInputPeer'] = None, todo_item_id: Optional[int] = None):
        self.reply_to_msg_id = reply_to_msg_id
        self.top_msg_id = top_msg_id
        self.reply_to_peer_id = reply_to_peer_id
        self.quote_text = quote_text
        self.quote_entities = quote_entities
        self.quote_offset = quote_offset
        self.monoforum_peer_id = monoforum_peer_id
        self.todo_item_id = todo_item_id

    def to_dict(self):
        return {
            '_': 'InputReplyToMessage',
            'reply_to_msg_id': self.reply_to_msg_id,
            'top_msg_id': self.top_msg_id,
            'reply_to_peer_id': self.reply_to_peer_id,
            'quote_text': self.quote_text,
            'quote_entities': self.quote_entities,
            'quote_offset': self.quote_offset,
            'monoforum_peer_id': self.monoforum_peer_id,
            'todo_item_id': self.todo_item_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.top_msg_id is not None:
            flags |= (1 << 0)
        if self.reply_to_peer_id is not None:
            flags |= (1 << 1)
        if self.quote_text is not None:
            flags |= (1 << 2)
        if self.quote_entities is not None:
            flags |= (1 << 3)
        if self.quote_offset is not None:
            flags |= (1 << 4)
        if self.monoforum_peer_id is not None:
            flags |= (1 << 5)
        if self.todo_item_id is not None:
            flags |= (1 << 6)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.reply_to_msg_id))
        if self.top_msg_id is not None:
            buf.write(struct.pack('<i', self.top_msg_id))
        if self.reply_to_peer_id is not None:
            buf.write(bytes(self.reply_to_peer_id))
        if self.quote_text is not None:
            buf.write(TLObject.serialize_bytes(self.quote_text))
        if self.quote_entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.quote_entities)))
            for item in self.quote_entities:
                buf.write(bytes(self.item))
        if self.quote_offset is not None:
            buf.write(struct.pack('<i', self.quote_offset))
        if self.monoforum_peer_id is not None:
            buf.write(bytes(self.monoforum_peer_id))
        if self.todo_item_id is not None:
            buf.write(struct.pack('<i', self.todo_item_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_reply_to_msg_id = reader.read_int()
        _args['reply_to_msg_id'] = _val_reply_to_msg_id
        if flags & (1 << 0):
            _val_top_msg_id = reader.read_int()
            _args['top_msg_id'] = _val_top_msg_id
        else:
            _args['top_msg_id'] = None
        if flags & (1 << 1):
            _val_reply_to_peer_id = reader.tgread_object()
            _args['reply_to_peer_id'] = _val_reply_to_peer_id
        else:
            _args['reply_to_peer_id'] = None
        if flags & (1 << 2):
            _val_quote_text = reader.tgread_string()
            _args['quote_text'] = _val_quote_text
        else:
            _args['quote_text'] = None
        if flags & (1 << 3):
            reader.read_int(signed=False)  # skip vector id
            _count_quote_entities = reader.read_int()
            _list_quote_entities = []
            for _ in range(_count_quote_entities):
                _item_quote_entities = reader.tgread_object()
                _list_quote_entities.append(_item_quote_entities)
            _args['quote_entities'] = _list_quote_entities
        else:
            _args['quote_entities'] = None
        if flags & (1 << 4):
            _val_quote_offset = reader.read_int()
            _args['quote_offset'] = _val_quote_offset
        else:
            _args['quote_offset'] = None
        if flags & (1 << 5):
            _val_monoforum_peer_id = reader.tgread_object()
            _args['monoforum_peer_id'] = _val_monoforum_peer_id
        else:
            _args['monoforum_peer_id'] = None
        if flags & (1 << 6):
            _val_todo_item_id = reader.read_int()
            _args['todo_item_id'] = _val_todo_item_id
        else:
            _args['todo_item_id'] = None
        return cls(**_args)


class InputReplyToMonoForum(TLObject):
    """TL type: inputReplyToMonoForum"""
    CONSTRUCTOR_ID = 0x69d66c45
    SUBCLASS_OF_ID = 0x8c71131d

    def __init__(self, monoforum_peer_id: 'TypeInputPeer'):
        self.monoforum_peer_id = monoforum_peer_id

    def to_dict(self):
        return {
            '_': 'InputReplyToMonoForum',
            'monoforum_peer_id': self.monoforum_peer_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.monoforum_peer_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_monoforum_peer_id = reader.tgread_object()
        _args['monoforum_peer_id'] = _val_monoforum_peer_id
        return cls(**_args)


class InputReplyToStory(TLObject):
    """TL type: inputReplyToStory"""
    CONSTRUCTOR_ID = 0x5881323a
    SUBCLASS_OF_ID = 0x8c71131d

    def __init__(self, peer: 'TypeInputPeer', story_id: int):
        self.peer = peer
        self.story_id = story_id

    def to_dict(self):
        return {
            '_': 'InputReplyToStory',
            'peer': self.peer,
            'story_id': self.story_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.story_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_story_id = reader.read_int()
        _args['story_id'] = _val_story_id
        return cls(**_args)


class InputReportReasonChildAbuse(TLObject):
    """TL type: inputReportReasonChildAbuse"""
    CONSTRUCTOR_ID = 0xadf44ee3
    SUBCLASS_OF_ID = 0x8401bd27

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputReportReasonChildAbuse',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputReportReasonCopyright(TLObject):
    """TL type: inputReportReasonCopyright"""
    CONSTRUCTOR_ID = 0x9b89f93a
    SUBCLASS_OF_ID = 0x8401bd27

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputReportReasonCopyright',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputReportReasonFake(TLObject):
    """TL type: inputReportReasonFake"""
    CONSTRUCTOR_ID = 0xf5ddd6e7
    SUBCLASS_OF_ID = 0x8401bd27

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputReportReasonFake',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputReportReasonGeoIrrelevant(TLObject):
    """TL type: inputReportReasonGeoIrrelevant"""
    CONSTRUCTOR_ID = 0xdbd4feed
    SUBCLASS_OF_ID = 0x8401bd27

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputReportReasonGeoIrrelevant',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputReportReasonIllegalDrugs(TLObject):
    """TL type: inputReportReasonIllegalDrugs"""
    CONSTRUCTOR_ID = 0x0a8eb2be
    SUBCLASS_OF_ID = 0x8401bd27

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputReportReasonIllegalDrugs',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputReportReasonOther(TLObject):
    """TL type: inputReportReasonOther"""
    CONSTRUCTOR_ID = 0xc1e4a2b1
    SUBCLASS_OF_ID = 0x8401bd27

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputReportReasonOther',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputReportReasonPersonalDetails(TLObject):
    """TL type: inputReportReasonPersonalDetails"""
    CONSTRUCTOR_ID = 0x9ec7863d
    SUBCLASS_OF_ID = 0x8401bd27

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputReportReasonPersonalDetails',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputReportReasonPornography(TLObject):
    """TL type: inputReportReasonPornography"""
    CONSTRUCTOR_ID = 0x2e59d922
    SUBCLASS_OF_ID = 0x8401bd27

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputReportReasonPornography',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputReportReasonSpam(TLObject):
    """TL type: inputReportReasonSpam"""
    CONSTRUCTOR_ID = 0x58dbcab8
    SUBCLASS_OF_ID = 0x8401bd27

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputReportReasonSpam',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputReportReasonViolence(TLObject):
    """TL type: inputReportReasonViolence"""
    CONSTRUCTOR_ID = 0x1e22c78d
    SUBCLASS_OF_ID = 0x8401bd27

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputReportReasonViolence',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputSavedStarGiftChat(TLObject):
    """TL type: inputSavedStarGiftChat"""
    CONSTRUCTOR_ID = 0xf101aa7f
    SUBCLASS_OF_ID = 0x8f7599ae

    def __init__(self, peer: 'TypeInputPeer', saved_id: int):
        self.peer = peer
        self.saved_id = saved_id

    def to_dict(self):
        return {
            '_': 'InputSavedStarGiftChat',
            'peer': self.peer,
            'saved_id': self.saved_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<q', self.saved_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_saved_id = reader.read_long()
        _args['saved_id'] = _val_saved_id
        return cls(**_args)


class InputSavedStarGiftSlug(TLObject):
    """TL type: inputSavedStarGiftSlug"""
    CONSTRUCTOR_ID = 0x2085c238
    SUBCLASS_OF_ID = 0x8f7599ae

    def __init__(self, slug: str):
        self.slug = slug

    def to_dict(self):
        return {
            '_': 'InputSavedStarGiftSlug',
            'slug': self.slug,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.slug))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        return cls(**_args)


class InputSavedStarGiftUser(TLObject):
    """TL type: inputSavedStarGiftUser"""
    CONSTRUCTOR_ID = 0x69279795
    SUBCLASS_OF_ID = 0x8f7599ae

    def __init__(self, msg_id: int):
        self.msg_id = msg_id

    def to_dict(self):
        return {
            '_': 'InputSavedStarGiftUser',
            'msg_id': self.msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        return cls(**_args)


class InputSecureFile(TLObject):
    """TL type: inputSecureFile"""
    CONSTRUCTOR_ID = 0x5367e5be
    SUBCLASS_OF_ID = 0xdac8adfc

    def __init__(self, id: int, access_hash: int):
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputSecureFile',
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputSecureFileLocation(TLObject):
    """TL type: inputSecureFileLocation"""
    CONSTRUCTOR_ID = 0xcbc7ee28
    SUBCLASS_OF_ID = 0x1523d462

    def __init__(self, id: int, access_hash: int):
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputSecureFileLocation',
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputSecureFileUploaded(TLObject):
    """TL type: inputSecureFileUploaded"""
    CONSTRUCTOR_ID = 0x3334b0f0
    SUBCLASS_OF_ID = 0xdac8adfc

    def __init__(self, id: int, parts: int, md5_checksum: str, file_hash: bytes, secret: bytes):
        self.id = id
        self.parts = parts
        self.md5_checksum = md5_checksum
        self.file_hash = file_hash
        self.secret = secret

    def to_dict(self):
        return {
            '_': 'InputSecureFileUploaded',
            'id': self.id,
            'parts': self.parts,
            'md5_checksum': self.md5_checksum,
            'file_hash': self.file_hash,
            'secret': self.secret,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<i', self.parts))
        buf.write(TLObject.serialize_bytes(self.md5_checksum))
        buf.write(TLObject.serialize_bytes(self.file_hash))
        buf.write(TLObject.serialize_bytes(self.secret))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_parts = reader.read_int()
        _args['parts'] = _val_parts
        _val_md5_checksum = reader.tgread_string()
        _args['md5_checksum'] = _val_md5_checksum
        _val_file_hash = reader.tgread_bytes()
        _args['file_hash'] = _val_file_hash
        _val_secret = reader.tgread_bytes()
        _args['secret'] = _val_secret
        return cls(**_args)


class InputSecureValue(TLObject):
    """TL type: inputSecureValue"""
    CONSTRUCTOR_ID = 0xdb21d0a7
    SUBCLASS_OF_ID = 0xb49da1fc

    def __init__(self, type: 'TypeSecureValueType', data: Optional['TypeSecureData'] = None, front_side: Optional['TypeInputSecureFile'] = None, reverse_side: Optional['TypeInputSecureFile'] = None, selfie: Optional['TypeInputSecureFile'] = None, translation: Optional[List['TypeInputSecureFile']] = None, files: Optional[List['TypeInputSecureFile']] = None, plain_data: Optional['TypeSecurePlainData'] = None):
        self.type = type
        self.data = data
        self.front_side = front_side
        self.reverse_side = reverse_side
        self.selfie = selfie
        self.translation = translation
        self.files = files
        self.plain_data = plain_data

    def to_dict(self):
        return {
            '_': 'InputSecureValue',
            'type': self.type,
            'data': self.data,
            'front_side': self.front_side,
            'reverse_side': self.reverse_side,
            'selfie': self.selfie,
            'translation': self.translation,
            'files': self.files,
            'plain_data': self.plain_data,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.data is not None:
            flags |= (1 << 0)
        if self.front_side is not None:
            flags |= (1 << 1)
        if self.reverse_side is not None:
            flags |= (1 << 2)
        if self.selfie is not None:
            flags |= (1 << 3)
        if self.translation is not None:
            flags |= (1 << 6)
        if self.files is not None:
            flags |= (1 << 4)
        if self.plain_data is not None:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.type))
        if self.data is not None:
            buf.write(bytes(self.data))
        if self.front_side is not None:
            buf.write(bytes(self.front_side))
        if self.reverse_side is not None:
            buf.write(bytes(self.reverse_side))
        if self.selfie is not None:
            buf.write(bytes(self.selfie))
        if self.translation is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.translation)))
            for item in self.translation:
                buf.write(bytes(self.item))
        if self.files is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.files)))
            for item in self.files:
                buf.write(bytes(self.item))
        if self.plain_data is not None:
            buf.write(bytes(self.plain_data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        if flags & (1 << 0):
            _val_data = reader.tgread_object()
            _args['data'] = _val_data
        else:
            _args['data'] = None
        if flags & (1 << 1):
            _val_front_side = reader.tgread_object()
            _args['front_side'] = _val_front_side
        else:
            _args['front_side'] = None
        if flags & (1 << 2):
            _val_reverse_side = reader.tgread_object()
            _args['reverse_side'] = _val_reverse_side
        else:
            _args['reverse_side'] = None
        if flags & (1 << 3):
            _val_selfie = reader.tgread_object()
            _args['selfie'] = _val_selfie
        else:
            _args['selfie'] = None
        if flags & (1 << 6):
            reader.read_int(signed=False)  # skip vector id
            _count_translation = reader.read_int()
            _list_translation = []
            for _ in range(_count_translation):
                _item_translation = reader.tgread_object()
                _list_translation.append(_item_translation)
            _args['translation'] = _list_translation
        else:
            _args['translation'] = None
        if flags & (1 << 4):
            reader.read_int(signed=False)  # skip vector id
            _count_files = reader.read_int()
            _list_files = []
            for _ in range(_count_files):
                _item_files = reader.tgread_object()
                _list_files.append(_item_files)
            _args['files'] = _list_files
        else:
            _args['files'] = None
        if flags & (1 << 5):
            _val_plain_data = reader.tgread_object()
            _args['plain_data'] = _val_plain_data
        else:
            _args['plain_data'] = None
        return cls(**_args)


class InputSingleMedia(TLObject):
    """TL type: inputSingleMedia"""
    CONSTRUCTOR_ID = 0x1cc6e91f
    SUBCLASS_OF_ID = 0x21ca8ed8

    def __init__(self, media: 'TypeInputMedia', message: str, random_id: int = None, entities: Optional[List['TypeMessageEntity']] = None):
        self.media = media
        self.message = message
        self.random_id = random_id
        self.entities = entities

    def to_dict(self):
        return {
            '_': 'InputSingleMedia',
            'media': self.media,
            'message': self.message,
            'random_id': self.random_id,
            'entities': self.entities,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.entities is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.media))
        buf.write(TLObject.serialize_bytes(self.message))
        buf.write(struct.pack('<q', self.random_id))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_media = reader.tgread_object()
        _args['media'] = _val_media
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        return cls(**_args)


class InputStarGiftAuction(TLObject):
    """TL type: inputStarGiftAuction"""
    CONSTRUCTOR_ID = 0x02e16c98
    SUBCLASS_OF_ID = 0x41a1eaaa

    def __init__(self, gift_id: int):
        self.gift_id = gift_id

    def to_dict(self):
        return {
            '_': 'InputStarGiftAuction',
            'gift_id': self.gift_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.gift_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_gift_id = reader.read_long()
        _args['gift_id'] = _val_gift_id
        return cls(**_args)


class InputStarGiftAuctionSlug(TLObject):
    """TL type: inputStarGiftAuctionSlug"""
    CONSTRUCTOR_ID = 0x7ab58308
    SUBCLASS_OF_ID = 0x41a1eaaa

    def __init__(self, slug: str):
        self.slug = slug

    def to_dict(self):
        return {
            '_': 'InputStarGiftAuctionSlug',
            'slug': self.slug,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.slug))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        return cls(**_args)


class InputStarsTransaction(TLObject):
    """TL type: inputStarsTransaction"""
    CONSTRUCTOR_ID = 0x206ae6d1
    SUBCLASS_OF_ID = 0x11e208ea

    def __init__(self, id: str, refund: Optional[bool] = None):
        self.id = id
        self.refund = refund

    def to_dict(self):
        return {
            '_': 'InputStarsTransaction',
            'id': self.id,
            'refund': self.refund,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.refund:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['refund'] = bool(flags & (1 << 0))
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        return cls(**_args)


class InputStickerSetAnimatedEmoji(TLObject):
    """TL type: inputStickerSetAnimatedEmoji"""
    CONSTRUCTOR_ID = 0x028703c8
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputStickerSetAnimatedEmoji',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputStickerSetAnimatedEmojiAnimations(TLObject):
    """TL type: inputStickerSetAnimatedEmojiAnimations"""
    CONSTRUCTOR_ID = 0x0cde3739
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputStickerSetAnimatedEmojiAnimations',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputStickerSetDice(TLObject):
    """TL type: inputStickerSetDice"""
    CONSTRUCTOR_ID = 0xe67f520e
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self, emoticon: str):
        self.emoticon = emoticon

    def to_dict(self):
        return {
            '_': 'InputStickerSetDice',
            'emoticon': self.emoticon,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.emoticon))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        return cls(**_args)


class InputStickerSetEmojiChannelDefaultStatuses(TLObject):
    """TL type: inputStickerSetEmojiChannelDefaultStatuses"""
    CONSTRUCTOR_ID = 0x49748553
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputStickerSetEmojiChannelDefaultStatuses',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputStickerSetEmojiDefaultStatuses(TLObject):
    """TL type: inputStickerSetEmojiDefaultStatuses"""
    CONSTRUCTOR_ID = 0x29d0f5ee
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputStickerSetEmojiDefaultStatuses',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputStickerSetEmojiDefaultTopicIcons(TLObject):
    """TL type: inputStickerSetEmojiDefaultTopicIcons"""
    CONSTRUCTOR_ID = 0x44c1f8e9
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputStickerSetEmojiDefaultTopicIcons',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputStickerSetEmojiGenericAnimations(TLObject):
    """TL type: inputStickerSetEmojiGenericAnimations"""
    CONSTRUCTOR_ID = 0x04c4d4ce
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputStickerSetEmojiGenericAnimations',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputStickerSetEmpty(TLObject):
    """TL type: inputStickerSetEmpty"""
    CONSTRUCTOR_ID = 0xffb62b95
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputStickerSetEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputStickerSetId(TLObject):
    """TL type: inputStickerSetID"""
    CONSTRUCTOR_ID = 0x9de7a269
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self, id: int, access_hash: int):
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputStickerSetId',
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputStickerSetItem(TLObject):
    """TL type: inputStickerSetItem"""
    CONSTRUCTOR_ID = 0x32da9e9c
    SUBCLASS_OF_ID = 0xae59f075

    def __init__(self, document: 'TypeInputDocument', emoji: str, mask_coords: Optional['TypeMaskCoords'] = None, keywords: Optional[str] = None):
        self.document = document
        self.emoji = emoji
        self.mask_coords = mask_coords
        self.keywords = keywords

    def to_dict(self):
        return {
            '_': 'InputStickerSetItem',
            'document': self.document,
            'emoji': self.emoji,
            'mask_coords': self.mask_coords,
            'keywords': self.keywords,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.mask_coords is not None:
            flags |= (1 << 0)
        if self.keywords is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.document))
        buf.write(TLObject.serialize_bytes(self.emoji))
        if self.mask_coords is not None:
            buf.write(bytes(self.mask_coords))
        if self.keywords is not None:
            buf.write(TLObject.serialize_bytes(self.keywords))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_document = reader.tgread_object()
        _args['document'] = _val_document
        _val_emoji = reader.tgread_string()
        _args['emoji'] = _val_emoji
        if flags & (1 << 0):
            _val_mask_coords = reader.tgread_object()
            _args['mask_coords'] = _val_mask_coords
        else:
            _args['mask_coords'] = None
        if flags & (1 << 1):
            _val_keywords = reader.tgread_string()
            _args['keywords'] = _val_keywords
        else:
            _args['keywords'] = None
        return cls(**_args)


class InputStickerSetPremiumGifts(TLObject):
    """TL type: inputStickerSetPremiumGifts"""
    CONSTRUCTOR_ID = 0xc88b3b02
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputStickerSetPremiumGifts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputStickerSetShortName(TLObject):
    """TL type: inputStickerSetShortName"""
    CONSTRUCTOR_ID = 0x861cc8a0
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self, short_name: str):
        self.short_name = short_name

    def to_dict(self):
        return {
            '_': 'InputStickerSetShortName',
            'short_name': self.short_name,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.short_name))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_short_name = reader.tgread_string()
        _args['short_name'] = _val_short_name
        return cls(**_args)


class InputStickerSetThumb(TLObject):
    """TL type: inputStickerSetThumb"""
    CONSTRUCTOR_ID = 0x9d84f3db
    SUBCLASS_OF_ID = 0x1523d462

    def __init__(self, stickerset: 'TypeInputStickerSet', thumb_version: int):
        self.stickerset = stickerset
        self.thumb_version = thumb_version

    def to_dict(self):
        return {
            '_': 'InputStickerSetThumb',
            'stickerset': self.stickerset,
            'thumb_version': self.thumb_version,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.stickerset))
        buf.write(struct.pack('<i', self.thumb_version))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_stickerset = reader.tgread_object()
        _args['stickerset'] = _val_stickerset
        _val_thumb_version = reader.read_int()
        _args['thumb_version'] = _val_thumb_version
        return cls(**_args)


class InputStickerSetTonGifts(TLObject):
    """TL type: inputStickerSetTonGifts"""
    CONSTRUCTOR_ID = 0x1cf671a0
    SUBCLASS_OF_ID = 0x3da389aa

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputStickerSetTonGifts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputStickeredMediaDocument(TLObject):
    """TL type: inputStickeredMediaDocument"""
    CONSTRUCTOR_ID = 0x0438865b
    SUBCLASS_OF_ID = 0x5146d99e

    def __init__(self, id: 'TypeInputDocument'):
        self.id = id

    def to_dict(self):
        return {
            '_': 'InputStickeredMediaDocument',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        return cls(**_args)


class InputStickeredMediaPhoto(TLObject):
    """TL type: inputStickeredMediaPhoto"""
    CONSTRUCTOR_ID = 0x4a992157
    SUBCLASS_OF_ID = 0x5146d99e

    def __init__(self, id: 'TypeInputPhoto'):
        self.id = id

    def to_dict(self):
        return {
            '_': 'InputStickeredMediaPhoto',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        return cls(**_args)


class InputStorePaymentAuthCode(TLObject):
    """TL type: inputStorePaymentAuthCode"""
    CONSTRUCTOR_ID = 0x9bb2636d
    SUBCLASS_OF_ID = 0xe7a4174d

    def __init__(self, phone_number: str, phone_code_hash: str, currency: str, amount: int, restore: Optional[bool] = None):
        self.phone_number = phone_number
        self.phone_code_hash = phone_code_hash
        self.currency = currency
        self.amount = amount
        self.restore = restore

    def to_dict(self):
        return {
            '_': 'InputStorePaymentAuthCode',
            'phone_number': self.phone_number,
            'phone_code_hash': self.phone_code_hash,
            'currency': self.currency,
            'amount': self.amount,
            'restore': self.restore,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.restore:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.phone_code_hash))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['restore'] = bool(flags & (1 << 0))
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_phone_code_hash = reader.tgread_string()
        _args['phone_code_hash'] = _val_phone_code_hash
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        return cls(**_args)


class InputStorePaymentGiftPremium(TLObject):
    """TL type: inputStorePaymentGiftPremium"""
    CONSTRUCTOR_ID = 0x616f7fe8
    SUBCLASS_OF_ID = 0xe7a4174d

    def __init__(self, user_id: 'TypeInputUser', currency: str, amount: int):
        self.user_id = user_id
        self.currency = currency
        self.amount = amount

    def to_dict(self):
        return {
            '_': 'InputStorePaymentGiftPremium',
            'user_id': self.user_id,
            'currency': self.currency,
            'amount': self.amount,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.user_id))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        return cls(**_args)


class InputStorePaymentPremiumGiftCode(TLObject):
    """TL type: inputStorePaymentPremiumGiftCode"""
    CONSTRUCTOR_ID = 0xfb790393
    SUBCLASS_OF_ID = 0xe7a4174d

    def __init__(self, users: List['TypeInputUser'], currency: str, amount: int, boost_peer: Optional['TypeInputPeer'] = None, message: Optional['TypeTextWithEntities'] = None):
        self.users = users
        self.currency = currency
        self.amount = amount
        self.boost_peer = boost_peer
        self.message = message

    def to_dict(self):
        return {
            '_': 'InputStorePaymentPremiumGiftCode',
            'users': self.users,
            'currency': self.currency,
            'amount': self.amount,
            'boost_peer': self.boost_peer,
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.boost_peer is not None:
            flags |= (1 << 0)
        if self.message is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        if self.boost_peer is not None:
            buf.write(bytes(self.boost_peer))
        if self.message is not None:
            buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        if flags & (1 << 0):
            _val_boost_peer = reader.tgread_object()
            _args['boost_peer'] = _val_boost_peer
        else:
            _args['boost_peer'] = None
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        if flags & (1 << 1):
            _val_message = reader.tgread_object()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        return cls(**_args)


class InputStorePaymentPremiumGiveaway(TLObject):
    """TL type: inputStorePaymentPremiumGiveaway"""
    CONSTRUCTOR_ID = 0x160544ca
    SUBCLASS_OF_ID = 0xe7a4174d

    def __init__(self, boost_peer: 'TypeInputPeer', until_date: Optional[datetime], currency: str, amount: int, only_new_subscribers: Optional[bool] = None, winners_are_visible: Optional[bool] = None, additional_peers: Optional[List['TypeInputPeer']] = None, countries_iso2: Optional[List[str]] = None, prize_description: Optional[str] = None, random_id: int = None):
        self.boost_peer = boost_peer
        self.until_date = until_date
        self.currency = currency
        self.amount = amount
        self.only_new_subscribers = only_new_subscribers
        self.winners_are_visible = winners_are_visible
        self.additional_peers = additional_peers
        self.countries_iso2 = countries_iso2
        self.prize_description = prize_description
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'InputStorePaymentPremiumGiveaway',
            'boost_peer': self.boost_peer,
            'until_date': self.until_date,
            'currency': self.currency,
            'amount': self.amount,
            'only_new_subscribers': self.only_new_subscribers,
            'winners_are_visible': self.winners_are_visible,
            'additional_peers': self.additional_peers,
            'countries_iso2': self.countries_iso2,
            'prize_description': self.prize_description,
            'random_id': self.random_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.only_new_subscribers:
            flags |= (1 << 0)
        if self.winners_are_visible:
            flags |= (1 << 3)
        if self.additional_peers is not None:
            flags |= (1 << 1)
        if self.countries_iso2 is not None:
            flags |= (1 << 2)
        if self.prize_description is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.boost_peer))
        buf.write(struct.pack('<i', self.until_date))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        if self.additional_peers is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.additional_peers)))
            for item in self.additional_peers:
                buf.write(bytes(self.item))
        if self.countries_iso2 is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.countries_iso2)))
            for item in self.countries_iso2:
                buf.write(TLObject.serialize_bytes(self.item))
        if self.prize_description is not None:
            buf.write(TLObject.serialize_bytes(self.prize_description))
        buf.write(struct.pack('<q', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['only_new_subscribers'] = bool(flags & (1 << 0))
        _args['winners_are_visible'] = bool(flags & (1 << 3))
        _val_boost_peer = reader.tgread_object()
        _args['boost_peer'] = _val_boost_peer
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_additional_peers = reader.read_int()
            _list_additional_peers = []
            for _ in range(_count_additional_peers):
                _item_additional_peers = reader.tgread_object()
                _list_additional_peers.append(_item_additional_peers)
            _args['additional_peers'] = _list_additional_peers
        else:
            _args['additional_peers'] = None
        if flags & (1 << 2):
            reader.read_int(signed=False)  # skip vector id
            _count_countries_iso2 = reader.read_int()
            _list_countries_iso2 = []
            for _ in range(_count_countries_iso2):
                _item_countries_iso2 = reader.tgread_string()
                _list_countries_iso2.append(_item_countries_iso2)
            _args['countries_iso2'] = _list_countries_iso2
        else:
            _args['countries_iso2'] = None
        if flags & (1 << 4):
            _val_prize_description = reader.tgread_string()
            _args['prize_description'] = _val_prize_description
        else:
            _args['prize_description'] = None
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_until_date = reader.read_int()
        _args['until_date'] = _val_until_date
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        return cls(**_args)


class InputStorePaymentPremiumSubscription(TLObject):
    """TL type: inputStorePaymentPremiumSubscription"""
    CONSTRUCTOR_ID = 0xa6751e66
    SUBCLASS_OF_ID = 0xe7a4174d

    def __init__(self, restore: Optional[bool] = None, upgrade: Optional[bool] = None):
        self.restore = restore
        self.upgrade = upgrade

    def to_dict(self):
        return {
            '_': 'InputStorePaymentPremiumSubscription',
            'restore': self.restore,
            'upgrade': self.upgrade,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.restore:
            flags |= (1 << 0)
        if self.upgrade:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['restore'] = bool(flags & (1 << 0))
        _args['upgrade'] = bool(flags & (1 << 1))
        return cls(**_args)


class InputStorePaymentStarsGift(TLObject):
    """TL type: inputStorePaymentStarsGift"""
    CONSTRUCTOR_ID = 0x1d741ef7
    SUBCLASS_OF_ID = 0xe7a4174d

    def __init__(self, user_id: 'TypeInputUser', stars: int, currency: str, amount: int):
        self.user_id = user_id
        self.stars = stars
        self.currency = currency
        self.amount = amount

    def to_dict(self):
        return {
            '_': 'InputStorePaymentStarsGift',
            'user_id': self.user_id,
            'stars': self.stars,
            'currency': self.currency,
            'amount': self.amount,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.user_id))
        buf.write(struct.pack('<q', self.stars))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        return cls(**_args)


class InputStorePaymentStarsGiveaway(TLObject):
    """TL type: inputStorePaymentStarsGiveaway"""
    CONSTRUCTOR_ID = 0x751f08fa
    SUBCLASS_OF_ID = 0xe7a4174d

    def __init__(self, stars: int, boost_peer: 'TypeInputPeer', until_date: Optional[datetime], currency: str, amount: int, users: int, only_new_subscribers: Optional[bool] = None, winners_are_visible: Optional[bool] = None, additional_peers: Optional[List['TypeInputPeer']] = None, countries_iso2: Optional[List[str]] = None, prize_description: Optional[str] = None, random_id: int = None):
        self.stars = stars
        self.boost_peer = boost_peer
        self.until_date = until_date
        self.currency = currency
        self.amount = amount
        self.users = users
        self.only_new_subscribers = only_new_subscribers
        self.winners_are_visible = winners_are_visible
        self.additional_peers = additional_peers
        self.countries_iso2 = countries_iso2
        self.prize_description = prize_description
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'InputStorePaymentStarsGiveaway',
            'stars': self.stars,
            'boost_peer': self.boost_peer,
            'until_date': self.until_date,
            'currency': self.currency,
            'amount': self.amount,
            'users': self.users,
            'only_new_subscribers': self.only_new_subscribers,
            'winners_are_visible': self.winners_are_visible,
            'additional_peers': self.additional_peers,
            'countries_iso2': self.countries_iso2,
            'prize_description': self.prize_description,
            'random_id': self.random_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.only_new_subscribers:
            flags |= (1 << 0)
        if self.winners_are_visible:
            flags |= (1 << 3)
        if self.additional_peers is not None:
            flags |= (1 << 1)
        if self.countries_iso2 is not None:
            flags |= (1 << 2)
        if self.prize_description is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.stars))
        buf.write(bytes(self.boost_peer))
        buf.write(struct.pack('<i', self.until_date))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        buf.write(struct.pack('<i', self.users))
        if self.additional_peers is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.additional_peers)))
            for item in self.additional_peers:
                buf.write(bytes(self.item))
        if self.countries_iso2 is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.countries_iso2)))
            for item in self.countries_iso2:
                buf.write(TLObject.serialize_bytes(self.item))
        if self.prize_description is not None:
            buf.write(TLObject.serialize_bytes(self.prize_description))
        buf.write(struct.pack('<q', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['only_new_subscribers'] = bool(flags & (1 << 0))
        _args['winners_are_visible'] = bool(flags & (1 << 3))
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        _val_boost_peer = reader.tgread_object()
        _args['boost_peer'] = _val_boost_peer
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_additional_peers = reader.read_int()
            _list_additional_peers = []
            for _ in range(_count_additional_peers):
                _item_additional_peers = reader.tgread_object()
                _list_additional_peers.append(_item_additional_peers)
            _args['additional_peers'] = _list_additional_peers
        else:
            _args['additional_peers'] = None
        if flags & (1 << 2):
            reader.read_int(signed=False)  # skip vector id
            _count_countries_iso2 = reader.read_int()
            _list_countries_iso2 = []
            for _ in range(_count_countries_iso2):
                _item_countries_iso2 = reader.tgread_string()
                _list_countries_iso2.append(_item_countries_iso2)
            _args['countries_iso2'] = _list_countries_iso2
        else:
            _args['countries_iso2'] = None
        if flags & (1 << 4):
            _val_prize_description = reader.tgread_string()
            _args['prize_description'] = _val_prize_description
        else:
            _args['prize_description'] = None
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_until_date = reader.read_int()
        _args['until_date'] = _val_until_date
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        _val_users = reader.read_int()
        _args['users'] = _val_users
        return cls(**_args)


class InputStorePaymentStarsTopup(TLObject):
    """TL type: inputStorePaymentStarsTopup"""
    CONSTRUCTOR_ID = 0xf9a2a6cb
    SUBCLASS_OF_ID = 0xe7a4174d

    def __init__(self, stars: int, currency: str, amount: int, spend_purpose_peer: Optional['TypeInputPeer'] = None):
        self.stars = stars
        self.currency = currency
        self.amount = amount
        self.spend_purpose_peer = spend_purpose_peer

    def to_dict(self):
        return {
            '_': 'InputStorePaymentStarsTopup',
            'stars': self.stars,
            'currency': self.currency,
            'amount': self.amount,
            'spend_purpose_peer': self.spend_purpose_peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.spend_purpose_peer is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.stars))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        if self.spend_purpose_peer is not None:
            buf.write(bytes(self.spend_purpose_peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        if flags & (1 << 0):
            _val_spend_purpose_peer = reader.tgread_object()
            _args['spend_purpose_peer'] = _val_spend_purpose_peer
        else:
            _args['spend_purpose_peer'] = None
        return cls(**_args)


class InputTakeoutFileLocation(TLObject):
    """TL type: inputTakeoutFileLocation"""
    CONSTRUCTOR_ID = 0x29be5899
    SUBCLASS_OF_ID = 0x1523d462

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputTakeoutFileLocation',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputTheme(TLObject):
    """TL type: inputTheme"""
    CONSTRUCTOR_ID = 0x3c5693e9
    SUBCLASS_OF_ID = 0x07a100f0

    def __init__(self, id: int, access_hash: int):
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputTheme',
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputThemeSettings(TLObject):
    """TL type: inputThemeSettings"""
    CONSTRUCTOR_ID = 0x8fde504f
    SUBCLASS_OF_ID = 0x8338c882

    def __init__(self, base_theme: 'TypeBaseTheme', accent_color: int, message_colors_animated: Optional[bool] = None, outbox_accent_color: Optional[int] = None, message_colors: Optional[List[int]] = None, wallpaper: Optional['TypeInputWallPaper'] = None, wallpaper_settings: Optional['TypeWallPaperSettings'] = None):
        self.base_theme = base_theme
        self.accent_color = accent_color
        self.message_colors_animated = message_colors_animated
        self.outbox_accent_color = outbox_accent_color
        self.message_colors = message_colors
        self.wallpaper = wallpaper
        self.wallpaper_settings = wallpaper_settings

    def to_dict(self):
        return {
            '_': 'InputThemeSettings',
            'base_theme': self.base_theme,
            'accent_color': self.accent_color,
            'message_colors_animated': self.message_colors_animated,
            'outbox_accent_color': self.outbox_accent_color,
            'message_colors': self.message_colors,
            'wallpaper': self.wallpaper,
            'wallpaper_settings': self.wallpaper_settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.message_colors_animated:
            flags |= (1 << 2)
        if self.outbox_accent_color is not None:
            flags |= (1 << 3)
        if self.message_colors is not None:
            flags |= (1 << 0)
        if self.wallpaper_settings is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.base_theme))
        buf.write(struct.pack('<i', self.accent_color))
        if self.outbox_accent_color is not None:
            buf.write(struct.pack('<i', self.outbox_accent_color))
        if self.message_colors is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.message_colors)))
            for item in self.message_colors:
                buf.write(struct.pack('<i', self.item))
        if self.wallpaper is not None:
            buf.write(bytes(self.wallpaper))
        if self.wallpaper_settings is not None:
            buf.write(bytes(self.wallpaper_settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['message_colors_animated'] = bool(flags & (1 << 2))
        _val_base_theme = reader.tgread_object()
        _args['base_theme'] = _val_base_theme
        _val_accent_color = reader.read_int()
        _args['accent_color'] = _val_accent_color
        if flags & (1 << 3):
            _val_outbox_accent_color = reader.read_int()
            _args['outbox_accent_color'] = _val_outbox_accent_color
        else:
            _args['outbox_accent_color'] = None
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_message_colors = reader.read_int()
            _list_message_colors = []
            for _ in range(_count_message_colors):
                _item_message_colors = reader.read_int()
                _list_message_colors.append(_item_message_colors)
            _args['message_colors'] = _list_message_colors
        else:
            _args['message_colors'] = None
        if flags & (1 << 1):
            _val_wallpaper = reader.tgread_object()
            _args['wallpaper'] = _val_wallpaper
        else:
            _args['wallpaper'] = None
        if flags & (1 << 1):
            _val_wallpaper_settings = reader.tgread_object()
            _args['wallpaper_settings'] = _val_wallpaper_settings
        else:
            _args['wallpaper_settings'] = None
        return cls(**_args)


class InputThemeSlug(TLObject):
    """TL type: inputThemeSlug"""
    CONSTRUCTOR_ID = 0xf5890df1
    SUBCLASS_OF_ID = 0x07a100f0

    def __init__(self, slug: str):
        self.slug = slug

    def to_dict(self):
        return {
            '_': 'InputThemeSlug',
            'slug': self.slug,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.slug))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        return cls(**_args)


class InputUser(TLObject):
    """TL type: inputUser"""
    CONSTRUCTOR_ID = 0xf21158c6
    SUBCLASS_OF_ID = 0xe669bf46

    def __init__(self, user_id: int, access_hash: int):
        self.user_id = user_id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputUser',
            'user_id': self.user_id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputUserEmpty(TLObject):
    """TL type: inputUserEmpty"""
    CONSTRUCTOR_ID = 0xb98886cf
    SUBCLASS_OF_ID = 0xe669bf46

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputUserEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputUserFromMessage(TLObject):
    """TL type: inputUserFromMessage"""
    CONSTRUCTOR_ID = 0x1da448e2
    SUBCLASS_OF_ID = 0xe669bf46

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, user_id: int):
        self.peer = peer
        self.msg_id = msg_id
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'InputUserFromMessage',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'user_id': self.user_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<q', self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class InputUserSelf(TLObject):
    """TL type: inputUserSelf"""
    CONSTRUCTOR_ID = 0xf7c1b13f
    SUBCLASS_OF_ID = 0xe669bf46

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'InputUserSelf',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class InputWallPaper(TLObject):
    """TL type: inputWallPaper"""
    CONSTRUCTOR_ID = 0xe630b979
    SUBCLASS_OF_ID = 0xee77201a

    def __init__(self, id: int, access_hash: int):
        self.id = id
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputWallPaper',
            'id': self.id,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class InputWallPaperNoFile(TLObject):
    """TL type: inputWallPaperNoFile"""
    CONSTRUCTOR_ID = 0x967a462e
    SUBCLASS_OF_ID = 0xee77201a

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'InputWallPaperNoFile',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        return cls(**_args)


class InputWallPaperSlug(TLObject):
    """TL type: inputWallPaperSlug"""
    CONSTRUCTOR_ID = 0x72091c80
    SUBCLASS_OF_ID = 0xee77201a

    def __init__(self, slug: str):
        self.slug = slug

    def to_dict(self):
        return {
            '_': 'InputWallPaperSlug',
            'slug': self.slug,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.slug))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        return cls(**_args)


class InputWebDocument(TLObject):
    """TL type: inputWebDocument"""
    CONSTRUCTOR_ID = 0x9bed434d
    SUBCLASS_OF_ID = 0x8ae8b146

    def __init__(self, url: str, size: int, mime_type: str, attributes: List['TypeDocumentAttribute']):
        self.url = url
        self.size = size
        self.mime_type = mime_type
        self.attributes = attributes

    def to_dict(self):
        return {
            '_': 'InputWebDocument',
            'url': self.url,
            'size': self.size,
            'mime_type': self.mime_type,
            'attributes': self.attributes,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<i', self.size))
        buf.write(TLObject.serialize_bytes(self.mime_type))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.attributes)))
        for item in self.attributes:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_size = reader.read_int()
        _args['size'] = _val_size
        _val_mime_type = reader.tgread_string()
        _args['mime_type'] = _val_mime_type
        reader.read_int(signed=False)  # skip vector id
        _count_attributes = reader.read_int()
        _list_attributes = []
        for _ in range(_count_attributes):
            _item_attributes = reader.tgread_object()
            _list_attributes.append(_item_attributes)
        _args['attributes'] = _list_attributes
        return cls(**_args)


class InputWebFileAudioAlbumThumbLocation(TLObject):
    """TL type: inputWebFileAudioAlbumThumbLocation"""
    CONSTRUCTOR_ID = 0xf46fe924
    SUBCLASS_OF_ID = 0xf72ed8d9

    def __init__(self, small: Optional[bool] = None, document: Optional['TypeInputDocument'] = None, title: Optional[str] = None, performer: Optional[str] = None):
        self.small = small
        self.document = document
        self.title = title
        self.performer = performer

    def to_dict(self):
        return {
            '_': 'InputWebFileAudioAlbumThumbLocation',
            'small': self.small,
            'document': self.document,
            'title': self.title,
            'performer': self.performer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.small:
            flags |= (1 << 2)
        if self.document is not None:
            flags |= (1 << 0)
        if self.performer is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        if self.document is not None:
            buf.write(bytes(self.document))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.performer is not None:
            buf.write(TLObject.serialize_bytes(self.performer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['small'] = bool(flags & (1 << 2))
        if flags & (1 << 0):
            _val_document = reader.tgread_object()
            _args['document'] = _val_document
        else:
            _args['document'] = None
        if flags & (1 << 1):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 1):
            _val_performer = reader.tgread_string()
            _args['performer'] = _val_performer
        else:
            _args['performer'] = None
        return cls(**_args)


class InputWebFileGeoPointLocation(TLObject):
    """TL type: inputWebFileGeoPointLocation"""
    CONSTRUCTOR_ID = 0x9f2221c9
    SUBCLASS_OF_ID = 0xf72ed8d9

    def __init__(self, geo_point: 'TypeInputGeoPoint', access_hash: int, w: int, h: int, zoom: int, scale: int):
        self.geo_point = geo_point
        self.access_hash = access_hash
        self.w = w
        self.h = h
        self.zoom = zoom
        self.scale = scale

    def to_dict(self):
        return {
            '_': 'InputWebFileGeoPointLocation',
            'geo_point': self.geo_point,
            'access_hash': self.access_hash,
            'w': self.w,
            'h': self.h,
            'zoom': self.zoom,
            'scale': self.scale,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.geo_point))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<i', self.w))
        buf.write(struct.pack('<i', self.h))
        buf.write(struct.pack('<i', self.zoom))
        buf.write(struct.pack('<i', self.scale))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_geo_point = reader.tgread_object()
        _args['geo_point'] = _val_geo_point
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_w = reader.read_int()
        _args['w'] = _val_w
        _val_h = reader.read_int()
        _args['h'] = _val_h
        _val_zoom = reader.read_int()
        _args['zoom'] = _val_zoom
        _val_scale = reader.read_int()
        _args['scale'] = _val_scale
        return cls(**_args)


class InputWebFileLocation(TLObject):
    """TL type: inputWebFileLocation"""
    CONSTRUCTOR_ID = 0xc239d686
    SUBCLASS_OF_ID = 0xf72ed8d9

    def __init__(self, url: str, access_hash: int):
        self.url = url
        self.access_hash = access_hash

    def to_dict(self):
        return {
            '_': 'InputWebFileLocation',
            'url': self.url,
            'access_hash': self.access_hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<q', self.access_hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        return cls(**_args)


class Invoice(TLObject):
    """TL type: invoice"""
    CONSTRUCTOR_ID = 0x049ee584
    SUBCLASS_OF_ID = 0x5fd82ed8

    def __init__(self, currency: str, prices: List['TypeLabeledPrice'], test: Optional[bool] = None, name_requested: Optional[bool] = None, phone_requested: Optional[bool] = None, email_requested: Optional[bool] = None, shipping_address_requested: Optional[bool] = None, flexible: Optional[bool] = None, phone_to_provider: Optional[bool] = None, email_to_provider: Optional[bool] = None, recurring: Optional[bool] = None, max_tip_amount: Optional[int] = None, suggested_tip_amounts: Optional[List[int]] = None, terms_url: Optional[str] = None, subscription_period: Optional[int] = None):
        self.currency = currency
        self.prices = prices
        self.test = test
        self.name_requested = name_requested
        self.phone_requested = phone_requested
        self.email_requested = email_requested
        self.shipping_address_requested = shipping_address_requested
        self.flexible = flexible
        self.phone_to_provider = phone_to_provider
        self.email_to_provider = email_to_provider
        self.recurring = recurring
        self.max_tip_amount = max_tip_amount
        self.suggested_tip_amounts = suggested_tip_amounts
        self.terms_url = terms_url
        self.subscription_period = subscription_period

    def to_dict(self):
        return {
            '_': 'Invoice',
            'currency': self.currency,
            'prices': self.prices,
            'test': self.test,
            'name_requested': self.name_requested,
            'phone_requested': self.phone_requested,
            'email_requested': self.email_requested,
            'shipping_address_requested': self.shipping_address_requested,
            'flexible': self.flexible,
            'phone_to_provider': self.phone_to_provider,
            'email_to_provider': self.email_to_provider,
            'recurring': self.recurring,
            'max_tip_amount': self.max_tip_amount,
            'suggested_tip_amounts': self.suggested_tip_amounts,
            'terms_url': self.terms_url,
            'subscription_period': self.subscription_period,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.test:
            flags |= (1 << 0)
        if self.name_requested:
            flags |= (1 << 1)
        if self.phone_requested:
            flags |= (1 << 2)
        if self.email_requested:
            flags |= (1 << 3)
        if self.shipping_address_requested:
            flags |= (1 << 4)
        if self.flexible:
            flags |= (1 << 5)
        if self.phone_to_provider:
            flags |= (1 << 6)
        if self.email_to_provider:
            flags |= (1 << 7)
        if self.recurring:
            flags |= (1 << 9)
        if self.suggested_tip_amounts is not None:
            flags |= (1 << 8)
        if self.terms_url is not None:
            flags |= (1 << 10)
        if self.subscription_period is not None:
            flags |= (1 << 11)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.prices)))
        for item in self.prices:
            buf.write(bytes(self.item))
        if self.max_tip_amount is not None:
            buf.write(struct.pack('<q', self.max_tip_amount))
        if self.suggested_tip_amounts is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.suggested_tip_amounts)))
            for item in self.suggested_tip_amounts:
                buf.write(struct.pack('<q', self.item))
        if self.terms_url is not None:
            buf.write(TLObject.serialize_bytes(self.terms_url))
        if self.subscription_period is not None:
            buf.write(struct.pack('<i', self.subscription_period))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['test'] = bool(flags & (1 << 0))
        _args['name_requested'] = bool(flags & (1 << 1))
        _args['phone_requested'] = bool(flags & (1 << 2))
        _args['email_requested'] = bool(flags & (1 << 3))
        _args['shipping_address_requested'] = bool(flags & (1 << 4))
        _args['flexible'] = bool(flags & (1 << 5))
        _args['phone_to_provider'] = bool(flags & (1 << 6))
        _args['email_to_provider'] = bool(flags & (1 << 7))
        _args['recurring'] = bool(flags & (1 << 9))
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        reader.read_int(signed=False)  # skip vector id
        _count_prices = reader.read_int()
        _list_prices = []
        for _ in range(_count_prices):
            _item_prices = reader.tgread_object()
            _list_prices.append(_item_prices)
        _args['prices'] = _list_prices
        if flags & (1 << 8):
            _val_max_tip_amount = reader.read_long()
            _args['max_tip_amount'] = _val_max_tip_amount
        else:
            _args['max_tip_amount'] = None
        if flags & (1 << 8):
            reader.read_int(signed=False)  # skip vector id
            _count_suggested_tip_amounts = reader.read_int()
            _list_suggested_tip_amounts = []
            for _ in range(_count_suggested_tip_amounts):
                _item_suggested_tip_amounts = reader.read_long()
                _list_suggested_tip_amounts.append(_item_suggested_tip_amounts)
            _args['suggested_tip_amounts'] = _list_suggested_tip_amounts
        else:
            _args['suggested_tip_amounts'] = None
        if flags & (1 << 10):
            _val_terms_url = reader.tgread_string()
            _args['terms_url'] = _val_terms_url
        else:
            _args['terms_url'] = None
        if flags & (1 << 11):
            _val_subscription_period = reader.read_int()
            _args['subscription_period'] = _val_subscription_period
        else:
            _args['subscription_period'] = None
        return cls(**_args)


class JsonArray(TLObject):
    """TL type: jsonArray"""
    CONSTRUCTOR_ID = 0xf7444763
    SUBCLASS_OF_ID = 0xeb9987b3

    def __init__(self, value: List['TypeJSONValue']):
        self.value = value

    def to_dict(self):
        return {
            '_': 'JsonArray',
            'value': self.value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.value)))
        for item in self.value:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_value = reader.read_int()
        _list_value = []
        for _ in range(_count_value):
            _item_value = reader.tgread_object()
            _list_value.append(_item_value)
        _args['value'] = _list_value
        return cls(**_args)


class JsonBool(TLObject):
    """TL type: jsonBool"""
    CONSTRUCTOR_ID = 0xc7345e6a
    SUBCLASS_OF_ID = 0xeb9987b3

    def __init__(self, value: bool):
        self.value = value

    def to_dict(self):
        return {
            '_': 'JsonBool',
            'value': self.value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<I', 0x997275b5 if self.value else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_value = reader.tgread_bool()
        _args['value'] = _val_value
        return cls(**_args)


class JsonNull(TLObject):
    """TL type: jsonNull"""
    CONSTRUCTOR_ID = 0x3f6d7b68
    SUBCLASS_OF_ID = 0xeb9987b3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'JsonNull',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class JsonNumber(TLObject):
    """TL type: jsonNumber"""
    CONSTRUCTOR_ID = 0x2be0dfa4
    SUBCLASS_OF_ID = 0xeb9987b3

    def __init__(self, value: float):
        self.value = value

    def to_dict(self):
        return {
            '_': 'JsonNumber',
            'value': self.value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<d', self.value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_value = reader.read_double()
        _args['value'] = _val_value
        return cls(**_args)


class JsonObject(TLObject):
    """TL type: jsonObject"""
    CONSTRUCTOR_ID = 0x99c1d49d
    SUBCLASS_OF_ID = 0xeb9987b3

    def __init__(self, value: List['TypeJSONObjectValue']):
        self.value = value

    def to_dict(self):
        return {
            '_': 'JsonObject',
            'value': self.value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.value)))
        for item in self.value:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_value = reader.read_int()
        _list_value = []
        for _ in range(_count_value):
            _item_value = reader.tgread_object()
            _list_value.append(_item_value)
        _args['value'] = _list_value
        return cls(**_args)


class JsonObjectValue(TLObject):
    """TL type: jsonObjectValue"""
    CONSTRUCTOR_ID = 0xc0de1bd9
    SUBCLASS_OF_ID = 0x937fceb9

    def __init__(self, key: str, value: 'TypeJSONValue'):
        self.key = key
        self.value = value

    def to_dict(self):
        return {
            '_': 'JsonObjectValue',
            'key': self.key,
            'value': self.value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.key))
        buf.write(bytes(self.value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_key = reader.tgread_string()
        _args['key'] = _val_key
        _val_value = reader.tgread_object()
        _args['value'] = _val_value
        return cls(**_args)


class JsonString(TLObject):
    """TL type: jsonString"""
    CONSTRUCTOR_ID = 0xb71e767a
    SUBCLASS_OF_ID = 0xeb9987b3

    def __init__(self, value: str):
        self.value = value

    def to_dict(self):
        return {
            '_': 'JsonString',
            'value': self.value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_value = reader.tgread_string()
        _args['value'] = _val_value
        return cls(**_args)


class KeyboardButton(TLObject):
    """TL type: keyboardButton"""
    CONSTRUCTOR_ID = 0x7d170cff
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButton',
            'text': self.text,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class KeyboardButtonBuy(TLObject):
    """TL type: keyboardButtonBuy"""
    CONSTRUCTOR_ID = 0x3fa53905
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButtonBuy',
            'text': self.text,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class KeyboardButtonCallback(TLObject):
    """TL type: keyboardButtonCallback"""
    CONSTRUCTOR_ID = 0xe62bc960
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, data: bytes, requires_password: Optional[bool] = None, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.data = data
        self.requires_password = requires_password
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButtonCallback',
            'text': self.text,
            'data': self.data,
            'requires_password': self.requires_password,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.requires_password:
            flags |= (1 << 0)
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.data))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['requires_password'] = bool(flags & (1 << 0))
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_data = reader.tgread_bytes()
        _args['data'] = _val_data
        return cls(**_args)


class KeyboardButtonCopy(TLObject):
    """TL type: keyboardButtonCopy"""
    CONSTRUCTOR_ID = 0xbcc4af10
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, copy_text: str, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.copy_text = copy_text
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButtonCopy',
            'text': self.text,
            'copy_text': self.copy_text,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.copy_text))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_copy_text = reader.tgread_string()
        _args['copy_text'] = _val_copy_text
        return cls(**_args)


class KeyboardButtonGame(TLObject):
    """TL type: keyboardButtonGame"""
    CONSTRUCTOR_ID = 0x89c590f9
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButtonGame',
            'text': self.text,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class KeyboardButtonRequestGeoLocation(TLObject):
    """TL type: keyboardButtonRequestGeoLocation"""
    CONSTRUCTOR_ID = 0xaa40f94d
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButtonRequestGeoLocation',
            'text': self.text,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class KeyboardButtonRequestPeer(TLObject):
    """TL type: keyboardButtonRequestPeer"""
    CONSTRUCTOR_ID = 0x5b0f15f5
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, button_id: int, peer_type: 'TypeRequestPeerType', max_quantity: int, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.button_id = button_id
        self.peer_type = peer_type
        self.max_quantity = max_quantity
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButtonRequestPeer',
            'text': self.text,
            'button_id': self.button_id,
            'peer_type': self.peer_type,
            'max_quantity': self.max_quantity,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(struct.pack('<i', self.button_id))
        buf.write(bytes(self.peer_type))
        buf.write(struct.pack('<i', self.max_quantity))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_button_id = reader.read_int()
        _args['button_id'] = _val_button_id
        _val_peer_type = reader.tgread_object()
        _args['peer_type'] = _val_peer_type
        _val_max_quantity = reader.read_int()
        _args['max_quantity'] = _val_max_quantity
        return cls(**_args)


class KeyboardButtonRequestPhone(TLObject):
    """TL type: keyboardButtonRequestPhone"""
    CONSTRUCTOR_ID = 0x417efd8f
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButtonRequestPhone',
            'text': self.text,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class KeyboardButtonRequestPoll(TLObject):
    """TL type: keyboardButtonRequestPoll"""
    CONSTRUCTOR_ID = 0x7a11d782
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, style: Optional['TypeKeyboardButtonStyle'] = None, quiz: Optional[bool] = None):
        self.text = text
        self.style = style
        self.quiz = quiz

    def to_dict(self):
        return {
            '_': 'KeyboardButtonRequestPoll',
            'text': self.text,
            'style': self.style,
            'quiz': self.quiz,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        if self.quiz is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        if self.style is not None:
            buf.write(bytes(self.style))
        if self.quiz is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.quiz else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        if flags & (1 << 0):
            _val_quiz = reader.tgread_bool()
            _args['quiz'] = _val_quiz
        else:
            _args['quiz'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class KeyboardButtonRow(TLObject):
    """TL type: keyboardButtonRow"""
    CONSTRUCTOR_ID = 0x77608b83
    SUBCLASS_OF_ID = 0x847730ae

    def __init__(self, buttons: List['TypeKeyboardButton']):
        self.buttons = buttons

    def to_dict(self):
        return {
            '_': 'KeyboardButtonRow',
            'buttons': self.buttons,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.buttons)))
        for item in self.buttons:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_buttons = reader.read_int()
        _list_buttons = []
        for _ in range(_count_buttons):
            _item_buttons = reader.tgread_object()
            _list_buttons.append(_item_buttons)
        _args['buttons'] = _list_buttons
        return cls(**_args)


class KeyboardButtonSimpleWebView(TLObject):
    """TL type: keyboardButtonSimpleWebView"""
    CONSTRUCTOR_ID = 0xe15c4370
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, url: str, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.url = url
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButtonSimpleWebView',
            'text': self.text,
            'url': self.url,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.url))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class KeyboardButtonStyle(TLObject):
    """TL type: keyboardButtonStyle"""
    CONSTRUCTOR_ID = 0x4fdd3430
    SUBCLASS_OF_ID = 0x13f2521b

    def __init__(self, bg_primary: Optional[bool] = None, bg_danger: Optional[bool] = None, bg_success: Optional[bool] = None, icon: Optional[int] = None):
        self.bg_primary = bg_primary
        self.bg_danger = bg_danger
        self.bg_success = bg_success
        self.icon = icon

    def to_dict(self):
        return {
            '_': 'KeyboardButtonStyle',
            'bg_primary': self.bg_primary,
            'bg_danger': self.bg_danger,
            'bg_success': self.bg_success,
            'icon': self.icon,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.bg_primary:
            flags |= (1 << 0)
        if self.bg_danger:
            flags |= (1 << 1)
        if self.bg_success:
            flags |= (1 << 2)
        if self.icon is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        if self.icon is not None:
            buf.write(struct.pack('<q', self.icon))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['bg_primary'] = bool(flags & (1 << 0))
        _args['bg_danger'] = bool(flags & (1 << 1))
        _args['bg_success'] = bool(flags & (1 << 2))
        if flags & (1 << 3):
            _val_icon = reader.read_long()
            _args['icon'] = _val_icon
        else:
            _args['icon'] = None
        return cls(**_args)


class KeyboardButtonSwitchInline(TLObject):
    """TL type: keyboardButtonSwitchInline"""
    CONSTRUCTOR_ID = 0x991399fc
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, query: str, same_peer: Optional[bool] = None, style: Optional['TypeKeyboardButtonStyle'] = None, peer_types: Optional[List['TypeInlineQueryPeerType']] = None):
        self.text = text
        self.query = query
        self.same_peer = same_peer
        self.style = style
        self.peer_types = peer_types

    def to_dict(self):
        return {
            '_': 'KeyboardButtonSwitchInline',
            'text': self.text,
            'query': self.query,
            'same_peer': self.same_peer,
            'style': self.style,
            'peer_types': self.peer_types,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.same_peer:
            flags |= (1 << 0)
        if self.style is not None:
            flags |= (1 << 10)
        if self.peer_types is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.query))
        if self.style is not None:
            buf.write(bytes(self.style))
        if self.peer_types is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.peer_types)))
            for item in self.peer_types:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['same_peer'] = bool(flags & (1 << 0))
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_query = reader.tgread_string()
        _args['query'] = _val_query
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_peer_types = reader.read_int()
            _list_peer_types = []
            for _ in range(_count_peer_types):
                _item_peer_types = reader.tgread_object()
                _list_peer_types.append(_item_peer_types)
            _args['peer_types'] = _list_peer_types
        else:
            _args['peer_types'] = None
        return cls(**_args)


class KeyboardButtonUrl(TLObject):
    """TL type: keyboardButtonUrl"""
    CONSTRUCTOR_ID = 0xd80c25ec
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, url: str, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.url = url
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButtonUrl',
            'text': self.text,
            'url': self.url,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.url))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class KeyboardButtonUrlAuth(TLObject):
    """TL type: keyboardButtonUrlAuth"""
    CONSTRUCTOR_ID = 0xf51006f9
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, url: str, button_id: int, style: Optional['TypeKeyboardButtonStyle'] = None, fwd_text: Optional[str] = None):
        self.text = text
        self.url = url
        self.button_id = button_id
        self.style = style
        self.fwd_text = fwd_text

    def to_dict(self):
        return {
            '_': 'KeyboardButtonUrlAuth',
            'text': self.text,
            'url': self.url,
            'button_id': self.button_id,
            'style': self.style,
            'fwd_text': self.fwd_text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        if self.fwd_text is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<i', self.button_id))
        if self.style is not None:
            buf.write(bytes(self.style))
        if self.fwd_text is not None:
            buf.write(TLObject.serialize_bytes(self.fwd_text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        if flags & (1 << 0):
            _val_fwd_text = reader.tgread_string()
            _args['fwd_text'] = _val_fwd_text
        else:
            _args['fwd_text'] = None
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_button_id = reader.read_int()
        _args['button_id'] = _val_button_id
        return cls(**_args)


class KeyboardButtonUserProfile(TLObject):
    """TL type: keyboardButtonUserProfile"""
    CONSTRUCTOR_ID = 0xc0fd5d09
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, user_id: int, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.user_id = user_id
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButtonUserProfile',
            'text': self.text,
            'user_id': self.user_id,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(struct.pack('<q', self.user_id))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class KeyboardButtonWebView(TLObject):
    """TL type: keyboardButtonWebView"""
    CONSTRUCTOR_ID = 0xe846b1a0
    SUBCLASS_OF_ID = 0x0bad74a3

    def __init__(self, text: str, url: str, style: Optional['TypeKeyboardButtonStyle'] = None):
        self.text = text
        self.url = url
        self.style = style

    def to_dict(self):
        return {
            '_': 'KeyboardButtonWebView',
            'text': self.text,
            'url': self.url,
            'style': self.style,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.style is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.url))
        if self.style is not None:
            buf.write(bytes(self.style))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 10):
            _val_style = reader.tgread_object()
            _args['style'] = _val_style
        else:
            _args['style'] = None
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class LabeledPrice(TLObject):
    """TL type: labeledPrice"""
    CONSTRUCTOR_ID = 0xcb296bf8
    SUBCLASS_OF_ID = 0x1c84047a

    def __init__(self, label: str, amount: int):
        self.label = label
        self.amount = amount

    def to_dict(self):
        return {
            '_': 'LabeledPrice',
            'label': self.label,
            'amount': self.amount,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.label))
        buf.write(struct.pack('<q', self.amount))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_label = reader.tgread_string()
        _args['label'] = _val_label
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        return cls(**_args)


class LangPackDifference(TLObject):
    """TL type: langPackDifference"""
    CONSTRUCTOR_ID = 0xf385c1f6
    SUBCLASS_OF_ID = 0x52662d55

    def __init__(self, lang_code: str, from_version: int, version: int, strings: List['TypeLangPackString']):
        self.lang_code = lang_code
        self.from_version = from_version
        self.version = version
        self.strings = strings

    def to_dict(self):
        return {
            '_': 'LangPackDifference',
            'lang_code': self.lang_code,
            'from_version': self.from_version,
            'version': self.version,
            'strings': self.strings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.lang_code))
        buf.write(struct.pack('<i', self.from_version))
        buf.write(struct.pack('<i', self.version))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.strings)))
        for item in self.strings:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        _val_from_version = reader.read_int()
        _args['from_version'] = _val_from_version
        _val_version = reader.read_int()
        _args['version'] = _val_version
        reader.read_int(signed=False)  # skip vector id
        _count_strings = reader.read_int()
        _list_strings = []
        for _ in range(_count_strings):
            _item_strings = reader.tgread_object()
            _list_strings.append(_item_strings)
        _args['strings'] = _list_strings
        return cls(**_args)


class LangPackLanguage(TLObject):
    """TL type: langPackLanguage"""
    CONSTRUCTOR_ID = 0xeeca5ce3
    SUBCLASS_OF_ID = 0xabac89b7

    def __init__(self, name: str, native_name: str, lang_code: str, plural_code: str, strings_count: int, translated_count: int, translations_url: str, official: Optional[bool] = None, rtl: Optional[bool] = None, beta: Optional[bool] = None, base_lang_code: Optional[str] = None):
        self.name = name
        self.native_name = native_name
        self.lang_code = lang_code
        self.plural_code = plural_code
        self.strings_count = strings_count
        self.translated_count = translated_count
        self.translations_url = translations_url
        self.official = official
        self.rtl = rtl
        self.beta = beta
        self.base_lang_code = base_lang_code

    def to_dict(self):
        return {
            '_': 'LangPackLanguage',
            'name': self.name,
            'native_name': self.native_name,
            'lang_code': self.lang_code,
            'plural_code': self.plural_code,
            'strings_count': self.strings_count,
            'translated_count': self.translated_count,
            'translations_url': self.translations_url,
            'official': self.official,
            'rtl': self.rtl,
            'beta': self.beta,
            'base_lang_code': self.base_lang_code,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.official:
            flags |= (1 << 0)
        if self.rtl:
            flags |= (1 << 2)
        if self.beta:
            flags |= (1 << 3)
        if self.base_lang_code is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.name))
        buf.write(TLObject.serialize_bytes(self.native_name))
        buf.write(TLObject.serialize_bytes(self.lang_code))
        buf.write(TLObject.serialize_bytes(self.plural_code))
        buf.write(struct.pack('<i', self.strings_count))
        buf.write(struct.pack('<i', self.translated_count))
        buf.write(TLObject.serialize_bytes(self.translations_url))
        if self.base_lang_code is not None:
            buf.write(TLObject.serialize_bytes(self.base_lang_code))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['official'] = bool(flags & (1 << 0))
        _args['rtl'] = bool(flags & (1 << 2))
        _args['beta'] = bool(flags & (1 << 3))
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        _val_native_name = reader.tgread_string()
        _args['native_name'] = _val_native_name
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        if flags & (1 << 1):
            _val_base_lang_code = reader.tgread_string()
            _args['base_lang_code'] = _val_base_lang_code
        else:
            _args['base_lang_code'] = None
        _val_plural_code = reader.tgread_string()
        _args['plural_code'] = _val_plural_code
        _val_strings_count = reader.read_int()
        _args['strings_count'] = _val_strings_count
        _val_translated_count = reader.read_int()
        _args['translated_count'] = _val_translated_count
        _val_translations_url = reader.tgread_string()
        _args['translations_url'] = _val_translations_url
        return cls(**_args)


class LangPackString(TLObject):
    """TL type: langPackString"""
    CONSTRUCTOR_ID = 0xcad181f6
    SUBCLASS_OF_ID = 0xdc179ab9

    def __init__(self, key: str, value: str):
        self.key = key
        self.value = value

    def to_dict(self):
        return {
            '_': 'LangPackString',
            'key': self.key,
            'value': self.value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.key))
        buf.write(TLObject.serialize_bytes(self.value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_key = reader.tgread_string()
        _args['key'] = _val_key
        _val_value = reader.tgread_string()
        _args['value'] = _val_value
        return cls(**_args)


class LangPackStringDeleted(TLObject):
    """TL type: langPackStringDeleted"""
    CONSTRUCTOR_ID = 0x2979eeb2
    SUBCLASS_OF_ID = 0xdc179ab9

    def __init__(self, key: str):
        self.key = key

    def to_dict(self):
        return {
            '_': 'LangPackStringDeleted',
            'key': self.key,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.key))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_key = reader.tgread_string()
        _args['key'] = _val_key
        return cls(**_args)


class LangPackStringPluralized(TLObject):
    """TL type: langPackStringPluralized"""
    CONSTRUCTOR_ID = 0x6c47ac9f
    SUBCLASS_OF_ID = 0xdc179ab9

    def __init__(self, key: str, other_value: str, zero_value: Optional[str] = None, one_value: Optional[str] = None, two_value: Optional[str] = None, few_value: Optional[str] = None, many_value: Optional[str] = None):
        self.key = key
        self.other_value = other_value
        self.zero_value = zero_value
        self.one_value = one_value
        self.two_value = two_value
        self.few_value = few_value
        self.many_value = many_value

    def to_dict(self):
        return {
            '_': 'LangPackStringPluralized',
            'key': self.key,
            'other_value': self.other_value,
            'zero_value': self.zero_value,
            'one_value': self.one_value,
            'two_value': self.two_value,
            'few_value': self.few_value,
            'many_value': self.many_value,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.zero_value is not None:
            flags |= (1 << 0)
        if self.one_value is not None:
            flags |= (1 << 1)
        if self.two_value is not None:
            flags |= (1 << 2)
        if self.few_value is not None:
            flags |= (1 << 3)
        if self.many_value is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.key))
        buf.write(TLObject.serialize_bytes(self.other_value))
        if self.zero_value is not None:
            buf.write(TLObject.serialize_bytes(self.zero_value))
        if self.one_value is not None:
            buf.write(TLObject.serialize_bytes(self.one_value))
        if self.two_value is not None:
            buf.write(TLObject.serialize_bytes(self.two_value))
        if self.few_value is not None:
            buf.write(TLObject.serialize_bytes(self.few_value))
        if self.many_value is not None:
            buf.write(TLObject.serialize_bytes(self.many_value))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_key = reader.tgread_string()
        _args['key'] = _val_key
        if flags & (1 << 0):
            _val_zero_value = reader.tgread_string()
            _args['zero_value'] = _val_zero_value
        else:
            _args['zero_value'] = None
        if flags & (1 << 1):
            _val_one_value = reader.tgread_string()
            _args['one_value'] = _val_one_value
        else:
            _args['one_value'] = None
        if flags & (1 << 2):
            _val_two_value = reader.tgread_string()
            _args['two_value'] = _val_two_value
        else:
            _args['two_value'] = None
        if flags & (1 << 3):
            _val_few_value = reader.tgread_string()
            _args['few_value'] = _val_few_value
        else:
            _args['few_value'] = None
        if flags & (1 << 4):
            _val_many_value = reader.tgread_string()
            _args['many_value'] = _val_many_value
        else:
            _args['many_value'] = None
        _val_other_value = reader.tgread_string()
        _args['other_value'] = _val_other_value
        return cls(**_args)


class MaskCoords(TLObject):
    """TL type: maskCoords"""
    CONSTRUCTOR_ID = 0xaed6dbb2
    SUBCLASS_OF_ID = 0x06bbb2fd

    def __init__(self, n: int, x: float, y: float, zoom: float):
        self.n = n
        self.x = x
        self.y = y
        self.zoom = zoom

    def to_dict(self):
        return {
            '_': 'MaskCoords',
            'n': self.n,
            'x': self.x,
            'y': self.y,
            'zoom': self.zoom,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.n))
        buf.write(struct.pack('<d', self.x))
        buf.write(struct.pack('<d', self.y))
        buf.write(struct.pack('<d', self.zoom))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_n = reader.read_int()
        _args['n'] = _val_n
        _val_x = reader.read_double()
        _args['x'] = _val_x
        _val_y = reader.read_double()
        _args['y'] = _val_y
        _val_zoom = reader.read_double()
        _args['zoom'] = _val_zoom
        return cls(**_args)


class MediaAreaChannelPost(TLObject):
    """TL type: mediaAreaChannelPost"""
    CONSTRUCTOR_ID = 0x770416af
    SUBCLASS_OF_ID = 0xf36d7bf2

    def __init__(self, coordinates: 'TypeMediaAreaCoordinates', channel_id: int, msg_id: int):
        self.coordinates = coordinates
        self.channel_id = channel_id
        self.msg_id = msg_id

    def to_dict(self):
        return {
            '_': 'MediaAreaChannelPost',
            'coordinates': self.coordinates,
            'channel_id': self.channel_id,
            'msg_id': self.msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.coordinates))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', self.msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_coordinates = reader.tgread_object()
        _args['coordinates'] = _val_coordinates
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        return cls(**_args)


class MediaAreaCoordinates(TLObject):
    """TL type: mediaAreaCoordinates"""
    CONSTRUCTOR_ID = 0xcfc9e002
    SUBCLASS_OF_ID = 0x1d448c39

    def __init__(self, x: float, y: float, w: float, h: float, rotation: float, radius: Optional[float] = None):
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.rotation = rotation
        self.radius = radius

    def to_dict(self):
        return {
            '_': 'MediaAreaCoordinates',
            'x': self.x,
            'y': self.y,
            'w': self.w,
            'h': self.h,
            'rotation': self.rotation,
            'radius': self.radius,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.radius is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<d', self.x))
        buf.write(struct.pack('<d', self.y))
        buf.write(struct.pack('<d', self.w))
        buf.write(struct.pack('<d', self.h))
        buf.write(struct.pack('<d', self.rotation))
        if self.radius is not None:
            buf.write(struct.pack('<d', self.radius))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_x = reader.read_double()
        _args['x'] = _val_x
        _val_y = reader.read_double()
        _args['y'] = _val_y
        _val_w = reader.read_double()
        _args['w'] = _val_w
        _val_h = reader.read_double()
        _args['h'] = _val_h
        _val_rotation = reader.read_double()
        _args['rotation'] = _val_rotation
        if flags & (1 << 0):
            _val_radius = reader.read_double()
            _args['radius'] = _val_radius
        else:
            _args['radius'] = None
        return cls(**_args)


class MediaAreaGeoPoint(TLObject):
    """TL type: mediaAreaGeoPoint"""
    CONSTRUCTOR_ID = 0xcad5452d
    SUBCLASS_OF_ID = 0xf36d7bf2

    def __init__(self, coordinates: 'TypeMediaAreaCoordinates', geo: 'TypeGeoPoint', address: Optional['TypeGeoPointAddress'] = None):
        self.coordinates = coordinates
        self.geo = geo
        self.address = address

    def to_dict(self):
        return {
            '_': 'MediaAreaGeoPoint',
            'coordinates': self.coordinates,
            'geo': self.geo,
            'address': self.address,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.address is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.coordinates))
        buf.write(bytes(self.geo))
        if self.address is not None:
            buf.write(bytes(self.address))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_coordinates = reader.tgread_object()
        _args['coordinates'] = _val_coordinates
        _val_geo = reader.tgread_object()
        _args['geo'] = _val_geo
        if flags & (1 << 0):
            _val_address = reader.tgread_object()
            _args['address'] = _val_address
        else:
            _args['address'] = None
        return cls(**_args)


class MediaAreaStarGift(TLObject):
    """TL type: mediaAreaStarGift"""
    CONSTRUCTOR_ID = 0x5787686d
    SUBCLASS_OF_ID = 0xf36d7bf2

    def __init__(self, coordinates: 'TypeMediaAreaCoordinates', slug: str):
        self.coordinates = coordinates
        self.slug = slug

    def to_dict(self):
        return {
            '_': 'MediaAreaStarGift',
            'coordinates': self.coordinates,
            'slug': self.slug,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.coordinates))
        buf.write(TLObject.serialize_bytes(self.slug))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_coordinates = reader.tgread_object()
        _args['coordinates'] = _val_coordinates
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        return cls(**_args)


class MediaAreaSuggestedReaction(TLObject):
    """TL type: mediaAreaSuggestedReaction"""
    CONSTRUCTOR_ID = 0x14455871
    SUBCLASS_OF_ID = 0xf36d7bf2

    def __init__(self, coordinates: 'TypeMediaAreaCoordinates', reaction: 'TypeReaction', dark: Optional[bool] = None, flipped: Optional[bool] = None):
        self.coordinates = coordinates
        self.reaction = reaction
        self.dark = dark
        self.flipped = flipped

    def to_dict(self):
        return {
            '_': 'MediaAreaSuggestedReaction',
            'coordinates': self.coordinates,
            'reaction': self.reaction,
            'dark': self.dark,
            'flipped': self.flipped,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.dark:
            flags |= (1 << 0)
        if self.flipped:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.coordinates))
        buf.write(bytes(self.reaction))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['dark'] = bool(flags & (1 << 0))
        _args['flipped'] = bool(flags & (1 << 1))
        _val_coordinates = reader.tgread_object()
        _args['coordinates'] = _val_coordinates
        _val_reaction = reader.tgread_object()
        _args['reaction'] = _val_reaction
        return cls(**_args)


class MediaAreaUrl(TLObject):
    """TL type: mediaAreaUrl"""
    CONSTRUCTOR_ID = 0x37381085
    SUBCLASS_OF_ID = 0xf36d7bf2

    def __init__(self, coordinates: 'TypeMediaAreaCoordinates', url: str):
        self.coordinates = coordinates
        self.url = url

    def to_dict(self):
        return {
            '_': 'MediaAreaUrl',
            'coordinates': self.coordinates,
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.coordinates))
        buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_coordinates = reader.tgread_object()
        _args['coordinates'] = _val_coordinates
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class MediaAreaVenue(TLObject):
    """TL type: mediaAreaVenue"""
    CONSTRUCTOR_ID = 0xbe82db9c
    SUBCLASS_OF_ID = 0xf36d7bf2

    def __init__(self, coordinates: 'TypeMediaAreaCoordinates', geo: 'TypeGeoPoint', title: str, address: str, provider: str, venue_id: str, venue_type: str):
        self.coordinates = coordinates
        self.geo = geo
        self.title = title
        self.address = address
        self.provider = provider
        self.venue_id = venue_id
        self.venue_type = venue_type

    def to_dict(self):
        return {
            '_': 'MediaAreaVenue',
            'coordinates': self.coordinates,
            'geo': self.geo,
            'title': self.title,
            'address': self.address,
            'provider': self.provider,
            'venue_id': self.venue_id,
            'venue_type': self.venue_type,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.coordinates))
        buf.write(bytes(self.geo))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.address))
        buf.write(TLObject.serialize_bytes(self.provider))
        buf.write(TLObject.serialize_bytes(self.venue_id))
        buf.write(TLObject.serialize_bytes(self.venue_type))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_coordinates = reader.tgread_object()
        _args['coordinates'] = _val_coordinates
        _val_geo = reader.tgread_object()
        _args['geo'] = _val_geo
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_address = reader.tgread_string()
        _args['address'] = _val_address
        _val_provider = reader.tgread_string()
        _args['provider'] = _val_provider
        _val_venue_id = reader.tgread_string()
        _args['venue_id'] = _val_venue_id
        _val_venue_type = reader.tgread_string()
        _args['venue_type'] = _val_venue_type
        return cls(**_args)


class MediaAreaWeather(TLObject):
    """TL type: mediaAreaWeather"""
    CONSTRUCTOR_ID = 0x49a6549c
    SUBCLASS_OF_ID = 0xf36d7bf2

    def __init__(self, coordinates: 'TypeMediaAreaCoordinates', emoji: str, temperature_c: float, color: int):
        self.coordinates = coordinates
        self.emoji = emoji
        self.temperature_c = temperature_c
        self.color = color

    def to_dict(self):
        return {
            '_': 'MediaAreaWeather',
            'coordinates': self.coordinates,
            'emoji': self.emoji,
            'temperature_c': self.temperature_c,
            'color': self.color,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.coordinates))
        buf.write(TLObject.serialize_bytes(self.emoji))
        buf.write(struct.pack('<d', self.temperature_c))
        buf.write(struct.pack('<i', self.color))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_coordinates = reader.tgread_object()
        _args['coordinates'] = _val_coordinates
        _val_emoji = reader.tgread_string()
        _args['emoji'] = _val_emoji
        _val_temperature_c = reader.read_double()
        _args['temperature_c'] = _val_temperature_c
        _val_color = reader.read_int()
        _args['color'] = _val_color
        return cls(**_args)


class Message(TLObject):
    """TL type: message"""
    CONSTRUCTOR_ID = 0x9cb490e9
    SUBCLASS_OF_ID = 0x790009e3

    def __init__(self, id: int, peer_id: 'TypePeer', date: Optional[datetime], message: str, out: Optional[bool] = None, mentioned: Optional[bool] = None, media_unread: Optional[bool] = None, silent: Optional[bool] = None, post: Optional[bool] = None, from_scheduled: Optional[bool] = None, legacy: Optional[bool] = None, edit_hide: Optional[bool] = None, pinned: Optional[bool] = None, noforwards: Optional[bool] = None, invert_media: Optional[bool] = None, offline: Optional[bool] = None, video_processing_pending: Optional[bool] = None, paid_suggested_post_stars: Optional[bool] = None, paid_suggested_post_ton: Optional[bool] = None, from_id: Optional['TypePeer'] = None, from_boosts_applied: Optional[int] = None, saved_peer_id: Optional['TypePeer'] = None, fwd_from: Optional['TypeMessageFwdHeader'] = None, via_bot_id: Optional[int] = None, via_business_bot_id: Optional[int] = None, reply_to: Optional['TypeMessageReplyHeader'] = None, media: Optional['TypeMessageMedia'] = None, reply_markup: Optional['TypeReplyMarkup'] = None, entities: Optional[List['TypeMessageEntity']] = None, views: Optional[int] = None, forwards: Optional[int] = None, replies: Optional['TypeMessageReplies'] = None, edit_date: Optional[datetime] = None, post_author: Optional[str] = None, grouped_id: Optional[int] = None, reactions: Optional['TypeMessageReactions'] = None, restriction_reason: Optional[List['TypeRestrictionReason']] = None, ttl_period: Optional[int] = None, quick_reply_shortcut_id: Optional[int] = None, effect: Optional[int] = None, factcheck: Optional['TypeFactCheck'] = None, report_delivery_until_date: Optional[datetime] = None, paid_message_stars: Optional[int] = None, suggested_post: Optional['TypeSuggestedPost'] = None, schedule_repeat_period: Optional[int] = None, summary_from_language: Optional[str] = None):
        self.id = id
        self.peer_id = peer_id
        self.date = date
        self.message = message
        self.out = out
        self.mentioned = mentioned
        self.media_unread = media_unread
        self.silent = silent
        self.post = post
        self.from_scheduled = from_scheduled
        self.legacy = legacy
        self.edit_hide = edit_hide
        self.pinned = pinned
        self.noforwards = noforwards
        self.invert_media = invert_media
        self.offline = offline
        self.video_processing_pending = video_processing_pending
        self.paid_suggested_post_stars = paid_suggested_post_stars
        self.paid_suggested_post_ton = paid_suggested_post_ton
        self.from_id = from_id
        self.from_boosts_applied = from_boosts_applied
        self.saved_peer_id = saved_peer_id
        self.fwd_from = fwd_from
        self.via_bot_id = via_bot_id
        self.via_business_bot_id = via_business_bot_id
        self.reply_to = reply_to
        self.media = media
        self.reply_markup = reply_markup
        self.entities = entities
        self.views = views
        self.forwards = forwards
        self.replies = replies
        self.edit_date = edit_date
        self.post_author = post_author
        self.grouped_id = grouped_id
        self.reactions = reactions
        self.restriction_reason = restriction_reason
        self.ttl_period = ttl_period
        self.quick_reply_shortcut_id = quick_reply_shortcut_id
        self.effect = effect
        self.factcheck = factcheck
        self.report_delivery_until_date = report_delivery_until_date
        self.paid_message_stars = paid_message_stars
        self.suggested_post = suggested_post
        self.schedule_repeat_period = schedule_repeat_period
        self.summary_from_language = summary_from_language

    def to_dict(self):
        return {
            '_': 'Message',
            'id': self.id,
            'peer_id': self.peer_id,
            'date': self.date,
            'message': self.message,
            'out': self.out,
            'mentioned': self.mentioned,
            'media_unread': self.media_unread,
            'silent': self.silent,
            'post': self.post,
            'from_scheduled': self.from_scheduled,
            'legacy': self.legacy,
            'edit_hide': self.edit_hide,
            'pinned': self.pinned,
            'noforwards': self.noforwards,
            'invert_media': self.invert_media,
            'offline': self.offline,
            'video_processing_pending': self.video_processing_pending,
            'paid_suggested_post_stars': self.paid_suggested_post_stars,
            'paid_suggested_post_ton': self.paid_suggested_post_ton,
            'from_id': self.from_id,
            'from_boosts_applied': self.from_boosts_applied,
            'saved_peer_id': self.saved_peer_id,
            'fwd_from': self.fwd_from,
            'via_bot_id': self.via_bot_id,
            'via_business_bot_id': self.via_business_bot_id,
            'reply_to': self.reply_to,
            'media': self.media,
            'reply_markup': self.reply_markup,
            'entities': self.entities,
            'views': self.views,
            'forwards': self.forwards,
            'replies': self.replies,
            'edit_date': self.edit_date,
            'post_author': self.post_author,
            'grouped_id': self.grouped_id,
            'reactions': self.reactions,
            'restriction_reason': self.restriction_reason,
            'ttl_period': self.ttl_period,
            'quick_reply_shortcut_id': self.quick_reply_shortcut_id,
            'effect': self.effect,
            'factcheck': self.factcheck,
            'report_delivery_until_date': self.report_delivery_until_date,
            'paid_message_stars': self.paid_message_stars,
            'suggested_post': self.suggested_post,
            'schedule_repeat_period': self.schedule_repeat_period,
            'summary_from_language': self.summary_from_language,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.out:
            flags |= (1 << 1)
        if self.mentioned:
            flags |= (1 << 4)
        if self.media_unread:
            flags |= (1 << 5)
        if self.silent:
            flags |= (1 << 13)
        if self.post:
            flags |= (1 << 14)
        if self.from_scheduled:
            flags |= (1 << 18)
        if self.legacy:
            flags |= (1 << 19)
        if self.edit_hide:
            flags |= (1 << 21)
        if self.pinned:
            flags |= (1 << 24)
        if self.noforwards:
            flags |= (1 << 26)
        if self.invert_media:
            flags |= (1 << 27)
        if self.from_id is not None:
            flags |= (1 << 8)
        if self.from_boosts_applied is not None:
            flags |= (1 << 29)
        if self.saved_peer_id is not None:
            flags |= (1 << 28)
        if self.fwd_from is not None:
            flags |= (1 << 2)
        if self.via_bot_id is not None:
            flags |= (1 << 11)
        if self.reply_to is not None:
            flags |= (1 << 3)
        if self.media is not None:
            flags |= (1 << 9)
        if self.reply_markup is not None:
            flags |= (1 << 6)
        if self.entities is not None:
            flags |= (1 << 7)
        if self.forwards is not None:
            flags |= (1 << 10)
        if self.replies is not None:
            flags |= (1 << 23)
        if self.edit_date is not None:
            flags |= (1 << 15)
        if self.post_author is not None:
            flags |= (1 << 16)
        if self.grouped_id is not None:
            flags |= (1 << 17)
        if self.reactions is not None:
            flags |= (1 << 20)
        if self.restriction_reason is not None:
            flags |= (1 << 22)
        if self.ttl_period is not None:
            flags |= (1 << 25)
        if self.quick_reply_shortcut_id is not None:
            flags |= (1 << 30)
        flags2 = 0
        if self.offline:
            flags2 |= (1 << 1)
        if self.video_processing_pending:
            flags2 |= (1 << 4)
        if self.paid_suggested_post_stars:
            flags2 |= (1 << 8)
        if self.paid_suggested_post_ton:
            flags2 |= (1 << 9)
        if self.via_business_bot_id is not None:
            flags2 |= (1 << 0)
        if self.effect is not None:
            flags2 |= (1 << 2)
        if self.factcheck is not None:
            flags2 |= (1 << 3)
        if self.report_delivery_until_date is not None:
            flags2 |= (1 << 5)
        if self.paid_message_stars is not None:
            flags2 |= (1 << 6)
        if self.suggested_post is not None:
            flags2 |= (1 << 7)
        if self.schedule_repeat_period is not None:
            flags2 |= (1 << 10)
        if self.summary_from_language is not None:
            flags2 |= (1 << 11)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<I', flags2))
        buf.write(struct.pack('<i', self.id))
        buf.write(bytes(self.peer_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(TLObject.serialize_bytes(self.message))
        if self.from_id is not None:
            buf.write(bytes(self.from_id))
        if self.from_boosts_applied is not None:
            buf.write(struct.pack('<i', self.from_boosts_applied))
        if self.saved_peer_id is not None:
            buf.write(bytes(self.saved_peer_id))
        if self.fwd_from is not None:
            buf.write(bytes(self.fwd_from))
        if self.via_bot_id is not None:
            buf.write(struct.pack('<q', self.via_bot_id))
        if self.via_business_bot_id is not None:
            buf.write(struct.pack('<q', self.via_business_bot_id))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        if self.media is not None:
            buf.write(bytes(self.media))
        if self.reply_markup is not None:
            buf.write(bytes(self.reply_markup))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.views is not None:
            buf.write(struct.pack('<i', self.views))
        if self.forwards is not None:
            buf.write(struct.pack('<i', self.forwards))
        if self.replies is not None:
            buf.write(bytes(self.replies))
        if self.edit_date is not None:
            buf.write(struct.pack('<i', self.edit_date))
        if self.post_author is not None:
            buf.write(TLObject.serialize_bytes(self.post_author))
        if self.grouped_id is not None:
            buf.write(struct.pack('<q', self.grouped_id))
        if self.reactions is not None:
            buf.write(bytes(self.reactions))
        if self.restriction_reason is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.restriction_reason)))
            for item in self.restriction_reason:
                buf.write(bytes(self.item))
        if self.ttl_period is not None:
            buf.write(struct.pack('<i', self.ttl_period))
        if self.quick_reply_shortcut_id is not None:
            buf.write(struct.pack('<i', self.quick_reply_shortcut_id))
        if self.effect is not None:
            buf.write(struct.pack('<q', self.effect))
        if self.factcheck is not None:
            buf.write(bytes(self.factcheck))
        if self.report_delivery_until_date is not None:
            buf.write(struct.pack('<i', self.report_delivery_until_date))
        if self.paid_message_stars is not None:
            buf.write(struct.pack('<q', self.paid_message_stars))
        if self.suggested_post is not None:
            buf.write(bytes(self.suggested_post))
        if self.schedule_repeat_period is not None:
            buf.write(struct.pack('<i', self.schedule_repeat_period))
        if self.summary_from_language is not None:
            buf.write(TLObject.serialize_bytes(self.summary_from_language))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['out'] = bool(flags & (1 << 1))
        _args['mentioned'] = bool(flags & (1 << 4))
        _args['media_unread'] = bool(flags & (1 << 5))
        _args['silent'] = bool(flags & (1 << 13))
        _args['post'] = bool(flags & (1 << 14))
        _args['from_scheduled'] = bool(flags & (1 << 18))
        _args['legacy'] = bool(flags & (1 << 19))
        _args['edit_hide'] = bool(flags & (1 << 21))
        _args['pinned'] = bool(flags & (1 << 24))
        _args['noforwards'] = bool(flags & (1 << 26))
        _args['invert_media'] = bool(flags & (1 << 27))
        flags2 = reader.read_int(signed=False)
        _args['offline'] = bool(flags2 & (1 << 1))
        _args['video_processing_pending'] = bool(flags2 & (1 << 4))
        _args['paid_suggested_post_stars'] = bool(flags2 & (1 << 8))
        _args['paid_suggested_post_ton'] = bool(flags2 & (1 << 9))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        if flags & (1 << 8):
            _val_from_id = reader.tgread_object()
            _args['from_id'] = _val_from_id
        else:
            _args['from_id'] = None
        if flags & (1 << 29):
            _val_from_boosts_applied = reader.read_int()
            _args['from_boosts_applied'] = _val_from_boosts_applied
        else:
            _args['from_boosts_applied'] = None
        _val_peer_id = reader.tgread_object()
        _args['peer_id'] = _val_peer_id
        if flags & (1 << 28):
            _val_saved_peer_id = reader.tgread_object()
            _args['saved_peer_id'] = _val_saved_peer_id
        else:
            _args['saved_peer_id'] = None
        if flags & (1 << 2):
            _val_fwd_from = reader.tgread_object()
            _args['fwd_from'] = _val_fwd_from
        else:
            _args['fwd_from'] = None
        if flags & (1 << 11):
            _val_via_bot_id = reader.read_long()
            _args['via_bot_id'] = _val_via_bot_id
        else:
            _args['via_bot_id'] = None
        if flags2 & (1 << 0):
            _val_via_business_bot_id = reader.read_long()
            _args['via_business_bot_id'] = _val_via_business_bot_id
        else:
            _args['via_business_bot_id'] = None
        if flags & (1 << 3):
            _val_reply_to = reader.tgread_object()
            _args['reply_to'] = _val_reply_to
        else:
            _args['reply_to'] = None
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 9):
            _val_media = reader.tgread_object()
            _args['media'] = _val_media
        else:
            _args['media'] = None
        if flags & (1 << 6):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        if flags & (1 << 7):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 10):
            _val_views = reader.read_int()
            _args['views'] = _val_views
        else:
            _args['views'] = None
        if flags & (1 << 10):
            _val_forwards = reader.read_int()
            _args['forwards'] = _val_forwards
        else:
            _args['forwards'] = None
        if flags & (1 << 23):
            _val_replies = reader.tgread_object()
            _args['replies'] = _val_replies
        else:
            _args['replies'] = None
        if flags & (1 << 15):
            _val_edit_date = reader.read_int()
            _args['edit_date'] = _val_edit_date
        else:
            _args['edit_date'] = None
        if flags & (1 << 16):
            _val_post_author = reader.tgread_string()
            _args['post_author'] = _val_post_author
        else:
            _args['post_author'] = None
        if flags & (1 << 17):
            _val_grouped_id = reader.read_long()
            _args['grouped_id'] = _val_grouped_id
        else:
            _args['grouped_id'] = None
        if flags & (1 << 20):
            _val_reactions = reader.tgread_object()
            _args['reactions'] = _val_reactions
        else:
            _args['reactions'] = None
        if flags & (1 << 22):
            reader.read_int(signed=False)  # skip vector id
            _count_restriction_reason = reader.read_int()
            _list_restriction_reason = []
            for _ in range(_count_restriction_reason):
                _item_restriction_reason = reader.tgread_object()
                _list_restriction_reason.append(_item_restriction_reason)
            _args['restriction_reason'] = _list_restriction_reason
        else:
            _args['restriction_reason'] = None
        if flags & (1 << 25):
            _val_ttl_period = reader.read_int()
            _args['ttl_period'] = _val_ttl_period
        else:
            _args['ttl_period'] = None
        if flags & (1 << 30):
            _val_quick_reply_shortcut_id = reader.read_int()
            _args['quick_reply_shortcut_id'] = _val_quick_reply_shortcut_id
        else:
            _args['quick_reply_shortcut_id'] = None
        if flags2 & (1 << 2):
            _val_effect = reader.read_long()
            _args['effect'] = _val_effect
        else:
            _args['effect'] = None
        if flags2 & (1 << 3):
            _val_factcheck = reader.tgread_object()
            _args['factcheck'] = _val_factcheck
        else:
            _args['factcheck'] = None
        if flags2 & (1 << 5):
            _val_report_delivery_until_date = reader.read_int()
            _args['report_delivery_until_date'] = _val_report_delivery_until_date
        else:
            _args['report_delivery_until_date'] = None
        if flags2 & (1 << 6):
            _val_paid_message_stars = reader.read_long()
            _args['paid_message_stars'] = _val_paid_message_stars
        else:
            _args['paid_message_stars'] = None
        if flags2 & (1 << 7):
            _val_suggested_post = reader.tgread_object()
            _args['suggested_post'] = _val_suggested_post
        else:
            _args['suggested_post'] = None
        if flags2 & (1 << 10):
            _val_schedule_repeat_period = reader.read_int()
            _args['schedule_repeat_period'] = _val_schedule_repeat_period
        else:
            _args['schedule_repeat_period'] = None
        if flags2 & (1 << 11):
            _val_summary_from_language = reader.tgread_string()
            _args['summary_from_language'] = _val_summary_from_language
        else:
            _args['summary_from_language'] = None
        return cls(**_args)


class MessageActionBoostApply(TLObject):
    """TL type: messageActionBoostApply"""
    CONSTRUCTOR_ID = 0xcc02aa6d
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, boosts: int):
        self.boosts = boosts

    def to_dict(self):
        return {
            '_': 'MessageActionBoostApply',
            'boosts': self.boosts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.boosts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_boosts = reader.read_int()
        _args['boosts'] = _val_boosts
        return cls(**_args)


class MessageActionBotAllowed(TLObject):
    """TL type: messageActionBotAllowed"""
    CONSTRUCTOR_ID = 0xc516d679
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, attach_menu: Optional[bool] = None, from_request: Optional[bool] = None, domain: Optional[str] = None, app: Optional['TypeBotApp'] = None):
        self.attach_menu = attach_menu
        self.from_request = from_request
        self.domain = domain
        self.app = app

    def to_dict(self):
        return {
            '_': 'MessageActionBotAllowed',
            'attach_menu': self.attach_menu,
            'from_request': self.from_request,
            'domain': self.domain,
            'app': self.app,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.attach_menu:
            flags |= (1 << 1)
        if self.from_request:
            flags |= (1 << 3)
        if self.domain is not None:
            flags |= (1 << 0)
        if self.app is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.domain is not None:
            buf.write(TLObject.serialize_bytes(self.domain))
        if self.app is not None:
            buf.write(bytes(self.app))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['attach_menu'] = bool(flags & (1 << 1))
        _args['from_request'] = bool(flags & (1 << 3))
        if flags & (1 << 0):
            _val_domain = reader.tgread_string()
            _args['domain'] = _val_domain
        else:
            _args['domain'] = None
        if flags & (1 << 2):
            _val_app = reader.tgread_object()
            _args['app'] = _val_app
        else:
            _args['app'] = None
        return cls(**_args)


class MessageActionChangeCreator(TLObject):
    """TL type: messageActionChangeCreator"""
    CONSTRUCTOR_ID = 0xe188503b
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, new_creator_id: int):
        self.new_creator_id = new_creator_id

    def to_dict(self):
        return {
            '_': 'MessageActionChangeCreator',
            'new_creator_id': self.new_creator_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.new_creator_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_new_creator_id = reader.read_long()
        _args['new_creator_id'] = _val_new_creator_id
        return cls(**_args)


class MessageActionChannelCreate(TLObject):
    """TL type: messageActionChannelCreate"""
    CONSTRUCTOR_ID = 0x95d2ac92
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, title: str):
        self.title = title

    def to_dict(self):
        return {
            '_': 'MessageActionChannelCreate',
            'title': self.title,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.title))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        return cls(**_args)


class MessageActionChannelMigrateFrom(TLObject):
    """TL type: messageActionChannelMigrateFrom"""
    CONSTRUCTOR_ID = 0xea3948e9
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, title: str, chat_id: int):
        self.title = title
        self.chat_id = chat_id

    def to_dict(self):
        return {
            '_': 'MessageActionChannelMigrateFrom',
            'title': self.title,
            'chat_id': self.chat_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(struct.pack('<q', self.chat_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        return cls(**_args)


class MessageActionChatAddUser(TLObject):
    """TL type: messageActionChatAddUser"""
    CONSTRUCTOR_ID = 0x15cefd00
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, users: List[int]):
        self.users = users

    def to_dict(self):
        return {
            '_': 'MessageActionChatAddUser',
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.read_long()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class MessageActionChatCreate(TLObject):
    """TL type: messageActionChatCreate"""
    CONSTRUCTOR_ID = 0xbd47cbad
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, title: str, users: List[int]):
        self.title = title
        self.users = users

    def to_dict(self):
        return {
            '_': 'MessageActionChatCreate',
            'title': self.title,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.read_long()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class MessageActionChatDeletePhoto(TLObject):
    """TL type: messageActionChatDeletePhoto"""
    CONSTRUCTOR_ID = 0x95e3fbef
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageActionChatDeletePhoto',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageActionChatDeleteUser(TLObject):
    """TL type: messageActionChatDeleteUser"""
    CONSTRUCTOR_ID = 0xa43f30cc
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, user_id: int):
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'MessageActionChatDeleteUser',
            'user_id': self.user_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class MessageActionChatEditPhoto(TLObject):
    """TL type: messageActionChatEditPhoto"""
    CONSTRUCTOR_ID = 0x7fcb13a8
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, photo: 'TypePhoto'):
        self.photo = photo

    def to_dict(self):
        return {
            '_': 'MessageActionChatEditPhoto',
            'photo': self.photo,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.photo))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_photo = reader.tgread_object()
        _args['photo'] = _val_photo
        return cls(**_args)


class MessageActionChatEditTitle(TLObject):
    """TL type: messageActionChatEditTitle"""
    CONSTRUCTOR_ID = 0xb5a1ce5a
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, title: str):
        self.title = title

    def to_dict(self):
        return {
            '_': 'MessageActionChatEditTitle',
            'title': self.title,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.title))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        return cls(**_args)


class MessageActionChatJoinedByLink(TLObject):
    """TL type: messageActionChatJoinedByLink"""
    CONSTRUCTOR_ID = 0x031224c3
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, inviter_id: int):
        self.inviter_id = inviter_id

    def to_dict(self):
        return {
            '_': 'MessageActionChatJoinedByLink',
            'inviter_id': self.inviter_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.inviter_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_inviter_id = reader.read_long()
        _args['inviter_id'] = _val_inviter_id
        return cls(**_args)


class MessageActionChatJoinedByRequest(TLObject):
    """TL type: messageActionChatJoinedByRequest"""
    CONSTRUCTOR_ID = 0xebbca3cb
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageActionChatJoinedByRequest',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageActionChatMigrateTo(TLObject):
    """TL type: messageActionChatMigrateTo"""
    CONSTRUCTOR_ID = 0xe1037f92
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, channel_id: int):
        self.channel_id = channel_id

    def to_dict(self):
        return {
            '_': 'MessageActionChatMigrateTo',
            'channel_id': self.channel_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        return cls(**_args)


class MessageActionConferenceCall(TLObject):
    """TL type: messageActionConferenceCall"""
    CONSTRUCTOR_ID = 0x2ffe2f7a
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, call_id: int, missed: Optional[bool] = None, active: Optional[bool] = None, video: Optional[bool] = None, duration: Optional[int] = None, other_participants: Optional[List['TypePeer']] = None):
        self.call_id = call_id
        self.missed = missed
        self.active = active
        self.video = video
        self.duration = duration
        self.other_participants = other_participants

    def to_dict(self):
        return {
            '_': 'MessageActionConferenceCall',
            'call_id': self.call_id,
            'missed': self.missed,
            'active': self.active,
            'video': self.video,
            'duration': self.duration,
            'other_participants': self.other_participants,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.missed:
            flags |= (1 << 0)
        if self.active:
            flags |= (1 << 1)
        if self.video:
            flags |= (1 << 4)
        if self.duration is not None:
            flags |= (1 << 2)
        if self.other_participants is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.call_id))
        if self.duration is not None:
            buf.write(struct.pack('<i', self.duration))
        if self.other_participants is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.other_participants)))
            for item in self.other_participants:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['missed'] = bool(flags & (1 << 0))
        _args['active'] = bool(flags & (1 << 1))
        _args['video'] = bool(flags & (1 << 4))
        _val_call_id = reader.read_long()
        _args['call_id'] = _val_call_id
        if flags & (1 << 2):
            _val_duration = reader.read_int()
            _args['duration'] = _val_duration
        else:
            _args['duration'] = None
        if flags & (1 << 3):
            reader.read_int(signed=False)  # skip vector id
            _count_other_participants = reader.read_int()
            _list_other_participants = []
            for _ in range(_count_other_participants):
                _item_other_participants = reader.tgread_object()
                _list_other_participants.append(_item_other_participants)
            _args['other_participants'] = _list_other_participants
        else:
            _args['other_participants'] = None
        return cls(**_args)


class MessageActionContactSignUp(TLObject):
    """TL type: messageActionContactSignUp"""
    CONSTRUCTOR_ID = 0xf3f25f76
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageActionContactSignUp',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageActionCreatedBroadcastList(TLObject):
    """TL type: messageActionCreatedBroadcastList"""
    CONSTRUCTOR_ID = 0x55555557
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageActionCreatedBroadcastList',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageActionCustomAction(TLObject):
    """TL type: messageActionCustomAction"""
    CONSTRUCTOR_ID = 0xfae69f56
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, message: str):
        self.message = message

    def to_dict(self):
        return {
            '_': 'MessageActionCustomAction',
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        return cls(**_args)


class MessageActionEmpty(TLObject):
    """TL type: messageActionEmpty"""
    CONSTRUCTOR_ID = 0xb6aef7b0
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageActionEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageActionGameScore(TLObject):
    """TL type: messageActionGameScore"""
    CONSTRUCTOR_ID = 0x92a72876
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, game_id: int, score: int):
        self.game_id = game_id
        self.score = score

    def to_dict(self):
        return {
            '_': 'MessageActionGameScore',
            'game_id': self.game_id,
            'score': self.score,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.game_id))
        buf.write(struct.pack('<i', self.score))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_game_id = reader.read_long()
        _args['game_id'] = _val_game_id
        _val_score = reader.read_int()
        _args['score'] = _val_score
        return cls(**_args)


class MessageActionGeoProximityReached(TLObject):
    """TL type: messageActionGeoProximityReached"""
    CONSTRUCTOR_ID = 0x98e0d697
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, from_id: 'TypePeer', to_id: 'TypePeer', distance: int):
        self.from_id = from_id
        self.to_id = to_id
        self.distance = distance

    def to_dict(self):
        return {
            '_': 'MessageActionGeoProximityReached',
            'from_id': self.from_id,
            'to_id': self.to_id,
            'distance': self.distance,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.from_id))
        buf.write(bytes(self.to_id))
        buf.write(struct.pack('<i', self.distance))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_from_id = reader.tgread_object()
        _args['from_id'] = _val_from_id
        _val_to_id = reader.tgread_object()
        _args['to_id'] = _val_to_id
        _val_distance = reader.read_int()
        _args['distance'] = _val_distance
        return cls(**_args)


class MessageActionGiftCode(TLObject):
    """TL type: messageActionGiftCode"""
    CONSTRUCTOR_ID = 0x31c48347
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, days: int, slug: str, via_giveaway: Optional[bool] = None, unclaimed: Optional[bool] = None, boost_peer: Optional['TypePeer'] = None, currency: Optional[str] = None, amount: Optional[int] = None, crypto_currency: Optional[str] = None, crypto_amount: Optional[int] = None, message: Optional['TypeTextWithEntities'] = None):
        self.days = days
        self.slug = slug
        self.via_giveaway = via_giveaway
        self.unclaimed = unclaimed
        self.boost_peer = boost_peer
        self.currency = currency
        self.amount = amount
        self.crypto_currency = crypto_currency
        self.crypto_amount = crypto_amount
        self.message = message

    def to_dict(self):
        return {
            '_': 'MessageActionGiftCode',
            'days': self.days,
            'slug': self.slug,
            'via_giveaway': self.via_giveaway,
            'unclaimed': self.unclaimed,
            'boost_peer': self.boost_peer,
            'currency': self.currency,
            'amount': self.amount,
            'crypto_currency': self.crypto_currency,
            'crypto_amount': self.crypto_amount,
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.via_giveaway:
            flags |= (1 << 0)
        if self.unclaimed:
            flags |= (1 << 5)
        if self.boost_peer is not None:
            flags |= (1 << 1)
        if self.amount is not None:
            flags |= (1 << 2)
        if self.crypto_amount is not None:
            flags |= (1 << 3)
        if self.message is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.days))
        buf.write(TLObject.serialize_bytes(self.slug))
        if self.boost_peer is not None:
            buf.write(bytes(self.boost_peer))
        if self.currency is not None:
            buf.write(TLObject.serialize_bytes(self.currency))
        if self.amount is not None:
            buf.write(struct.pack('<q', self.amount))
        if self.crypto_currency is not None:
            buf.write(TLObject.serialize_bytes(self.crypto_currency))
        if self.crypto_amount is not None:
            buf.write(struct.pack('<q', self.crypto_amount))
        if self.message is not None:
            buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['via_giveaway'] = bool(flags & (1 << 0))
        _args['unclaimed'] = bool(flags & (1 << 5))
        if flags & (1 << 1):
            _val_boost_peer = reader.tgread_object()
            _args['boost_peer'] = _val_boost_peer
        else:
            _args['boost_peer'] = None
        _val_days = reader.read_int()
        _args['days'] = _val_days
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        if flags & (1 << 2):
            _val_currency = reader.tgread_string()
            _args['currency'] = _val_currency
        else:
            _args['currency'] = None
        if flags & (1 << 2):
            _val_amount = reader.read_long()
            _args['amount'] = _val_amount
        else:
            _args['amount'] = None
        if flags & (1 << 3):
            _val_crypto_currency = reader.tgread_string()
            _args['crypto_currency'] = _val_crypto_currency
        else:
            _args['crypto_currency'] = None
        if flags & (1 << 3):
            _val_crypto_amount = reader.read_long()
            _args['crypto_amount'] = _val_crypto_amount
        else:
            _args['crypto_amount'] = None
        if flags & (1 << 4):
            _val_message = reader.tgread_object()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        return cls(**_args)


class MessageActionGiftPremium(TLObject):
    """TL type: messageActionGiftPremium"""
    CONSTRUCTOR_ID = 0x48e91302
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, currency: str, amount: int, days: int, crypto_currency: Optional[str] = None, crypto_amount: Optional[int] = None, message: Optional['TypeTextWithEntities'] = None):
        self.currency = currency
        self.amount = amount
        self.days = days
        self.crypto_currency = crypto_currency
        self.crypto_amount = crypto_amount
        self.message = message

    def to_dict(self):
        return {
            '_': 'MessageActionGiftPremium',
            'currency': self.currency,
            'amount': self.amount,
            'days': self.days,
            'crypto_currency': self.crypto_currency,
            'crypto_amount': self.crypto_amount,
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.crypto_amount is not None:
            flags |= (1 << 0)
        if self.message is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        buf.write(struct.pack('<i', self.days))
        if self.crypto_currency is not None:
            buf.write(TLObject.serialize_bytes(self.crypto_currency))
        if self.crypto_amount is not None:
            buf.write(struct.pack('<q', self.crypto_amount))
        if self.message is not None:
            buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        _val_days = reader.read_int()
        _args['days'] = _val_days
        if flags & (1 << 0):
            _val_crypto_currency = reader.tgread_string()
            _args['crypto_currency'] = _val_crypto_currency
        else:
            _args['crypto_currency'] = None
        if flags & (1 << 0):
            _val_crypto_amount = reader.read_long()
            _args['crypto_amount'] = _val_crypto_amount
        else:
            _args['crypto_amount'] = None
        if flags & (1 << 1):
            _val_message = reader.tgread_object()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        return cls(**_args)


class MessageActionGiftStars(TLObject):
    """TL type: messageActionGiftStars"""
    CONSTRUCTOR_ID = 0x45d5b021
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, currency: str, amount: int, stars: int, crypto_currency: Optional[str] = None, crypto_amount: Optional[int] = None, transaction_id: Optional[str] = None):
        self.currency = currency
        self.amount = amount
        self.stars = stars
        self.crypto_currency = crypto_currency
        self.crypto_amount = crypto_amount
        self.transaction_id = transaction_id

    def to_dict(self):
        return {
            '_': 'MessageActionGiftStars',
            'currency': self.currency,
            'amount': self.amount,
            'stars': self.stars,
            'crypto_currency': self.crypto_currency,
            'crypto_amount': self.crypto_amount,
            'transaction_id': self.transaction_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.crypto_amount is not None:
            flags |= (1 << 0)
        if self.transaction_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        buf.write(struct.pack('<q', self.stars))
        if self.crypto_currency is not None:
            buf.write(TLObject.serialize_bytes(self.crypto_currency))
        if self.crypto_amount is not None:
            buf.write(struct.pack('<q', self.crypto_amount))
        if self.transaction_id is not None:
            buf.write(TLObject.serialize_bytes(self.transaction_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        if flags & (1 << 0):
            _val_crypto_currency = reader.tgread_string()
            _args['crypto_currency'] = _val_crypto_currency
        else:
            _args['crypto_currency'] = None
        if flags & (1 << 0):
            _val_crypto_amount = reader.read_long()
            _args['crypto_amount'] = _val_crypto_amount
        else:
            _args['crypto_amount'] = None
        if flags & (1 << 1):
            _val_transaction_id = reader.tgread_string()
            _args['transaction_id'] = _val_transaction_id
        else:
            _args['transaction_id'] = None
        return cls(**_args)


class MessageActionGiftTon(TLObject):
    """TL type: messageActionGiftTon"""
    CONSTRUCTOR_ID = 0xa8a3c699
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, currency: str, amount: int, crypto_currency: str, crypto_amount: int, transaction_id: Optional[str] = None):
        self.currency = currency
        self.amount = amount
        self.crypto_currency = crypto_currency
        self.crypto_amount = crypto_amount
        self.transaction_id = transaction_id

    def to_dict(self):
        return {
            '_': 'MessageActionGiftTon',
            'currency': self.currency,
            'amount': self.amount,
            'crypto_currency': self.crypto_currency,
            'crypto_amount': self.crypto_amount,
            'transaction_id': self.transaction_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.transaction_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        buf.write(TLObject.serialize_bytes(self.crypto_currency))
        buf.write(struct.pack('<q', self.crypto_amount))
        if self.transaction_id is not None:
            buf.write(TLObject.serialize_bytes(self.transaction_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        _val_crypto_currency = reader.tgread_string()
        _args['crypto_currency'] = _val_crypto_currency
        _val_crypto_amount = reader.read_long()
        _args['crypto_amount'] = _val_crypto_amount
        if flags & (1 << 0):
            _val_transaction_id = reader.tgread_string()
            _args['transaction_id'] = _val_transaction_id
        else:
            _args['transaction_id'] = None
        return cls(**_args)


class MessageActionGiveawayLaunch(TLObject):
    """TL type: messageActionGiveawayLaunch"""
    CONSTRUCTOR_ID = 0xa80f51e4
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, stars: Optional[int] = None):
        self.stars = stars

    def to_dict(self):
        return {
            '_': 'MessageActionGiveawayLaunch',
            'stars': self.stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.stars is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        if self.stars is not None:
            buf.write(struct.pack('<q', self.stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_stars = reader.read_long()
            _args['stars'] = _val_stars
        else:
            _args['stars'] = None
        return cls(**_args)


class MessageActionGiveawayResults(TLObject):
    """TL type: messageActionGiveawayResults"""
    CONSTRUCTOR_ID = 0x87e2f155
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, winners_count: int, unclaimed_count: int, stars: Optional[bool] = None):
        self.winners_count = winners_count
        self.unclaimed_count = unclaimed_count
        self.stars = stars

    def to_dict(self):
        return {
            '_': 'MessageActionGiveawayResults',
            'winners_count': self.winners_count,
            'unclaimed_count': self.unclaimed_count,
            'stars': self.stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.stars:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.winners_count))
        buf.write(struct.pack('<i', self.unclaimed_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['stars'] = bool(flags & (1 << 0))
        _val_winners_count = reader.read_int()
        _args['winners_count'] = _val_winners_count
        _val_unclaimed_count = reader.read_int()
        _args['unclaimed_count'] = _val_unclaimed_count
        return cls(**_args)


class MessageActionGroupCall(TLObject):
    """TL type: messageActionGroupCall"""
    CONSTRUCTOR_ID = 0x7a0d7f42
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, call: 'TypeInputGroupCall', duration: Optional[int] = None):
        self.call = call
        self.duration = duration

    def to_dict(self):
        return {
            '_': 'MessageActionGroupCall',
            'call': self.call,
            'duration': self.duration,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.duration is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.call))
        if self.duration is not None:
            buf.write(struct.pack('<i', self.duration))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        if flags & (1 << 0):
            _val_duration = reader.read_int()
            _args['duration'] = _val_duration
        else:
            _args['duration'] = None
        return cls(**_args)


class MessageActionGroupCallScheduled(TLObject):
    """TL type: messageActionGroupCallScheduled"""
    CONSTRUCTOR_ID = 0xb3a07661
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, call: 'TypeInputGroupCall', schedule_date: Optional[datetime]):
        self.call = call
        self.schedule_date = schedule_date

    def to_dict(self):
        return {
            '_': 'MessageActionGroupCallScheduled',
            'call': self.call,
            'schedule_date': self.schedule_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.call))
        buf.write(struct.pack('<i', self.schedule_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_schedule_date = reader.read_int()
        _args['schedule_date'] = _val_schedule_date
        return cls(**_args)


class MessageActionHistoryClear(TLObject):
    """TL type: messageActionHistoryClear"""
    CONSTRUCTOR_ID = 0x9fbab604
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageActionHistoryClear',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageActionInviteToGroupCall(TLObject):
    """TL type: messageActionInviteToGroupCall"""
    CONSTRUCTOR_ID = 0x502f92f7
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, call: 'TypeInputGroupCall', users: List[int]):
        self.call = call
        self.users = users

    def to_dict(self):
        return {
            '_': 'MessageActionInviteToGroupCall',
            'call': self.call,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.call))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.read_long()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class MessageActionLoginUnknownLocation(TLObject):
    """TL type: messageActionLoginUnknownLocation"""
    CONSTRUCTOR_ID = 0x555555f5
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, title: str, address: str):
        self.title = title
        self.address = address

    def to_dict(self):
        return {
            '_': 'MessageActionLoginUnknownLocation',
            'title': self.title,
            'address': self.address,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.address))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_address = reader.tgread_string()
        _args['address'] = _val_address
        return cls(**_args)


class MessageActionNewCreatorPending(TLObject):
    """TL type: messageActionNewCreatorPending"""
    CONSTRUCTOR_ID = 0xb07ed085
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, new_creator_id: int):
        self.new_creator_id = new_creator_id

    def to_dict(self):
        return {
            '_': 'MessageActionNewCreatorPending',
            'new_creator_id': self.new_creator_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.new_creator_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_new_creator_id = reader.read_long()
        _args['new_creator_id'] = _val_new_creator_id
        return cls(**_args)


class MessageActionPaidMessagesPrice(TLObject):
    """TL type: messageActionPaidMessagesPrice"""
    CONSTRUCTOR_ID = 0x84b88578
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, stars: int, broadcast_messages_allowed: Optional[bool] = None):
        self.stars = stars
        self.broadcast_messages_allowed = broadcast_messages_allowed

    def to_dict(self):
        return {
            '_': 'MessageActionPaidMessagesPrice',
            'stars': self.stars,
            'broadcast_messages_allowed': self.broadcast_messages_allowed,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.broadcast_messages_allowed:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['broadcast_messages_allowed'] = bool(flags & (1 << 0))
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        return cls(**_args)


class MessageActionPaidMessagesRefunded(TLObject):
    """TL type: messageActionPaidMessagesRefunded"""
    CONSTRUCTOR_ID = 0xac1f1fcd
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, count: int, stars: int):
        self.count = count
        self.stars = stars

    def to_dict(self):
        return {
            '_': 'MessageActionPaidMessagesRefunded',
            'count': self.count,
            'stars': self.stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.count))
        buf.write(struct.pack('<q', self.stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_count = reader.read_int()
        _args['count'] = _val_count
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        return cls(**_args)


class MessageActionPaymentRefunded(TLObject):
    """TL type: messageActionPaymentRefunded"""
    CONSTRUCTOR_ID = 0x41b3e202
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, peer: 'TypePeer', currency: str, total_amount: int, charge: 'TypePaymentCharge', payload: Optional[bytes] = None):
        self.peer = peer
        self.currency = currency
        self.total_amount = total_amount
        self.charge = charge
        self.payload = payload

    def to_dict(self):
        return {
            '_': 'MessageActionPaymentRefunded',
            'peer': self.peer,
            'currency': self.currency,
            'total_amount': self.total_amount,
            'charge': self.charge,
            'payload': self.payload,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.payload is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.total_amount))
        buf.write(bytes(self.charge))
        if self.payload is not None:
            buf.write(TLObject.serialize_bytes(self.payload))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_total_amount = reader.read_long()
        _args['total_amount'] = _val_total_amount
        if flags & (1 << 0):
            _val_payload = reader.tgread_bytes()
            _args['payload'] = _val_payload
        else:
            _args['payload'] = None
        _val_charge = reader.tgread_object()
        _args['charge'] = _val_charge
        return cls(**_args)


class MessageActionPaymentSent(TLObject):
    """TL type: messageActionPaymentSent"""
    CONSTRUCTOR_ID = 0xc624b16e
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, currency: str, total_amount: int, recurring_init: Optional[bool] = None, recurring_used: Optional[bool] = None, invoice_slug: Optional[str] = None, subscription_until_date: Optional[datetime] = None):
        self.currency = currency
        self.total_amount = total_amount
        self.recurring_init = recurring_init
        self.recurring_used = recurring_used
        self.invoice_slug = invoice_slug
        self.subscription_until_date = subscription_until_date

    def to_dict(self):
        return {
            '_': 'MessageActionPaymentSent',
            'currency': self.currency,
            'total_amount': self.total_amount,
            'recurring_init': self.recurring_init,
            'recurring_used': self.recurring_used,
            'invoice_slug': self.invoice_slug,
            'subscription_until_date': self.subscription_until_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.recurring_init:
            flags |= (1 << 2)
        if self.recurring_used:
            flags |= (1 << 3)
        if self.invoice_slug is not None:
            flags |= (1 << 0)
        if self.subscription_until_date is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.total_amount))
        if self.invoice_slug is not None:
            buf.write(TLObject.serialize_bytes(self.invoice_slug))
        if self.subscription_until_date is not None:
            buf.write(struct.pack('<i', self.subscription_until_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['recurring_init'] = bool(flags & (1 << 2))
        _args['recurring_used'] = bool(flags & (1 << 3))
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_total_amount = reader.read_long()
        _args['total_amount'] = _val_total_amount
        if flags & (1 << 0):
            _val_invoice_slug = reader.tgread_string()
            _args['invoice_slug'] = _val_invoice_slug
        else:
            _args['invoice_slug'] = None
        if flags & (1 << 4):
            _val_subscription_until_date = reader.read_int()
            _args['subscription_until_date'] = _val_subscription_until_date
        else:
            _args['subscription_until_date'] = None
        return cls(**_args)


class MessageActionPaymentSentMe(TLObject):
    """TL type: messageActionPaymentSentMe"""
    CONSTRUCTOR_ID = 0xffa00ccc
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, currency: str, total_amount: int, payload: bytes, charge: 'TypePaymentCharge', recurring_init: Optional[bool] = None, recurring_used: Optional[bool] = None, info: Optional['TypePaymentRequestedInfo'] = None, shipping_option_id: Optional[str] = None, subscription_until_date: Optional[datetime] = None):
        self.currency = currency
        self.total_amount = total_amount
        self.payload = payload
        self.charge = charge
        self.recurring_init = recurring_init
        self.recurring_used = recurring_used
        self.info = info
        self.shipping_option_id = shipping_option_id
        self.subscription_until_date = subscription_until_date

    def to_dict(self):
        return {
            '_': 'MessageActionPaymentSentMe',
            'currency': self.currency,
            'total_amount': self.total_amount,
            'payload': self.payload,
            'charge': self.charge,
            'recurring_init': self.recurring_init,
            'recurring_used': self.recurring_used,
            'info': self.info,
            'shipping_option_id': self.shipping_option_id,
            'subscription_until_date': self.subscription_until_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.recurring_init:
            flags |= (1 << 2)
        if self.recurring_used:
            flags |= (1 << 3)
        if self.info is not None:
            flags |= (1 << 0)
        if self.shipping_option_id is not None:
            flags |= (1 << 1)
        if self.subscription_until_date is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.total_amount))
        buf.write(TLObject.serialize_bytes(self.payload))
        buf.write(bytes(self.charge))
        if self.info is not None:
            buf.write(bytes(self.info))
        if self.shipping_option_id is not None:
            buf.write(TLObject.serialize_bytes(self.shipping_option_id))
        if self.subscription_until_date is not None:
            buf.write(struct.pack('<i', self.subscription_until_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['recurring_init'] = bool(flags & (1 << 2))
        _args['recurring_used'] = bool(flags & (1 << 3))
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_total_amount = reader.read_long()
        _args['total_amount'] = _val_total_amount
        _val_payload = reader.tgread_bytes()
        _args['payload'] = _val_payload
        if flags & (1 << 0):
            _val_info = reader.tgread_object()
            _args['info'] = _val_info
        else:
            _args['info'] = None
        if flags & (1 << 1):
            _val_shipping_option_id = reader.tgread_string()
            _args['shipping_option_id'] = _val_shipping_option_id
        else:
            _args['shipping_option_id'] = None
        _val_charge = reader.tgread_object()
        _args['charge'] = _val_charge
        if flags & (1 << 4):
            _val_subscription_until_date = reader.read_int()
            _args['subscription_until_date'] = _val_subscription_until_date
        else:
            _args['subscription_until_date'] = None
        return cls(**_args)


class MessageActionPhoneCall(TLObject):
    """TL type: messageActionPhoneCall"""
    CONSTRUCTOR_ID = 0x80e11a7f
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, call_id: int, video: Optional[bool] = None, reason: Optional['TypePhoneCallDiscardReason'] = None, duration: Optional[int] = None):
        self.call_id = call_id
        self.video = video
        self.reason = reason
        self.duration = duration

    def to_dict(self):
        return {
            '_': 'MessageActionPhoneCall',
            'call_id': self.call_id,
            'video': self.video,
            'reason': self.reason,
            'duration': self.duration,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.video:
            flags |= (1 << 2)
        if self.reason is not None:
            flags |= (1 << 0)
        if self.duration is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.call_id))
        if self.reason is not None:
            buf.write(bytes(self.reason))
        if self.duration is not None:
            buf.write(struct.pack('<i', self.duration))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['video'] = bool(flags & (1 << 2))
        _val_call_id = reader.read_long()
        _args['call_id'] = _val_call_id
        if flags & (1 << 0):
            _val_reason = reader.tgread_object()
            _args['reason'] = _val_reason
        else:
            _args['reason'] = None
        if flags & (1 << 1):
            _val_duration = reader.read_int()
            _args['duration'] = _val_duration
        else:
            _args['duration'] = None
        return cls(**_args)


class MessageActionPhoneNumberRequest(TLObject):
    """TL type: messageActionPhoneNumberRequest"""
    CONSTRUCTOR_ID = 0x01baa035
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageActionPhoneNumberRequest',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageActionPinMessage(TLObject):
    """TL type: messageActionPinMessage"""
    CONSTRUCTOR_ID = 0x94bd38ed
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageActionPinMessage',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageActionPrizeStars(TLObject):
    """TL type: messageActionPrizeStars"""
    CONSTRUCTOR_ID = 0xb00c47a2
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, stars: int, transaction_id: str, boost_peer: 'TypePeer', giveaway_msg_id: int, unclaimed: Optional[bool] = None):
        self.stars = stars
        self.transaction_id = transaction_id
        self.boost_peer = boost_peer
        self.giveaway_msg_id = giveaway_msg_id
        self.unclaimed = unclaimed

    def to_dict(self):
        return {
            '_': 'MessageActionPrizeStars',
            'stars': self.stars,
            'transaction_id': self.transaction_id,
            'boost_peer': self.boost_peer,
            'giveaway_msg_id': self.giveaway_msg_id,
            'unclaimed': self.unclaimed,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.unclaimed:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.stars))
        buf.write(TLObject.serialize_bytes(self.transaction_id))
        buf.write(bytes(self.boost_peer))
        buf.write(struct.pack('<i', self.giveaway_msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['unclaimed'] = bool(flags & (1 << 0))
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        _val_transaction_id = reader.tgread_string()
        _args['transaction_id'] = _val_transaction_id
        _val_boost_peer = reader.tgread_object()
        _args['boost_peer'] = _val_boost_peer
        _val_giveaway_msg_id = reader.read_int()
        _args['giveaway_msg_id'] = _val_giveaway_msg_id
        return cls(**_args)


class MessageActionRequestedPeer(TLObject):
    """TL type: messageActionRequestedPeer"""
    CONSTRUCTOR_ID = 0x31518e9b
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, button_id: int, peers: List['TypePeer']):
        self.button_id = button_id
        self.peers = peers

    def to_dict(self):
        return {
            '_': 'MessageActionRequestedPeer',
            'button_id': self.button_id,
            'peers': self.peers,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.button_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.peers)))
        for item in self.peers:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_button_id = reader.read_int()
        _args['button_id'] = _val_button_id
        reader.read_int(signed=False)  # skip vector id
        _count_peers = reader.read_int()
        _list_peers = []
        for _ in range(_count_peers):
            _item_peers = reader.tgread_object()
            _list_peers.append(_item_peers)
        _args['peers'] = _list_peers
        return cls(**_args)


class MessageActionRequestedPeerSentMe(TLObject):
    """TL type: messageActionRequestedPeerSentMe"""
    CONSTRUCTOR_ID = 0x93b31848
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, button_id: int, peers: List['TypeRequestedPeer']):
        self.button_id = button_id
        self.peers = peers

    def to_dict(self):
        return {
            '_': 'MessageActionRequestedPeerSentMe',
            'button_id': self.button_id,
            'peers': self.peers,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.button_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.peers)))
        for item in self.peers:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_button_id = reader.read_int()
        _args['button_id'] = _val_button_id
        reader.read_int(signed=False)  # skip vector id
        _count_peers = reader.read_int()
        _list_peers = []
        for _ in range(_count_peers):
            _item_peers = reader.tgread_object()
            _list_peers.append(_item_peers)
        _args['peers'] = _list_peers
        return cls(**_args)


class MessageActionScreenshotTaken(TLObject):
    """TL type: messageActionScreenshotTaken"""
    CONSTRUCTOR_ID = 0x4792929b
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageActionScreenshotTaken',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageActionSecureValuesSent(TLObject):
    """TL type: messageActionSecureValuesSent"""
    CONSTRUCTOR_ID = 0xd95c6154
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, types: List['TypeSecureValueType']):
        self.types = types

    def to_dict(self):
        return {
            '_': 'MessageActionSecureValuesSent',
            'types': self.types,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.types)))
        for item in self.types:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_types = reader.read_int()
        _list_types = []
        for _ in range(_count_types):
            _item_types = reader.tgread_object()
            _list_types.append(_item_types)
        _args['types'] = _list_types
        return cls(**_args)


class MessageActionSecureValuesSentMe(TLObject):
    """TL type: messageActionSecureValuesSentMe"""
    CONSTRUCTOR_ID = 0x1b287353
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, values: List['TypeSecureValue'], credentials: 'TypeSecureCredentialsEncrypted'):
        self.values = values
        self.credentials = credentials

    def to_dict(self):
        return {
            '_': 'MessageActionSecureValuesSentMe',
            'values': self.values,
            'credentials': self.credentials,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.values)))
        for item in self.values:
            buf.write(bytes(self.item))
        buf.write(bytes(self.credentials))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_values = reader.read_int()
        _list_values = []
        for _ in range(_count_values):
            _item_values = reader.tgread_object()
            _list_values.append(_item_values)
        _args['values'] = _list_values
        _val_credentials = reader.tgread_object()
        _args['credentials'] = _val_credentials
        return cls(**_args)


class MessageActionSetChatTheme(TLObject):
    """TL type: messageActionSetChatTheme"""
    CONSTRUCTOR_ID = 0xb91bbd3a
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, theme: 'TypeChatTheme'):
        self.theme = theme

    def to_dict(self):
        return {
            '_': 'MessageActionSetChatTheme',
            'theme': self.theme,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.theme))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_theme = reader.tgread_object()
        _args['theme'] = _val_theme
        return cls(**_args)


class MessageActionSetChatWallPaper(TLObject):
    """TL type: messageActionSetChatWallPaper"""
    CONSTRUCTOR_ID = 0x5060a3f4
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, wallpaper: 'TypeWallPaper', same: Optional[bool] = None, for_both: Optional[bool] = None):
        self.wallpaper = wallpaper
        self.same = same
        self.for_both = for_both

    def to_dict(self):
        return {
            '_': 'MessageActionSetChatWallPaper',
            'wallpaper': self.wallpaper,
            'same': self.same,
            'for_both': self.for_both,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.same:
            flags |= (1 << 0)
        if self.for_both:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.wallpaper))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['same'] = bool(flags & (1 << 0))
        _args['for_both'] = bool(flags & (1 << 1))
        _val_wallpaper = reader.tgread_object()
        _args['wallpaper'] = _val_wallpaper
        return cls(**_args)


class MessageActionSetMessagesTtl(TLObject):
    """TL type: messageActionSetMessagesTTL"""
    CONSTRUCTOR_ID = 0x3c134d7b
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, period: int, auto_setting_from: Optional[int] = None):
        self.period = period
        self.auto_setting_from = auto_setting_from

    def to_dict(self):
        return {
            '_': 'MessageActionSetMessagesTtl',
            'period': self.period,
            'auto_setting_from': self.auto_setting_from,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.auto_setting_from is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.period))
        if self.auto_setting_from is not None:
            buf.write(struct.pack('<q', self.auto_setting_from))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_period = reader.read_int()
        _args['period'] = _val_period
        if flags & (1 << 0):
            _val_auto_setting_from = reader.read_long()
            _args['auto_setting_from'] = _val_auto_setting_from
        else:
            _args['auto_setting_from'] = None
        return cls(**_args)


class MessageActionStarGift(TLObject):
    """TL type: messageActionStarGift"""
    CONSTRUCTOR_ID = 0xea2c31d3
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, gift: 'TypeStarGift', name_hidden: Optional[bool] = None, saved: Optional[bool] = None, converted: Optional[bool] = None, upgraded: Optional[bool] = None, refunded: Optional[bool] = None, can_upgrade: Optional[bool] = None, prepaid_upgrade: Optional[bool] = None, upgrade_separate: Optional[bool] = None, auction_acquired: Optional[bool] = None, message: Optional['TypeTextWithEntities'] = None, convert_stars: Optional[int] = None, upgrade_msg_id: Optional[int] = None, upgrade_stars: Optional[int] = None, from_id: Optional['TypePeer'] = None, peer: Optional['TypePeer'] = None, saved_id: Optional[int] = None, prepaid_upgrade_hash: Optional[str] = None, gift_msg_id: Optional[int] = None, to_id: Optional['TypePeer'] = None, gift_num: Optional[int] = None):
        self.gift = gift
        self.name_hidden = name_hidden
        self.saved = saved
        self.converted = converted
        self.upgraded = upgraded
        self.refunded = refunded
        self.can_upgrade = can_upgrade
        self.prepaid_upgrade = prepaid_upgrade
        self.upgrade_separate = upgrade_separate
        self.auction_acquired = auction_acquired
        self.message = message
        self.convert_stars = convert_stars
        self.upgrade_msg_id = upgrade_msg_id
        self.upgrade_stars = upgrade_stars
        self.from_id = from_id
        self.peer = peer
        self.saved_id = saved_id
        self.prepaid_upgrade_hash = prepaid_upgrade_hash
        self.gift_msg_id = gift_msg_id
        self.to_id = to_id
        self.gift_num = gift_num

    def to_dict(self):
        return {
            '_': 'MessageActionStarGift',
            'gift': self.gift,
            'name_hidden': self.name_hidden,
            'saved': self.saved,
            'converted': self.converted,
            'upgraded': self.upgraded,
            'refunded': self.refunded,
            'can_upgrade': self.can_upgrade,
            'prepaid_upgrade': self.prepaid_upgrade,
            'upgrade_separate': self.upgrade_separate,
            'auction_acquired': self.auction_acquired,
            'message': self.message,
            'convert_stars': self.convert_stars,
            'upgrade_msg_id': self.upgrade_msg_id,
            'upgrade_stars': self.upgrade_stars,
            'from_id': self.from_id,
            'peer': self.peer,
            'saved_id': self.saved_id,
            'prepaid_upgrade_hash': self.prepaid_upgrade_hash,
            'gift_msg_id': self.gift_msg_id,
            'to_id': self.to_id,
            'gift_num': self.gift_num,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.name_hidden:
            flags |= (1 << 0)
        if self.saved:
            flags |= (1 << 2)
        if self.converted:
            flags |= (1 << 3)
        if self.upgrade_msg_id is not None:
            flags |= (1 << 5)
        if self.refunded:
            flags |= (1 << 9)
        if self.can_upgrade:
            flags |= (1 << 10)
        if self.prepaid_upgrade:
            flags |= (1 << 13)
        if self.upgrade_separate:
            flags |= (1 << 16)
        if self.auction_acquired:
            flags |= (1 << 17)
        if self.message is not None:
            flags |= (1 << 1)
        if self.convert_stars is not None:
            flags |= (1 << 4)
        if self.upgrade_stars is not None:
            flags |= (1 << 8)
        if self.from_id is not None:
            flags |= (1 << 11)
        if self.saved_id is not None:
            flags |= (1 << 12)
        if self.prepaid_upgrade_hash is not None:
            flags |= (1 << 14)
        if self.gift_msg_id is not None:
            flags |= (1 << 15)
        if self.to_id is not None:
            flags |= (1 << 18)
        if self.gift_num is not None:
            flags |= (1 << 19)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.gift))
        if self.message is not None:
            buf.write(bytes(self.message))
        if self.convert_stars is not None:
            buf.write(struct.pack('<q', self.convert_stars))
        if self.upgrade_msg_id is not None:
            buf.write(struct.pack('<i', self.upgrade_msg_id))
        if self.upgrade_stars is not None:
            buf.write(struct.pack('<q', self.upgrade_stars))
        if self.from_id is not None:
            buf.write(bytes(self.from_id))
        if self.peer is not None:
            buf.write(bytes(self.peer))
        if self.saved_id is not None:
            buf.write(struct.pack('<q', self.saved_id))
        if self.prepaid_upgrade_hash is not None:
            buf.write(TLObject.serialize_bytes(self.prepaid_upgrade_hash))
        if self.gift_msg_id is not None:
            buf.write(struct.pack('<i', self.gift_msg_id))
        if self.to_id is not None:
            buf.write(bytes(self.to_id))
        if self.gift_num is not None:
            buf.write(struct.pack('<i', self.gift_num))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['name_hidden'] = bool(flags & (1 << 0))
        _args['saved'] = bool(flags & (1 << 2))
        _args['converted'] = bool(flags & (1 << 3))
        _args['upgraded'] = bool(flags & (1 << 5))
        _args['refunded'] = bool(flags & (1 << 9))
        _args['can_upgrade'] = bool(flags & (1 << 10))
        _args['prepaid_upgrade'] = bool(flags & (1 << 13))
        _args['upgrade_separate'] = bool(flags & (1 << 16))
        _args['auction_acquired'] = bool(flags & (1 << 17))
        _val_gift = reader.tgread_object()
        _args['gift'] = _val_gift
        if flags & (1 << 1):
            _val_message = reader.tgread_object()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        if flags & (1 << 4):
            _val_convert_stars = reader.read_long()
            _args['convert_stars'] = _val_convert_stars
        else:
            _args['convert_stars'] = None
        if flags & (1 << 5):
            _val_upgrade_msg_id = reader.read_int()
            _args['upgrade_msg_id'] = _val_upgrade_msg_id
        else:
            _args['upgrade_msg_id'] = None
        if flags & (1 << 8):
            _val_upgrade_stars = reader.read_long()
            _args['upgrade_stars'] = _val_upgrade_stars
        else:
            _args['upgrade_stars'] = None
        if flags & (1 << 11):
            _val_from_id = reader.tgread_object()
            _args['from_id'] = _val_from_id
        else:
            _args['from_id'] = None
        if flags & (1 << 12):
            _val_peer = reader.tgread_object()
            _args['peer'] = _val_peer
        else:
            _args['peer'] = None
        if flags & (1 << 12):
            _val_saved_id = reader.read_long()
            _args['saved_id'] = _val_saved_id
        else:
            _args['saved_id'] = None
        if flags & (1 << 14):
            _val_prepaid_upgrade_hash = reader.tgread_string()
            _args['prepaid_upgrade_hash'] = _val_prepaid_upgrade_hash
        else:
            _args['prepaid_upgrade_hash'] = None
        if flags & (1 << 15):
            _val_gift_msg_id = reader.read_int()
            _args['gift_msg_id'] = _val_gift_msg_id
        else:
            _args['gift_msg_id'] = None
        if flags & (1 << 18):
            _val_to_id = reader.tgread_object()
            _args['to_id'] = _val_to_id
        else:
            _args['to_id'] = None
        if flags & (1 << 19):
            _val_gift_num = reader.read_int()
            _args['gift_num'] = _val_gift_num
        else:
            _args['gift_num'] = None
        return cls(**_args)


class MessageActionStarGiftPurchaseOffer(TLObject):
    """TL type: messageActionStarGiftPurchaseOffer"""
    CONSTRUCTOR_ID = 0x774278d4
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, gift: 'TypeStarGift', price: 'TypeStarsAmount', expires_at: Optional[datetime], accepted: Optional[bool] = None, declined: Optional[bool] = None):
        self.gift = gift
        self.price = price
        self.expires_at = expires_at
        self.accepted = accepted
        self.declined = declined

    def to_dict(self):
        return {
            '_': 'MessageActionStarGiftPurchaseOffer',
            'gift': self.gift,
            'price': self.price,
            'expires_at': self.expires_at,
            'accepted': self.accepted,
            'declined': self.declined,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.accepted:
            flags |= (1 << 0)
        if self.declined:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.gift))
        buf.write(bytes(self.price))
        buf.write(struct.pack('<i', self.expires_at))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['accepted'] = bool(flags & (1 << 0))
        _args['declined'] = bool(flags & (1 << 1))
        _val_gift = reader.tgread_object()
        _args['gift'] = _val_gift
        _val_price = reader.tgread_object()
        _args['price'] = _val_price
        _val_expires_at = reader.read_int()
        _args['expires_at'] = _val_expires_at
        return cls(**_args)


class MessageActionStarGiftPurchaseOfferDeclined(TLObject):
    """TL type: messageActionStarGiftPurchaseOfferDeclined"""
    CONSTRUCTOR_ID = 0x73ada76b
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, gift: 'TypeStarGift', price: 'TypeStarsAmount', expired: Optional[bool] = None):
        self.gift = gift
        self.price = price
        self.expired = expired

    def to_dict(self):
        return {
            '_': 'MessageActionStarGiftPurchaseOfferDeclined',
            'gift': self.gift,
            'price': self.price,
            'expired': self.expired,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.expired:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.gift))
        buf.write(bytes(self.price))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['expired'] = bool(flags & (1 << 0))
        _val_gift = reader.tgread_object()
        _args['gift'] = _val_gift
        _val_price = reader.tgread_object()
        _args['price'] = _val_price
        return cls(**_args)


class MessageActionStarGiftUnique(TLObject):
    """TL type: messageActionStarGiftUnique"""
    CONSTRUCTOR_ID = 0xe6c31522
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, gift: 'TypeStarGift', upgrade: Optional[bool] = None, transferred: Optional[bool] = None, saved: Optional[bool] = None, refunded: Optional[bool] = None, prepaid_upgrade: Optional[bool] = None, assigned: Optional[bool] = None, from_offer: Optional[bool] = None, craft: Optional[bool] = None, can_export_at: Optional[int] = None, transfer_stars: Optional[int] = None, from_id: Optional['TypePeer'] = None, peer: Optional['TypePeer'] = None, saved_id: Optional[int] = None, resale_amount: Optional['TypeStarsAmount'] = None, can_transfer_at: Optional[int] = None, can_resell_at: Optional[int] = None, drop_original_details_stars: Optional[int] = None, can_craft_at: Optional[int] = None):
        self.gift = gift
        self.upgrade = upgrade
        self.transferred = transferred
        self.saved = saved
        self.refunded = refunded
        self.prepaid_upgrade = prepaid_upgrade
        self.assigned = assigned
        self.from_offer = from_offer
        self.craft = craft
        self.can_export_at = can_export_at
        self.transfer_stars = transfer_stars
        self.from_id = from_id
        self.peer = peer
        self.saved_id = saved_id
        self.resale_amount = resale_amount
        self.can_transfer_at = can_transfer_at
        self.can_resell_at = can_resell_at
        self.drop_original_details_stars = drop_original_details_stars
        self.can_craft_at = can_craft_at

    def to_dict(self):
        return {
            '_': 'MessageActionStarGiftUnique',
            'gift': self.gift,
            'upgrade': self.upgrade,
            'transferred': self.transferred,
            'saved': self.saved,
            'refunded': self.refunded,
            'prepaid_upgrade': self.prepaid_upgrade,
            'assigned': self.assigned,
            'from_offer': self.from_offer,
            'craft': self.craft,
            'can_export_at': self.can_export_at,
            'transfer_stars': self.transfer_stars,
            'from_id': self.from_id,
            'peer': self.peer,
            'saved_id': self.saved_id,
            'resale_amount': self.resale_amount,
            'can_transfer_at': self.can_transfer_at,
            'can_resell_at': self.can_resell_at,
            'drop_original_details_stars': self.drop_original_details_stars,
            'can_craft_at': self.can_craft_at,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.upgrade:
            flags |= (1 << 0)
        if self.transferred:
            flags |= (1 << 1)
        if self.saved:
            flags |= (1 << 2)
        if self.refunded:
            flags |= (1 << 5)
        if self.prepaid_upgrade:
            flags |= (1 << 11)
        if self.assigned:
            flags |= (1 << 13)
        if self.from_offer:
            flags |= (1 << 14)
        if self.craft:
            flags |= (1 << 16)
        if self.can_export_at is not None:
            flags |= (1 << 3)
        if self.transfer_stars is not None:
            flags |= (1 << 4)
        if self.from_id is not None:
            flags |= (1 << 6)
        if self.saved_id is not None:
            flags |= (1 << 7)
        if self.resale_amount is not None:
            flags |= (1 << 8)
        if self.can_transfer_at is not None:
            flags |= (1 << 9)
        if self.can_resell_at is not None:
            flags |= (1 << 10)
        if self.drop_original_details_stars is not None:
            flags |= (1 << 12)
        if self.can_craft_at is not None:
            flags |= (1 << 15)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.gift))
        if self.can_export_at is not None:
            buf.write(struct.pack('<i', self.can_export_at))
        if self.transfer_stars is not None:
            buf.write(struct.pack('<q', self.transfer_stars))
        if self.from_id is not None:
            buf.write(bytes(self.from_id))
        if self.peer is not None:
            buf.write(bytes(self.peer))
        if self.saved_id is not None:
            buf.write(struct.pack('<q', self.saved_id))
        if self.resale_amount is not None:
            buf.write(bytes(self.resale_amount))
        if self.can_transfer_at is not None:
            buf.write(struct.pack('<i', self.can_transfer_at))
        if self.can_resell_at is not None:
            buf.write(struct.pack('<i', self.can_resell_at))
        if self.drop_original_details_stars is not None:
            buf.write(struct.pack('<q', self.drop_original_details_stars))
        if self.can_craft_at is not None:
            buf.write(struct.pack('<i', self.can_craft_at))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['upgrade'] = bool(flags & (1 << 0))
        _args['transferred'] = bool(flags & (1 << 1))
        _args['saved'] = bool(flags & (1 << 2))
        _args['refunded'] = bool(flags & (1 << 5))
        _args['prepaid_upgrade'] = bool(flags & (1 << 11))
        _args['assigned'] = bool(flags & (1 << 13))
        _args['from_offer'] = bool(flags & (1 << 14))
        _args['craft'] = bool(flags & (1 << 16))
        _val_gift = reader.tgread_object()
        _args['gift'] = _val_gift
        if flags & (1 << 3):
            _val_can_export_at = reader.read_int()
            _args['can_export_at'] = _val_can_export_at
        else:
            _args['can_export_at'] = None
        if flags & (1 << 4):
            _val_transfer_stars = reader.read_long()
            _args['transfer_stars'] = _val_transfer_stars
        else:
            _args['transfer_stars'] = None
        if flags & (1 << 6):
            _val_from_id = reader.tgread_object()
            _args['from_id'] = _val_from_id
        else:
            _args['from_id'] = None
        if flags & (1 << 7):
            _val_peer = reader.tgread_object()
            _args['peer'] = _val_peer
        else:
            _args['peer'] = None
        if flags & (1 << 7):
            _val_saved_id = reader.read_long()
            _args['saved_id'] = _val_saved_id
        else:
            _args['saved_id'] = None
        if flags & (1 << 8):
            _val_resale_amount = reader.tgread_object()
            _args['resale_amount'] = _val_resale_amount
        else:
            _args['resale_amount'] = None
        if flags & (1 << 9):
            _val_can_transfer_at = reader.read_int()
            _args['can_transfer_at'] = _val_can_transfer_at
        else:
            _args['can_transfer_at'] = None
        if flags & (1 << 10):
            _val_can_resell_at = reader.read_int()
            _args['can_resell_at'] = _val_can_resell_at
        else:
            _args['can_resell_at'] = None
        if flags & (1 << 12):
            _val_drop_original_details_stars = reader.read_long()
            _args['drop_original_details_stars'] = _val_drop_original_details_stars
        else:
            _args['drop_original_details_stars'] = None
        if flags & (1 << 15):
            _val_can_craft_at = reader.read_int()
            _args['can_craft_at'] = _val_can_craft_at
        else:
            _args['can_craft_at'] = None
        return cls(**_args)


class MessageActionSuggestBirthday(TLObject):
    """TL type: messageActionSuggestBirthday"""
    CONSTRUCTOR_ID = 0x2c8f2a25
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, birthday: 'TypeBirthday'):
        self.birthday = birthday

    def to_dict(self):
        return {
            '_': 'MessageActionSuggestBirthday',
            'birthday': self.birthday,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.birthday))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_birthday = reader.tgread_object()
        _args['birthday'] = _val_birthday
        return cls(**_args)


class MessageActionSuggestProfilePhoto(TLObject):
    """TL type: messageActionSuggestProfilePhoto"""
    CONSTRUCTOR_ID = 0x57de635e
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, photo: 'TypePhoto'):
        self.photo = photo

    def to_dict(self):
        return {
            '_': 'MessageActionSuggestProfilePhoto',
            'photo': self.photo,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.photo))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_photo = reader.tgread_object()
        _args['photo'] = _val_photo
        return cls(**_args)


class MessageActionSuggestedPostApproval(TLObject):
    """TL type: messageActionSuggestedPostApproval"""
    CONSTRUCTOR_ID = 0xee7a1596
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, rejected: Optional[bool] = None, balance_too_low: Optional[bool] = None, reject_comment: Optional[str] = None, schedule_date: Optional[datetime] = None, price: Optional['TypeStarsAmount'] = None):
        self.rejected = rejected
        self.balance_too_low = balance_too_low
        self.reject_comment = reject_comment
        self.schedule_date = schedule_date
        self.price = price

    def to_dict(self):
        return {
            '_': 'MessageActionSuggestedPostApproval',
            'rejected': self.rejected,
            'balance_too_low': self.balance_too_low,
            'reject_comment': self.reject_comment,
            'schedule_date': self.schedule_date,
            'price': self.price,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.rejected:
            flags |= (1 << 0)
        if self.balance_too_low:
            flags |= (1 << 1)
        if self.reject_comment is not None:
            flags |= (1 << 2)
        if self.schedule_date is not None:
            flags |= (1 << 3)
        if self.price is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        if self.reject_comment is not None:
            buf.write(TLObject.serialize_bytes(self.reject_comment))
        if self.schedule_date is not None:
            buf.write(struct.pack('<i', self.schedule_date))
        if self.price is not None:
            buf.write(bytes(self.price))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['rejected'] = bool(flags & (1 << 0))
        _args['balance_too_low'] = bool(flags & (1 << 1))
        if flags & (1 << 2):
            _val_reject_comment = reader.tgread_string()
            _args['reject_comment'] = _val_reject_comment
        else:
            _args['reject_comment'] = None
        if flags & (1 << 3):
            _val_schedule_date = reader.read_int()
            _args['schedule_date'] = _val_schedule_date
        else:
            _args['schedule_date'] = None
        if flags & (1 << 4):
            _val_price = reader.tgread_object()
            _args['price'] = _val_price
        else:
            _args['price'] = None
        return cls(**_args)


class MessageActionSuggestedPostRefund(TLObject):
    """TL type: messageActionSuggestedPostRefund"""
    CONSTRUCTOR_ID = 0x69f916f8
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, payer_initiated: Optional[bool] = None):
        self.payer_initiated = payer_initiated

    def to_dict(self):
        return {
            '_': 'MessageActionSuggestedPostRefund',
            'payer_initiated': self.payer_initiated,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.payer_initiated:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['payer_initiated'] = bool(flags & (1 << 0))
        return cls(**_args)


class MessageActionSuggestedPostSuccess(TLObject):
    """TL type: messageActionSuggestedPostSuccess"""
    CONSTRUCTOR_ID = 0x95ddcf69
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, price: 'TypeStarsAmount'):
        self.price = price

    def to_dict(self):
        return {
            '_': 'MessageActionSuggestedPostSuccess',
            'price': self.price,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.price))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_price = reader.tgread_object()
        _args['price'] = _val_price
        return cls(**_args)


class MessageActionTtlchange(TLObject):
    """TL type: messageActionTTLChange"""
    CONSTRUCTOR_ID = 0x55555552
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, ttl: int):
        self.ttl = ttl

    def to_dict(self):
        return {
            '_': 'MessageActionTtlchange',
            'ttl': self.ttl,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.ttl))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_ttl = reader.read_int()
        _args['ttl'] = _val_ttl
        return cls(**_args)


class MessageActionTodoAppendTasks(TLObject):
    """TL type: messageActionTodoAppendTasks"""
    CONSTRUCTOR_ID = 0xc7edbc83
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, list: List['TypeTodoItem']):
        self.list = list

    def to_dict(self):
        return {
            '_': 'MessageActionTodoAppendTasks',
            'list': self.list,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.list)))
        for item in self.list:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_list = reader.read_int()
        _list_list = []
        for _ in range(_count_list):
            _item_list = reader.tgread_object()
            _list_list.append(_item_list)
        _args['list'] = _list_list
        return cls(**_args)


class MessageActionTodoCompletions(TLObject):
    """TL type: messageActionTodoCompletions"""
    CONSTRUCTOR_ID = 0xcc7c5c89
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, completed: List[int], incompleted: List[int]):
        self.completed = completed
        self.incompleted = incompleted

    def to_dict(self):
        return {
            '_': 'MessageActionTodoCompletions',
            'completed': self.completed,
            'incompleted': self.incompleted,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.completed)))
        for item in self.completed:
            buf.write(struct.pack('<i', self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.incompleted)))
        for item in self.incompleted:
            buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_completed = reader.read_int()
        _list_completed = []
        for _ in range(_count_completed):
            _item_completed = reader.read_int()
            _list_completed.append(_item_completed)
        _args['completed'] = _list_completed
        reader.read_int(signed=False)  # skip vector id
        _count_incompleted = reader.read_int()
        _list_incompleted = []
        for _ in range(_count_incompleted):
            _item_incompleted = reader.read_int()
            _list_incompleted.append(_item_incompleted)
        _args['incompleted'] = _list_incompleted
        return cls(**_args)


class MessageActionTopicCreate(TLObject):
    """TL type: messageActionTopicCreate"""
    CONSTRUCTOR_ID = 0x0d999256
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, title: str, icon_color: int, title_missing: Optional[bool] = None, icon_emoji_id: Optional[int] = None):
        self.title = title
        self.icon_color = icon_color
        self.title_missing = title_missing
        self.icon_emoji_id = icon_emoji_id

    def to_dict(self):
        return {
            '_': 'MessageActionTopicCreate',
            'title': self.title,
            'icon_color': self.icon_color,
            'title_missing': self.title_missing,
            'icon_emoji_id': self.icon_emoji_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.title_missing:
            flags |= (1 << 1)
        if self.icon_emoji_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(struct.pack('<i', self.icon_color))
        if self.icon_emoji_id is not None:
            buf.write(struct.pack('<q', self.icon_emoji_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['title_missing'] = bool(flags & (1 << 1))
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_icon_color = reader.read_int()
        _args['icon_color'] = _val_icon_color
        if flags & (1 << 0):
            _val_icon_emoji_id = reader.read_long()
            _args['icon_emoji_id'] = _val_icon_emoji_id
        else:
            _args['icon_emoji_id'] = None
        return cls(**_args)


class MessageActionTopicEdit(TLObject):
    """TL type: messageActionTopicEdit"""
    CONSTRUCTOR_ID = 0xc0944820
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, title: Optional[str] = None, icon_emoji_id: Optional[int] = None, closed: Optional[bool] = None, hidden: Optional[bool] = None):
        self.title = title
        self.icon_emoji_id = icon_emoji_id
        self.closed = closed
        self.hidden = hidden

    def to_dict(self):
        return {
            '_': 'MessageActionTopicEdit',
            'title': self.title,
            'icon_emoji_id': self.icon_emoji_id,
            'closed': self.closed,
            'hidden': self.hidden,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.title is not None:
            flags |= (1 << 0)
        if self.icon_emoji_id is not None:
            flags |= (1 << 1)
        if self.closed is not None:
            flags |= (1 << 2)
        if self.hidden is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.icon_emoji_id is not None:
            buf.write(struct.pack('<q', self.icon_emoji_id))
        if self.closed is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.closed else 0xbc799737))
        if self.hidden is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.hidden else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 1):
            _val_icon_emoji_id = reader.read_long()
            _args['icon_emoji_id'] = _val_icon_emoji_id
        else:
            _args['icon_emoji_id'] = None
        if flags & (1 << 2):
            _val_closed = reader.tgread_bool()
            _args['closed'] = _val_closed
        else:
            _args['closed'] = None
        if flags & (1 << 3):
            _val_hidden = reader.tgread_bool()
            _args['hidden'] = _val_hidden
        else:
            _args['hidden'] = None
        return cls(**_args)


class MessageActionUserJoined(TLObject):
    """TL type: messageActionUserJoined"""
    CONSTRUCTOR_ID = 0x55555550
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageActionUserJoined',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageActionUserUpdatedPhoto(TLObject):
    """TL type: messageActionUserUpdatedPhoto"""
    CONSTRUCTOR_ID = 0x55555551
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, new_user_photo: 'TypeUserProfilePhoto'):
        self.new_user_photo = new_user_photo

    def to_dict(self):
        return {
            '_': 'MessageActionUserUpdatedPhoto',
            'new_user_photo': self.new_user_photo,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.new_user_photo))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_new_user_photo = reader.tgread_object()
        _args['new_user_photo'] = _val_new_user_photo
        return cls(**_args)


class MessageActionWebViewDataSent(TLObject):
    """TL type: messageActionWebViewDataSent"""
    CONSTRUCTOR_ID = 0xb4c38cb5
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, text: str):
        self.text = text

    def to_dict(self):
        return {
            '_': 'MessageActionWebViewDataSent',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class MessageActionWebViewDataSentMe(TLObject):
    """TL type: messageActionWebViewDataSentMe"""
    CONSTRUCTOR_ID = 0x47dd8079
    SUBCLASS_OF_ID = 0x8680d126

    def __init__(self, text: str, data: str):
        self.text = text
        self.data = data

    def to_dict(self):
        return {
            '_': 'MessageActionWebViewDataSentMe',
            'text': self.text,
            'data': self.data,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_data = reader.tgread_string()
        _args['data'] = _val_data
        return cls(**_args)


class MessageEmpty(TLObject):
    """TL type: messageEmpty"""
    CONSTRUCTOR_ID = 0x90a6ca84
    SUBCLASS_OF_ID = 0x790009e3

    def __init__(self, id: int, peer_id: Optional['TypePeer'] = None):
        self.id = id
        self.peer_id = peer_id

    def to_dict(self):
        return {
            '_': 'MessageEmpty',
            'id': self.id,
            'peer_id': self.peer_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.peer_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        if self.peer_id is not None:
            buf.write(bytes(self.peer_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.read_int()
        _args['id'] = _val_id
        if flags & (1 << 0):
            _val_peer_id = reader.tgread_object()
            _args['peer_id'] = _val_peer_id
        else:
            _args['peer_id'] = None
        return cls(**_args)


class MessageEntityBankCard(TLObject):
    """TL type: messageEntityBankCard"""
    CONSTRUCTOR_ID = 0x761e6af4
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityBankCard',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityBlockquote(TLObject):
    """TL type: messageEntityBlockquote"""
    CONSTRUCTOR_ID = 0xf1ccaaac
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int, collapsed: Optional[bool] = None):
        self.offset = offset
        self.length = length
        self.collapsed = collapsed

    def to_dict(self):
        return {
            '_': 'MessageEntityBlockquote',
            'offset': self.offset,
            'length': self.length,
            'collapsed': self.collapsed,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.collapsed:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['collapsed'] = bool(flags & (1 << 0))
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityBold(TLObject):
    """TL type: messageEntityBold"""
    CONSTRUCTOR_ID = 0xbd610bc9
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityBold',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityBotCommand(TLObject):
    """TL type: messageEntityBotCommand"""
    CONSTRUCTOR_ID = 0x6cef8ac7
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityBotCommand',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityCashtag(TLObject):
    """TL type: messageEntityCashtag"""
    CONSTRUCTOR_ID = 0x4c4e743f
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityCashtag',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityCode(TLObject):
    """TL type: messageEntityCode"""
    CONSTRUCTOR_ID = 0x28a20571
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityCode',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityCustomEmoji(TLObject):
    """TL type: messageEntityCustomEmoji"""
    CONSTRUCTOR_ID = 0xc8cf05f8
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int, document_id: int):
        self.offset = offset
        self.length = length
        self.document_id = document_id

    def to_dict(self):
        return {
            '_': 'MessageEntityCustomEmoji',
            'offset': self.offset,
            'length': self.length,
            'document_id': self.document_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        buf.write(struct.pack('<q', self.document_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        _val_document_id = reader.read_long()
        _args['document_id'] = _val_document_id
        return cls(**_args)


class MessageEntityEmail(TLObject):
    """TL type: messageEntityEmail"""
    CONSTRUCTOR_ID = 0x64e475c2
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityEmail',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityHashtag(TLObject):
    """TL type: messageEntityHashtag"""
    CONSTRUCTOR_ID = 0x6f635b0d
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityHashtag',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityItalic(TLObject):
    """TL type: messageEntityItalic"""
    CONSTRUCTOR_ID = 0x826f8b60
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityItalic',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityMention(TLObject):
    """TL type: messageEntityMention"""
    CONSTRUCTOR_ID = 0xfa04579d
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityMention',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityMentionName(TLObject):
    """TL type: messageEntityMentionName"""
    CONSTRUCTOR_ID = 0xdc7b1140
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int, user_id: int):
        self.offset = offset
        self.length = length
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'MessageEntityMentionName',
            'offset': self.offset,
            'length': self.length,
            'user_id': self.user_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        buf.write(struct.pack('<q', self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class MessageEntityPhone(TLObject):
    """TL type: messageEntityPhone"""
    CONSTRUCTOR_ID = 0x9b69e34b
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityPhone',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityPre(TLObject):
    """TL type: messageEntityPre"""
    CONSTRUCTOR_ID = 0x73924be0
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int, language: str):
        self.offset = offset
        self.length = length
        self.language = language

    def to_dict(self):
        return {
            '_': 'MessageEntityPre',
            'offset': self.offset,
            'length': self.length,
            'language': self.language,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        buf.write(TLObject.serialize_bytes(self.language))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        _val_language = reader.tgread_string()
        _args['language'] = _val_language
        return cls(**_args)


class MessageEntitySpoiler(TLObject):
    """TL type: messageEntitySpoiler"""
    CONSTRUCTOR_ID = 0x32ca960f
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntitySpoiler',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityStrike(TLObject):
    """TL type: messageEntityStrike"""
    CONSTRUCTOR_ID = 0xbf0693d4
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityStrike',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityTextUrl(TLObject):
    """TL type: messageEntityTextUrl"""
    CONSTRUCTOR_ID = 0x76a6d327
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int, url: str):
        self.offset = offset
        self.length = length
        self.url = url

    def to_dict(self):
        return {
            '_': 'MessageEntityTextUrl',
            'offset': self.offset,
            'length': self.length,
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class MessageEntityUnderline(TLObject):
    """TL type: messageEntityUnderline"""
    CONSTRUCTOR_ID = 0x9c4e7e8b
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityUnderline',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityUnknown(TLObject):
    """TL type: messageEntityUnknown"""
    CONSTRUCTOR_ID = 0xbb92ba95
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityUnknown',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageEntityUrl(TLObject):
    """TL type: messageEntityUrl"""
    CONSTRUCTOR_ID = 0x6ed02538
    SUBCLASS_OF_ID = 0xcf6419dc

    def __init__(self, offset: int, length: int):
        self.offset = offset
        self.length = length

    def to_dict(self):
        return {
            '_': 'MessageEntityUrl',
            'offset': self.offset,
            'length': self.length,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_length = reader.read_int()
        _args['length'] = _val_length
        return cls(**_args)


class MessageExtendedMedia(TLObject):
    """TL type: messageExtendedMedia"""
    CONSTRUCTOR_ID = 0xee479c64
    SUBCLASS_OF_ID = 0x9727d95d

    def __init__(self, media: 'TypeMessageMedia'):
        self.media = media

    def to_dict(self):
        return {
            '_': 'MessageExtendedMedia',
            'media': self.media,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.media))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_media = reader.tgread_object()
        _args['media'] = _val_media
        return cls(**_args)


class MessageExtendedMediaPreview(TLObject):
    """TL type: messageExtendedMediaPreview"""
    CONSTRUCTOR_ID = 0xad628cc8
    SUBCLASS_OF_ID = 0x9727d95d

    def __init__(self, w: Optional[int] = None, h: Optional[int] = None, thumb: Optional['TypePhotoSize'] = None, video_duration: Optional[int] = None):
        self.w = w
        self.h = h
        self.thumb = thumb
        self.video_duration = video_duration

    def to_dict(self):
        return {
            '_': 'MessageExtendedMediaPreview',
            'w': self.w,
            'h': self.h,
            'thumb': self.thumb,
            'video_duration': self.video_duration,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.h is not None:
            flags |= (1 << 0)
        if self.thumb is not None:
            flags |= (1 << 1)
        if self.video_duration is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.w is not None:
            buf.write(struct.pack('<i', self.w))
        if self.h is not None:
            buf.write(struct.pack('<i', self.h))
        if self.thumb is not None:
            buf.write(bytes(self.thumb))
        if self.video_duration is not None:
            buf.write(struct.pack('<i', self.video_duration))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_w = reader.read_int()
            _args['w'] = _val_w
        else:
            _args['w'] = None
        if flags & (1 << 0):
            _val_h = reader.read_int()
            _args['h'] = _val_h
        else:
            _args['h'] = None
        if flags & (1 << 1):
            _val_thumb = reader.tgread_object()
            _args['thumb'] = _val_thumb
        else:
            _args['thumb'] = None
        if flags & (1 << 2):
            _val_video_duration = reader.read_int()
            _args['video_duration'] = _val_video_duration
        else:
            _args['video_duration'] = None
        return cls(**_args)


class MessageFwdHeader(TLObject):
    """TL type: messageFwdHeader"""
    CONSTRUCTOR_ID = 0x4e4df4bb
    SUBCLASS_OF_ID = 0x7a286804

    def __init__(self, date: Optional[datetime], imported: Optional[bool] = None, saved_out: Optional[bool] = None, from_id: Optional['TypePeer'] = None, from_name: Optional[str] = None, channel_post: Optional[int] = None, post_author: Optional[str] = None, saved_from_peer: Optional['TypePeer'] = None, saved_from_msg_id: Optional[int] = None, saved_from_id: Optional['TypePeer'] = None, saved_from_name: Optional[str] = None, saved_date: Optional[datetime] = None, psa_type: Optional[str] = None):
        self.date = date
        self.imported = imported
        self.saved_out = saved_out
        self.from_id = from_id
        self.from_name = from_name
        self.channel_post = channel_post
        self.post_author = post_author
        self.saved_from_peer = saved_from_peer
        self.saved_from_msg_id = saved_from_msg_id
        self.saved_from_id = saved_from_id
        self.saved_from_name = saved_from_name
        self.saved_date = saved_date
        self.psa_type = psa_type

    def to_dict(self):
        return {
            '_': 'MessageFwdHeader',
            'date': self.date,
            'imported': self.imported,
            'saved_out': self.saved_out,
            'from_id': self.from_id,
            'from_name': self.from_name,
            'channel_post': self.channel_post,
            'post_author': self.post_author,
            'saved_from_peer': self.saved_from_peer,
            'saved_from_msg_id': self.saved_from_msg_id,
            'saved_from_id': self.saved_from_id,
            'saved_from_name': self.saved_from_name,
            'saved_date': self.saved_date,
            'psa_type': self.psa_type,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.imported:
            flags |= (1 << 7)
        if self.saved_out:
            flags |= (1 << 11)
        if self.from_id is not None:
            flags |= (1 << 0)
        if self.from_name is not None:
            flags |= (1 << 5)
        if self.channel_post is not None:
            flags |= (1 << 2)
        if self.post_author is not None:
            flags |= (1 << 3)
        if self.saved_from_msg_id is not None:
            flags |= (1 << 4)
        if self.saved_from_id is not None:
            flags |= (1 << 8)
        if self.saved_from_name is not None:
            flags |= (1 << 9)
        if self.saved_date is not None:
            flags |= (1 << 10)
        if self.psa_type is not None:
            flags |= (1 << 6)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.date))
        if self.from_id is not None:
            buf.write(bytes(self.from_id))
        if self.from_name is not None:
            buf.write(TLObject.serialize_bytes(self.from_name))
        if self.channel_post is not None:
            buf.write(struct.pack('<i', self.channel_post))
        if self.post_author is not None:
            buf.write(TLObject.serialize_bytes(self.post_author))
        if self.saved_from_peer is not None:
            buf.write(bytes(self.saved_from_peer))
        if self.saved_from_msg_id is not None:
            buf.write(struct.pack('<i', self.saved_from_msg_id))
        if self.saved_from_id is not None:
            buf.write(bytes(self.saved_from_id))
        if self.saved_from_name is not None:
            buf.write(TLObject.serialize_bytes(self.saved_from_name))
        if self.saved_date is not None:
            buf.write(struct.pack('<i', self.saved_date))
        if self.psa_type is not None:
            buf.write(TLObject.serialize_bytes(self.psa_type))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['imported'] = bool(flags & (1 << 7))
        _args['saved_out'] = bool(flags & (1 << 11))
        if flags & (1 << 0):
            _val_from_id = reader.tgread_object()
            _args['from_id'] = _val_from_id
        else:
            _args['from_id'] = None
        if flags & (1 << 5):
            _val_from_name = reader.tgread_string()
            _args['from_name'] = _val_from_name
        else:
            _args['from_name'] = None
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 2):
            _val_channel_post = reader.read_int()
            _args['channel_post'] = _val_channel_post
        else:
            _args['channel_post'] = None
        if flags & (1 << 3):
            _val_post_author = reader.tgread_string()
            _args['post_author'] = _val_post_author
        else:
            _args['post_author'] = None
        if flags & (1 << 4):
            _val_saved_from_peer = reader.tgread_object()
            _args['saved_from_peer'] = _val_saved_from_peer
        else:
            _args['saved_from_peer'] = None
        if flags & (1 << 4):
            _val_saved_from_msg_id = reader.read_int()
            _args['saved_from_msg_id'] = _val_saved_from_msg_id
        else:
            _args['saved_from_msg_id'] = None
        if flags & (1 << 8):
            _val_saved_from_id = reader.tgread_object()
            _args['saved_from_id'] = _val_saved_from_id
        else:
            _args['saved_from_id'] = None
        if flags & (1 << 9):
            _val_saved_from_name = reader.tgread_string()
            _args['saved_from_name'] = _val_saved_from_name
        else:
            _args['saved_from_name'] = None
        if flags & (1 << 10):
            _val_saved_date = reader.read_int()
            _args['saved_date'] = _val_saved_date
        else:
            _args['saved_date'] = None
        if flags & (1 << 6):
            _val_psa_type = reader.tgread_string()
            _args['psa_type'] = _val_psa_type
        else:
            _args['psa_type'] = None
        return cls(**_args)


class MessageMediaContact(TLObject):
    """TL type: messageMediaContact"""
    CONSTRUCTOR_ID = 0x70322949
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, phone_number: str, first_name: str, last_name: str, vcard: str, user_id: int):
        self.phone_number = phone_number
        self.first_name = first_name
        self.last_name = last_name
        self.vcard = vcard
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'MessageMediaContact',
            'phone_number': self.phone_number,
            'first_name': self.first_name,
            'last_name': self.last_name,
            'vcard': self.vcard,
            'user_id': self.user_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.first_name))
        buf.write(TLObject.serialize_bytes(self.last_name))
        buf.write(TLObject.serialize_bytes(self.vcard))
        buf.write(struct.pack('<q', self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_first_name = reader.tgread_string()
        _args['first_name'] = _val_first_name
        _val_last_name = reader.tgread_string()
        _args['last_name'] = _val_last_name
        _val_vcard = reader.tgread_string()
        _args['vcard'] = _val_vcard
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class MessageMediaDice(TLObject):
    """TL type: messageMediaDice"""
    CONSTRUCTOR_ID = 0x08cbec07
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, value: int, emoticon: str, game_outcome: Optional['TypeEmojiGameOutcome'] = None):
        self.value = value
        self.emoticon = emoticon
        self.game_outcome = game_outcome

    def to_dict(self):
        return {
            '_': 'MessageMediaDice',
            'value': self.value,
            'emoticon': self.emoticon,
            'game_outcome': self.game_outcome,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.game_outcome is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.value))
        buf.write(TLObject.serialize_bytes(self.emoticon))
        if self.game_outcome is not None:
            buf.write(bytes(self.game_outcome))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_value = reader.read_int()
        _args['value'] = _val_value
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        if flags & (1 << 0):
            _val_game_outcome = reader.tgread_object()
            _args['game_outcome'] = _val_game_outcome
        else:
            _args['game_outcome'] = None
        return cls(**_args)


class MessageMediaDocument(TLObject):
    """TL type: messageMediaDocument"""
    CONSTRUCTOR_ID = 0x52d8ccd9
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, nopremium: Optional[bool] = None, spoiler: Optional[bool] = None, video: Optional[bool] = None, round: Optional[bool] = None, voice: Optional[bool] = None, document: Optional['TypeDocument'] = None, alt_documents: Optional[List['TypeDocument']] = None, video_cover: Optional['TypePhoto'] = None, video_timestamp: Optional[int] = None, ttl_seconds: Optional[int] = None):
        self.nopremium = nopremium
        self.spoiler = spoiler
        self.video = video
        self.round = round
        self.voice = voice
        self.document = document
        self.alt_documents = alt_documents
        self.video_cover = video_cover
        self.video_timestamp = video_timestamp
        self.ttl_seconds = ttl_seconds

    def to_dict(self):
        return {
            '_': 'MessageMediaDocument',
            'nopremium': self.nopremium,
            'spoiler': self.spoiler,
            'video': self.video,
            'round': self.round,
            'voice': self.voice,
            'document': self.document,
            'alt_documents': self.alt_documents,
            'video_cover': self.video_cover,
            'video_timestamp': self.video_timestamp,
            'ttl_seconds': self.ttl_seconds,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.nopremium:
            flags |= (1 << 3)
        if self.spoiler:
            flags |= (1 << 4)
        if self.video:
            flags |= (1 << 6)
        if self.round:
            flags |= (1 << 7)
        if self.voice:
            flags |= (1 << 8)
        if self.document is not None:
            flags |= (1 << 0)
        if self.alt_documents is not None:
            flags |= (1 << 5)
        if self.video_cover is not None:
            flags |= (1 << 9)
        if self.video_timestamp is not None:
            flags |= (1 << 10)
        if self.ttl_seconds is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.document is not None:
            buf.write(bytes(self.document))
        if self.alt_documents is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.alt_documents)))
            for item in self.alt_documents:
                buf.write(bytes(self.item))
        if self.video_cover is not None:
            buf.write(bytes(self.video_cover))
        if self.video_timestamp is not None:
            buf.write(struct.pack('<i', self.video_timestamp))
        if self.ttl_seconds is not None:
            buf.write(struct.pack('<i', self.ttl_seconds))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['nopremium'] = bool(flags & (1 << 3))
        _args['spoiler'] = bool(flags & (1 << 4))
        _args['video'] = bool(flags & (1 << 6))
        _args['round'] = bool(flags & (1 << 7))
        _args['voice'] = bool(flags & (1 << 8))
        if flags & (1 << 0):
            _val_document = reader.tgread_object()
            _args['document'] = _val_document
        else:
            _args['document'] = None
        if flags & (1 << 5):
            reader.read_int(signed=False)  # skip vector id
            _count_alt_documents = reader.read_int()
            _list_alt_documents = []
            for _ in range(_count_alt_documents):
                _item_alt_documents = reader.tgread_object()
                _list_alt_documents.append(_item_alt_documents)
            _args['alt_documents'] = _list_alt_documents
        else:
            _args['alt_documents'] = None
        if flags & (1 << 9):
            _val_video_cover = reader.tgread_object()
            _args['video_cover'] = _val_video_cover
        else:
            _args['video_cover'] = None
        if flags & (1 << 10):
            _val_video_timestamp = reader.read_int()
            _args['video_timestamp'] = _val_video_timestamp
        else:
            _args['video_timestamp'] = None
        if flags & (1 << 2):
            _val_ttl_seconds = reader.read_int()
            _args['ttl_seconds'] = _val_ttl_seconds
        else:
            _args['ttl_seconds'] = None
        return cls(**_args)


class MessageMediaEmpty(TLObject):
    """TL type: messageMediaEmpty"""
    CONSTRUCTOR_ID = 0x3ded6320
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageMediaEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageMediaGame(TLObject):
    """TL type: messageMediaGame"""
    CONSTRUCTOR_ID = 0xfdb19008
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, game: 'TypeGame'):
        self.game = game

    def to_dict(self):
        return {
            '_': 'MessageMediaGame',
            'game': self.game,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.game))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_game = reader.tgread_object()
        _args['game'] = _val_game
        return cls(**_args)


class MessageMediaGeo(TLObject):
    """TL type: messageMediaGeo"""
    CONSTRUCTOR_ID = 0x56e0d474
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, geo: 'TypeGeoPoint'):
        self.geo = geo

    def to_dict(self):
        return {
            '_': 'MessageMediaGeo',
            'geo': self.geo,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.geo))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_geo = reader.tgread_object()
        _args['geo'] = _val_geo
        return cls(**_args)


class MessageMediaGeoLive(TLObject):
    """TL type: messageMediaGeoLive"""
    CONSTRUCTOR_ID = 0xb940c666
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, geo: 'TypeGeoPoint', period: int, heading: Optional[int] = None, proximity_notification_radius: Optional[int] = None):
        self.geo = geo
        self.period = period
        self.heading = heading
        self.proximity_notification_radius = proximity_notification_radius

    def to_dict(self):
        return {
            '_': 'MessageMediaGeoLive',
            'geo': self.geo,
            'period': self.period,
            'heading': self.heading,
            'proximity_notification_radius': self.proximity_notification_radius,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.heading is not None:
            flags |= (1 << 0)
        if self.proximity_notification_radius is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.geo))
        buf.write(struct.pack('<i', self.period))
        if self.heading is not None:
            buf.write(struct.pack('<i', self.heading))
        if self.proximity_notification_radius is not None:
            buf.write(struct.pack('<i', self.proximity_notification_radius))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_geo = reader.tgread_object()
        _args['geo'] = _val_geo
        if flags & (1 << 0):
            _val_heading = reader.read_int()
            _args['heading'] = _val_heading
        else:
            _args['heading'] = None
        _val_period = reader.read_int()
        _args['period'] = _val_period
        if flags & (1 << 1):
            _val_proximity_notification_radius = reader.read_int()
            _args['proximity_notification_radius'] = _val_proximity_notification_radius
        else:
            _args['proximity_notification_radius'] = None
        return cls(**_args)


class MessageMediaGiveaway(TLObject):
    """TL type: messageMediaGiveaway"""
    CONSTRUCTOR_ID = 0xaa073beb
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, channels: List[int], quantity: int, until_date: Optional[datetime], only_new_subscribers: Optional[bool] = None, winners_are_visible: Optional[bool] = None, countries_iso2: Optional[List[str]] = None, prize_description: Optional[str] = None, months: Optional[int] = None, stars: Optional[int] = None):
        self.channels = channels
        self.quantity = quantity
        self.until_date = until_date
        self.only_new_subscribers = only_new_subscribers
        self.winners_are_visible = winners_are_visible
        self.countries_iso2 = countries_iso2
        self.prize_description = prize_description
        self.months = months
        self.stars = stars

    def to_dict(self):
        return {
            '_': 'MessageMediaGiveaway',
            'channels': self.channels,
            'quantity': self.quantity,
            'until_date': self.until_date,
            'only_new_subscribers': self.only_new_subscribers,
            'winners_are_visible': self.winners_are_visible,
            'countries_iso2': self.countries_iso2,
            'prize_description': self.prize_description,
            'months': self.months,
            'stars': self.stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.only_new_subscribers:
            flags |= (1 << 0)
        if self.winners_are_visible:
            flags |= (1 << 2)
        if self.countries_iso2 is not None:
            flags |= (1 << 1)
        if self.prize_description is not None:
            flags |= (1 << 3)
        if self.months is not None:
            flags |= (1 << 4)
        if self.stars is not None:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.channels)))
        for item in self.channels:
            buf.write(struct.pack('<q', self.item))
        buf.write(struct.pack('<i', self.quantity))
        buf.write(struct.pack('<i', self.until_date))
        if self.countries_iso2 is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.countries_iso2)))
            for item in self.countries_iso2:
                buf.write(TLObject.serialize_bytes(self.item))
        if self.prize_description is not None:
            buf.write(TLObject.serialize_bytes(self.prize_description))
        if self.months is not None:
            buf.write(struct.pack('<i', self.months))
        if self.stars is not None:
            buf.write(struct.pack('<q', self.stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['only_new_subscribers'] = bool(flags & (1 << 0))
        _args['winners_are_visible'] = bool(flags & (1 << 2))
        reader.read_int(signed=False)  # skip vector id
        _count_channels = reader.read_int()
        _list_channels = []
        for _ in range(_count_channels):
            _item_channels = reader.read_long()
            _list_channels.append(_item_channels)
        _args['channels'] = _list_channels
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_countries_iso2 = reader.read_int()
            _list_countries_iso2 = []
            for _ in range(_count_countries_iso2):
                _item_countries_iso2 = reader.tgread_string()
                _list_countries_iso2.append(_item_countries_iso2)
            _args['countries_iso2'] = _list_countries_iso2
        else:
            _args['countries_iso2'] = None
        if flags & (1 << 3):
            _val_prize_description = reader.tgread_string()
            _args['prize_description'] = _val_prize_description
        else:
            _args['prize_description'] = None
        _val_quantity = reader.read_int()
        _args['quantity'] = _val_quantity
        if flags & (1 << 4):
            _val_months = reader.read_int()
            _args['months'] = _val_months
        else:
            _args['months'] = None
        if flags & (1 << 5):
            _val_stars = reader.read_long()
            _args['stars'] = _val_stars
        else:
            _args['stars'] = None
        _val_until_date = reader.read_int()
        _args['until_date'] = _val_until_date
        return cls(**_args)


class MessageMediaGiveawayResults(TLObject):
    """TL type: messageMediaGiveawayResults"""
    CONSTRUCTOR_ID = 0xceaa3ea1
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, channel_id: int, launch_msg_id: int, winners_count: int, unclaimed_count: int, winners: List[int], until_date: Optional[datetime], only_new_subscribers: Optional[bool] = None, refunded: Optional[bool] = None, additional_peers_count: Optional[int] = None, months: Optional[int] = None, stars: Optional[int] = None, prize_description: Optional[str] = None):
        self.channel_id = channel_id
        self.launch_msg_id = launch_msg_id
        self.winners_count = winners_count
        self.unclaimed_count = unclaimed_count
        self.winners = winners
        self.until_date = until_date
        self.only_new_subscribers = only_new_subscribers
        self.refunded = refunded
        self.additional_peers_count = additional_peers_count
        self.months = months
        self.stars = stars
        self.prize_description = prize_description

    def to_dict(self):
        return {
            '_': 'MessageMediaGiveawayResults',
            'channel_id': self.channel_id,
            'launch_msg_id': self.launch_msg_id,
            'winners_count': self.winners_count,
            'unclaimed_count': self.unclaimed_count,
            'winners': self.winners,
            'until_date': self.until_date,
            'only_new_subscribers': self.only_new_subscribers,
            'refunded': self.refunded,
            'additional_peers_count': self.additional_peers_count,
            'months': self.months,
            'stars': self.stars,
            'prize_description': self.prize_description,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.only_new_subscribers:
            flags |= (1 << 0)
        if self.refunded:
            flags |= (1 << 2)
        if self.additional_peers_count is not None:
            flags |= (1 << 3)
        if self.months is not None:
            flags |= (1 << 4)
        if self.stars is not None:
            flags |= (1 << 5)
        if self.prize_description is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', self.launch_msg_id))
        buf.write(struct.pack('<i', self.winners_count))
        buf.write(struct.pack('<i', self.unclaimed_count))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.winners)))
        for item in self.winners:
            buf.write(struct.pack('<q', self.item))
        buf.write(struct.pack('<i', self.until_date))
        if self.additional_peers_count is not None:
            buf.write(struct.pack('<i', self.additional_peers_count))
        if self.months is not None:
            buf.write(struct.pack('<i', self.months))
        if self.stars is not None:
            buf.write(struct.pack('<q', self.stars))
        if self.prize_description is not None:
            buf.write(TLObject.serialize_bytes(self.prize_description))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['only_new_subscribers'] = bool(flags & (1 << 0))
        _args['refunded'] = bool(flags & (1 << 2))
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        if flags & (1 << 3):
            _val_additional_peers_count = reader.read_int()
            _args['additional_peers_count'] = _val_additional_peers_count
        else:
            _args['additional_peers_count'] = None
        _val_launch_msg_id = reader.read_int()
        _args['launch_msg_id'] = _val_launch_msg_id
        _val_winners_count = reader.read_int()
        _args['winners_count'] = _val_winners_count
        _val_unclaimed_count = reader.read_int()
        _args['unclaimed_count'] = _val_unclaimed_count
        reader.read_int(signed=False)  # skip vector id
        _count_winners = reader.read_int()
        _list_winners = []
        for _ in range(_count_winners):
            _item_winners = reader.read_long()
            _list_winners.append(_item_winners)
        _args['winners'] = _list_winners
        if flags & (1 << 4):
            _val_months = reader.read_int()
            _args['months'] = _val_months
        else:
            _args['months'] = None
        if flags & (1 << 5):
            _val_stars = reader.read_long()
            _args['stars'] = _val_stars
        else:
            _args['stars'] = None
        if flags & (1 << 1):
            _val_prize_description = reader.tgread_string()
            _args['prize_description'] = _val_prize_description
        else:
            _args['prize_description'] = None
        _val_until_date = reader.read_int()
        _args['until_date'] = _val_until_date
        return cls(**_args)


class MessageMediaInvoice(TLObject):
    """TL type: messageMediaInvoice"""
    CONSTRUCTOR_ID = 0xf6a548d3
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, title: str, description: str, currency: str, total_amount: int, start_param: str, shipping_address_requested: Optional[bool] = None, test: Optional[bool] = None, photo: Optional['TypeWebDocument'] = None, receipt_msg_id: Optional[int] = None, extended_media: Optional['TypeMessageExtendedMedia'] = None):
        self.title = title
        self.description = description
        self.currency = currency
        self.total_amount = total_amount
        self.start_param = start_param
        self.shipping_address_requested = shipping_address_requested
        self.test = test
        self.photo = photo
        self.receipt_msg_id = receipt_msg_id
        self.extended_media = extended_media

    def to_dict(self):
        return {
            '_': 'MessageMediaInvoice',
            'title': self.title,
            'description': self.description,
            'currency': self.currency,
            'total_amount': self.total_amount,
            'start_param': self.start_param,
            'shipping_address_requested': self.shipping_address_requested,
            'test': self.test,
            'photo': self.photo,
            'receipt_msg_id': self.receipt_msg_id,
            'extended_media': self.extended_media,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.shipping_address_requested:
            flags |= (1 << 1)
        if self.test:
            flags |= (1 << 3)
        if self.photo is not None:
            flags |= (1 << 0)
        if self.receipt_msg_id is not None:
            flags |= (1 << 2)
        if self.extended_media is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.description))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.total_amount))
        buf.write(TLObject.serialize_bytes(self.start_param))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        if self.receipt_msg_id is not None:
            buf.write(struct.pack('<i', self.receipt_msg_id))
        if self.extended_media is not None:
            buf.write(bytes(self.extended_media))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['shipping_address_requested'] = bool(flags & (1 << 1))
        _args['test'] = bool(flags & (1 << 3))
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_description = reader.tgread_string()
        _args['description'] = _val_description
        if flags & (1 << 0):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        if flags & (1 << 2):
            _val_receipt_msg_id = reader.read_int()
            _args['receipt_msg_id'] = _val_receipt_msg_id
        else:
            _args['receipt_msg_id'] = None
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_total_amount = reader.read_long()
        _args['total_amount'] = _val_total_amount
        _val_start_param = reader.tgread_string()
        _args['start_param'] = _val_start_param
        if flags & (1 << 4):
            _val_extended_media = reader.tgread_object()
            _args['extended_media'] = _val_extended_media
        else:
            _args['extended_media'] = None
        return cls(**_args)


class MessageMediaPaidMedia(TLObject):
    """TL type: messageMediaPaidMedia"""
    CONSTRUCTOR_ID = 0xa8852491
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, stars_amount: int, extended_media: List['TypeMessageExtendedMedia']):
        self.stars_amount = stars_amount
        self.extended_media = extended_media

    def to_dict(self):
        return {
            '_': 'MessageMediaPaidMedia',
            'stars_amount': self.stars_amount,
            'extended_media': self.extended_media,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.stars_amount))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.extended_media)))
        for item in self.extended_media:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_stars_amount = reader.read_long()
        _args['stars_amount'] = _val_stars_amount
        reader.read_int(signed=False)  # skip vector id
        _count_extended_media = reader.read_int()
        _list_extended_media = []
        for _ in range(_count_extended_media):
            _item_extended_media = reader.tgread_object()
            _list_extended_media.append(_item_extended_media)
        _args['extended_media'] = _list_extended_media
        return cls(**_args)


class MessageMediaPhoto(TLObject):
    """TL type: messageMediaPhoto"""
    CONSTRUCTOR_ID = 0x695150d7
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, spoiler: Optional[bool] = None, photo: Optional['TypePhoto'] = None, ttl_seconds: Optional[int] = None):
        self.spoiler = spoiler
        self.photo = photo
        self.ttl_seconds = ttl_seconds

    def to_dict(self):
        return {
            '_': 'MessageMediaPhoto',
            'spoiler': self.spoiler,
            'photo': self.photo,
            'ttl_seconds': self.ttl_seconds,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.spoiler:
            flags |= (1 << 3)
        if self.photo is not None:
            flags |= (1 << 0)
        if self.ttl_seconds is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        if self.ttl_seconds is not None:
            buf.write(struct.pack('<i', self.ttl_seconds))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['spoiler'] = bool(flags & (1 << 3))
        if flags & (1 << 0):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        if flags & (1 << 2):
            _val_ttl_seconds = reader.read_int()
            _args['ttl_seconds'] = _val_ttl_seconds
        else:
            _args['ttl_seconds'] = None
        return cls(**_args)


class MessageMediaPoll(TLObject):
    """TL type: messageMediaPoll"""
    CONSTRUCTOR_ID = 0x4bd6e798
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, poll: 'TypePoll', results: 'TypePollResults'):
        self.poll = poll
        self.results = results

    def to_dict(self):
        return {
            '_': 'MessageMediaPoll',
            'poll': self.poll,
            'results': self.results,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.poll))
        buf.write(bytes(self.results))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_poll = reader.tgread_object()
        _args['poll'] = _val_poll
        _val_results = reader.tgread_object()
        _args['results'] = _val_results
        return cls(**_args)


class MessageMediaStory(TLObject):
    """TL type: messageMediaStory"""
    CONSTRUCTOR_ID = 0x68cb6283
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, peer: 'TypePeer', id: int, via_mention: Optional[bool] = None, story: Optional['TypeStoryItem'] = None):
        self.peer = peer
        self.id = id
        self.via_mention = via_mention
        self.story = story

    def to_dict(self):
        return {
            '_': 'MessageMediaStory',
            'peer': self.peer,
            'id': self.id,
            'via_mention': self.via_mention,
            'story': self.story,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.via_mention:
            flags |= (1 << 1)
        if self.story is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.id))
        if self.story is not None:
            buf.write(bytes(self.story))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['via_mention'] = bool(flags & (1 << 1))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_id = reader.read_int()
        _args['id'] = _val_id
        if flags & (1 << 0):
            _val_story = reader.tgread_object()
            _args['story'] = _val_story
        else:
            _args['story'] = None
        return cls(**_args)


class MessageMediaToDo(TLObject):
    """TL type: messageMediaToDo"""
    CONSTRUCTOR_ID = 0x8a53b014
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, todo: 'TypeTodoList', completions: Optional[List['TypeTodoCompletion']] = None):
        self.todo = todo
        self.completions = completions

    def to_dict(self):
        return {
            '_': 'MessageMediaToDo',
            'todo': self.todo,
            'completions': self.completions,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.completions is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.todo))
        if self.completions is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.completions)))
            for item in self.completions:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_todo = reader.tgread_object()
        _args['todo'] = _val_todo
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_completions = reader.read_int()
            _list_completions = []
            for _ in range(_count_completions):
                _item_completions = reader.tgread_object()
                _list_completions.append(_item_completions)
            _args['completions'] = _list_completions
        else:
            _args['completions'] = None
        return cls(**_args)


class MessageMediaUnsupported(TLObject):
    """TL type: messageMediaUnsupported"""
    CONSTRUCTOR_ID = 0x9f84f49e
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'MessageMediaUnsupported',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class MessageMediaVenue(TLObject):
    """TL type: messageMediaVenue"""
    CONSTRUCTOR_ID = 0x2ec0533f
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, geo: 'TypeGeoPoint', title: str, address: str, provider: str, venue_id: str, venue_type: str):
        self.geo = geo
        self.title = title
        self.address = address
        self.provider = provider
        self.venue_id = venue_id
        self.venue_type = venue_type

    def to_dict(self):
        return {
            '_': 'MessageMediaVenue',
            'geo': self.geo,
            'title': self.title,
            'address': self.address,
            'provider': self.provider,
            'venue_id': self.venue_id,
            'venue_type': self.venue_type,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.geo))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.address))
        buf.write(TLObject.serialize_bytes(self.provider))
        buf.write(TLObject.serialize_bytes(self.venue_id))
        buf.write(TLObject.serialize_bytes(self.venue_type))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_geo = reader.tgread_object()
        _args['geo'] = _val_geo
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_address = reader.tgread_string()
        _args['address'] = _val_address
        _val_provider = reader.tgread_string()
        _args['provider'] = _val_provider
        _val_venue_id = reader.tgread_string()
        _args['venue_id'] = _val_venue_id
        _val_venue_type = reader.tgread_string()
        _args['venue_type'] = _val_venue_type
        return cls(**_args)


class MessageMediaVideoStream(TLObject):
    """TL type: messageMediaVideoStream"""
    CONSTRUCTOR_ID = 0xca5cab89
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, call: 'TypeInputGroupCall', rtmp_stream: Optional[bool] = None):
        self.call = call
        self.rtmp_stream = rtmp_stream

    def to_dict(self):
        return {
            '_': 'MessageMediaVideoStream',
            'call': self.call,
            'rtmp_stream': self.rtmp_stream,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.rtmp_stream:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.call))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['rtmp_stream'] = bool(flags & (1 << 0))
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        return cls(**_args)


class MessageMediaWebPage(TLObject):
    """TL type: messageMediaWebPage"""
    CONSTRUCTOR_ID = 0xddf10c3b
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, webpage: 'TypeWebPage', force_large_media: Optional[bool] = None, force_small_media: Optional[bool] = None, manual: Optional[bool] = None, safe: Optional[bool] = None):
        self.webpage = webpage
        self.force_large_media = force_large_media
        self.force_small_media = force_small_media
        self.manual = manual
        self.safe = safe

    def to_dict(self):
        return {
            '_': 'MessageMediaWebPage',
            'webpage': self.webpage,
            'force_large_media': self.force_large_media,
            'force_small_media': self.force_small_media,
            'manual': self.manual,
            'safe': self.safe,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.force_large_media:
            flags |= (1 << 0)
        if self.force_small_media:
            flags |= (1 << 1)
        if self.manual:
            flags |= (1 << 3)
        if self.safe:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.webpage))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['force_large_media'] = bool(flags & (1 << 0))
        _args['force_small_media'] = bool(flags & (1 << 1))
        _args['manual'] = bool(flags & (1 << 3))
        _args['safe'] = bool(flags & (1 << 4))
        _val_webpage = reader.tgread_object()
        _args['webpage'] = _val_webpage
        return cls(**_args)


class MessagePeerReaction(TLObject):
    """TL type: messagePeerReaction"""
    CONSTRUCTOR_ID = 0x8c79b63c
    SUBCLASS_OF_ID = 0xaf73a2a5

    def __init__(self, peer_id: 'TypePeer', date: Optional[datetime], reaction: 'TypeReaction', big: Optional[bool] = None, unread: Optional[bool] = None, my: Optional[bool] = None):
        self.peer_id = peer_id
        self.date = date
        self.reaction = reaction
        self.big = big
        self.unread = unread
        self.my = my

    def to_dict(self):
        return {
            '_': 'MessagePeerReaction',
            'peer_id': self.peer_id,
            'date': self.date,
            'reaction': self.reaction,
            'big': self.big,
            'unread': self.unread,
            'my': self.my,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.big:
            flags |= (1 << 0)
        if self.unread:
            flags |= (1 << 1)
        if self.my:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(bytes(self.reaction))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['big'] = bool(flags & (1 << 0))
        _args['unread'] = bool(flags & (1 << 1))
        _args['my'] = bool(flags & (1 << 2))
        _val_peer_id = reader.tgread_object()
        _args['peer_id'] = _val_peer_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_reaction = reader.tgread_object()
        _args['reaction'] = _val_reaction
        return cls(**_args)


class MessagePeerVote(TLObject):
    """TL type: messagePeerVote"""
    CONSTRUCTOR_ID = 0xb6cc2d5c
    SUBCLASS_OF_ID = 0x85c27202

    def __init__(self, peer: 'TypePeer', option: bytes, date: Optional[datetime]):
        self.peer = peer
        self.option = option
        self.date = date

    def to_dict(self):
        return {
            '_': 'MessagePeerVote',
            'peer': self.peer,
            'option': self.option,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.option))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_option = reader.tgread_bytes()
        _args['option'] = _val_option
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class MessagePeerVoteInputOption(TLObject):
    """TL type: messagePeerVoteInputOption"""
    CONSTRUCTOR_ID = 0x74cda504
    SUBCLASS_OF_ID = 0x85c27202

    def __init__(self, peer: 'TypePeer', date: Optional[datetime]):
        self.peer = peer
        self.date = date

    def to_dict(self):
        return {
            '_': 'MessagePeerVoteInputOption',
            'peer': self.peer,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class MessagePeerVoteMultiple(TLObject):
    """TL type: messagePeerVoteMultiple"""
    CONSTRUCTOR_ID = 0x4628f6e6
    SUBCLASS_OF_ID = 0x85c27202

    def __init__(self, peer: 'TypePeer', options: List[bytes], date: Optional[datetime]):
        self.peer = peer
        self.options = options
        self.date = date

    def to_dict(self):
        return {
            '_': 'MessagePeerVoteMultiple',
            'peer': self.peer,
            'options': self.options,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.options)))
        for item in self.options:
            buf.write(TLObject.serialize_bytes(self.item))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        reader.read_int(signed=False)  # skip vector id
        _count_options = reader.read_int()
        _list_options = []
        for _ in range(_count_options):
            _item_options = reader.tgread_bytes()
            _list_options.append(_item_options)
        _args['options'] = _list_options
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class MessageRange(TLObject):
    """TL type: messageRange"""
    CONSTRUCTOR_ID = 0x0ae30253
    SUBCLASS_OF_ID = 0xbec74577

    def __init__(self, min_id: int, max_id: int):
        self.min_id = min_id
        self.max_id = max_id

    def to_dict(self):
        return {
            '_': 'MessageRange',
            'min_id': self.min_id,
            'max_id': self.max_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.min_id))
        buf.write(struct.pack('<i', self.max_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_min_id = reader.read_int()
        _args['min_id'] = _val_min_id
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        return cls(**_args)


class MessageReactions(TLObject):
    """TL type: messageReactions"""
    CONSTRUCTOR_ID = 0x0a339f0b
    SUBCLASS_OF_ID = 0x8a5b071c

    def __init__(self, results: List['TypeReactionCount'], min: Optional[bool] = None, can_see_list: Optional[bool] = None, reactions_as_tags: Optional[bool] = None, recent_reactions: Optional[List['TypeMessagePeerReaction']] = None, top_reactors: Optional[List['TypeMessageReactor']] = None):
        self.results = results
        self.min = min
        self.can_see_list = can_see_list
        self.reactions_as_tags = reactions_as_tags
        self.recent_reactions = recent_reactions
        self.top_reactors = top_reactors

    def to_dict(self):
        return {
            '_': 'MessageReactions',
            'results': self.results,
            'min': self.min,
            'can_see_list': self.can_see_list,
            'reactions_as_tags': self.reactions_as_tags,
            'recent_reactions': self.recent_reactions,
            'top_reactors': self.top_reactors,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.min:
            flags |= (1 << 0)
        if self.can_see_list:
            flags |= (1 << 2)
        if self.reactions_as_tags:
            flags |= (1 << 3)
        if self.recent_reactions is not None:
            flags |= (1 << 1)
        if self.top_reactors is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.results)))
        for item in self.results:
            buf.write(bytes(self.item))
        if self.recent_reactions is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.recent_reactions)))
            for item in self.recent_reactions:
                buf.write(bytes(self.item))
        if self.top_reactors is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.top_reactors)))
            for item in self.top_reactors:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['min'] = bool(flags & (1 << 0))
        _args['can_see_list'] = bool(flags & (1 << 2))
        _args['reactions_as_tags'] = bool(flags & (1 << 3))
        reader.read_int(signed=False)  # skip vector id
        _count_results = reader.read_int()
        _list_results = []
        for _ in range(_count_results):
            _item_results = reader.tgread_object()
            _list_results.append(_item_results)
        _args['results'] = _list_results
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_recent_reactions = reader.read_int()
            _list_recent_reactions = []
            for _ in range(_count_recent_reactions):
                _item_recent_reactions = reader.tgread_object()
                _list_recent_reactions.append(_item_recent_reactions)
            _args['recent_reactions'] = _list_recent_reactions
        else:
            _args['recent_reactions'] = None
        if flags & (1 << 4):
            reader.read_int(signed=False)  # skip vector id
            _count_top_reactors = reader.read_int()
            _list_top_reactors = []
            for _ in range(_count_top_reactors):
                _item_top_reactors = reader.tgread_object()
                _list_top_reactors.append(_item_top_reactors)
            _args['top_reactors'] = _list_top_reactors
        else:
            _args['top_reactors'] = None
        return cls(**_args)


class MessageReactor(TLObject):
    """TL type: messageReactor"""
    CONSTRUCTOR_ID = 0x4ba3a95a
    SUBCLASS_OF_ID = 0xf0381ab9

    def __init__(self, count: int, top: Optional[bool] = None, my: Optional[bool] = None, anonymous: Optional[bool] = None, peer_id: Optional['TypePeer'] = None):
        self.count = count
        self.top = top
        self.my = my
        self.anonymous = anonymous
        self.peer_id = peer_id

    def to_dict(self):
        return {
            '_': 'MessageReactor',
            'count': self.count,
            'top': self.top,
            'my': self.my,
            'anonymous': self.anonymous,
            'peer_id': self.peer_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.top:
            flags |= (1 << 0)
        if self.my:
            flags |= (1 << 1)
        if self.anonymous:
            flags |= (1 << 2)
        if self.peer_id is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.count))
        if self.peer_id is not None:
            buf.write(bytes(self.peer_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['top'] = bool(flags & (1 << 0))
        _args['my'] = bool(flags & (1 << 1))
        _args['anonymous'] = bool(flags & (1 << 2))
        if flags & (1 << 3):
            _val_peer_id = reader.tgread_object()
            _args['peer_id'] = _val_peer_id
        else:
            _args['peer_id'] = None
        _val_count = reader.read_int()
        _args['count'] = _val_count
        return cls(**_args)


class MessageReplies(TLObject):
    """TL type: messageReplies"""
    CONSTRUCTOR_ID = 0x83d60fc2
    SUBCLASS_OF_ID = 0x6ccd5ce2

    def __init__(self, replies: int, replies_pts: int, comments: Optional[bool] = None, recent_repliers: Optional[List['TypePeer']] = None, channel_id: Optional[int] = None, max_id: Optional[int] = None, read_max_id: Optional[int] = None):
        self.replies = replies
        self.replies_pts = replies_pts
        self.comments = comments
        self.recent_repliers = recent_repliers
        self.channel_id = channel_id
        self.max_id = max_id
        self.read_max_id = read_max_id

    def to_dict(self):
        return {
            '_': 'MessageReplies',
            'replies': self.replies,
            'replies_pts': self.replies_pts,
            'comments': self.comments,
            'recent_repliers': self.recent_repliers,
            'channel_id': self.channel_id,
            'max_id': self.max_id,
            'read_max_id': self.read_max_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.channel_id is not None:
            flags |= (1 << 0)
        if self.recent_repliers is not None:
            flags |= (1 << 1)
        if self.max_id is not None:
            flags |= (1 << 2)
        if self.read_max_id is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.replies))
        buf.write(struct.pack('<i', self.replies_pts))
        if self.recent_repliers is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.recent_repliers)))
            for item in self.recent_repliers:
                buf.write(bytes(self.item))
        if self.channel_id is not None:
            buf.write(struct.pack('<q', self.channel_id))
        if self.max_id is not None:
            buf.write(struct.pack('<i', self.max_id))
        if self.read_max_id is not None:
            buf.write(struct.pack('<i', self.read_max_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['comments'] = bool(flags & (1 << 0))
        _val_replies = reader.read_int()
        _args['replies'] = _val_replies
        _val_replies_pts = reader.read_int()
        _args['replies_pts'] = _val_replies_pts
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_recent_repliers = reader.read_int()
            _list_recent_repliers = []
            for _ in range(_count_recent_repliers):
                _item_recent_repliers = reader.tgread_object()
                _list_recent_repliers.append(_item_recent_repliers)
            _args['recent_repliers'] = _list_recent_repliers
        else:
            _args['recent_repliers'] = None
        if flags & (1 << 0):
            _val_channel_id = reader.read_long()
            _args['channel_id'] = _val_channel_id
        else:
            _args['channel_id'] = None
        if flags & (1 << 2):
            _val_max_id = reader.read_int()
            _args['max_id'] = _val_max_id
        else:
            _args['max_id'] = None
        if flags & (1 << 3):
            _val_read_max_id = reader.read_int()
            _args['read_max_id'] = _val_read_max_id
        else:
            _args['read_max_id'] = None
        return cls(**_args)


class MessageReplyHeader(TLObject):
    """TL type: messageReplyHeader"""
    CONSTRUCTOR_ID = 0x6917560b
    SUBCLASS_OF_ID = 0x5b4d9167

    def __init__(self, reply_to_scheduled: Optional[bool] = None, forum_topic: Optional[bool] = None, quote: Optional[bool] = None, reply_to_msg_id: Optional[int] = None, reply_to_peer_id: Optional['TypePeer'] = None, reply_from: Optional['TypeMessageFwdHeader'] = None, reply_media: Optional['TypeMessageMedia'] = None, reply_to_top_id: Optional[int] = None, quote_text: Optional[str] = None, quote_entities: Optional[List['TypeMessageEntity']] = None, quote_offset: Optional[int] = None, todo_item_id: Optional[int] = None):
        self.reply_to_scheduled = reply_to_scheduled
        self.forum_topic = forum_topic
        self.quote = quote
        self.reply_to_msg_id = reply_to_msg_id
        self.reply_to_peer_id = reply_to_peer_id
        self.reply_from = reply_from
        self.reply_media = reply_media
        self.reply_to_top_id = reply_to_top_id
        self.quote_text = quote_text
        self.quote_entities = quote_entities
        self.quote_offset = quote_offset
        self.todo_item_id = todo_item_id

    def to_dict(self):
        return {
            '_': 'MessageReplyHeader',
            'reply_to_scheduled': self.reply_to_scheduled,
            'forum_topic': self.forum_topic,
            'quote': self.quote,
            'reply_to_msg_id': self.reply_to_msg_id,
            'reply_to_peer_id': self.reply_to_peer_id,
            'reply_from': self.reply_from,
            'reply_media': self.reply_media,
            'reply_to_top_id': self.reply_to_top_id,
            'quote_text': self.quote_text,
            'quote_entities': self.quote_entities,
            'quote_offset': self.quote_offset,
            'todo_item_id': self.todo_item_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reply_to_scheduled:
            flags |= (1 << 2)
        if self.forum_topic:
            flags |= (1 << 3)
        if self.quote:
            flags |= (1 << 9)
        if self.reply_to_msg_id is not None:
            flags |= (1 << 4)
        if self.reply_to_peer_id is not None:
            flags |= (1 << 0)
        if self.reply_from is not None:
            flags |= (1 << 5)
        if self.reply_media is not None:
            flags |= (1 << 8)
        if self.reply_to_top_id is not None:
            flags |= (1 << 1)
        if self.quote_text is not None:
            flags |= (1 << 6)
        if self.quote_entities is not None:
            flags |= (1 << 7)
        if self.quote_offset is not None:
            flags |= (1 << 10)
        if self.todo_item_id is not None:
            flags |= (1 << 11)
        buf.write(struct.pack('<I', flags))
        if self.reply_to_msg_id is not None:
            buf.write(struct.pack('<i', self.reply_to_msg_id))
        if self.reply_to_peer_id is not None:
            buf.write(bytes(self.reply_to_peer_id))
        if self.reply_from is not None:
            buf.write(bytes(self.reply_from))
        if self.reply_media is not None:
            buf.write(bytes(self.reply_media))
        if self.reply_to_top_id is not None:
            buf.write(struct.pack('<i', self.reply_to_top_id))
        if self.quote_text is not None:
            buf.write(TLObject.serialize_bytes(self.quote_text))
        if self.quote_entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.quote_entities)))
            for item in self.quote_entities:
                buf.write(bytes(self.item))
        if self.quote_offset is not None:
            buf.write(struct.pack('<i', self.quote_offset))
        if self.todo_item_id is not None:
            buf.write(struct.pack('<i', self.todo_item_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['reply_to_scheduled'] = bool(flags & (1 << 2))
        _args['forum_topic'] = bool(flags & (1 << 3))
        _args['quote'] = bool(flags & (1 << 9))
        if flags & (1 << 4):
            _val_reply_to_msg_id = reader.read_int()
            _args['reply_to_msg_id'] = _val_reply_to_msg_id
        else:
            _args['reply_to_msg_id'] = None
        if flags & (1 << 0):
            _val_reply_to_peer_id = reader.tgread_object()
            _args['reply_to_peer_id'] = _val_reply_to_peer_id
        else:
            _args['reply_to_peer_id'] = None
        if flags & (1 << 5):
            _val_reply_from = reader.tgread_object()
            _args['reply_from'] = _val_reply_from
        else:
            _args['reply_from'] = None
        if flags & (1 << 8):
            _val_reply_media = reader.tgread_object()
            _args['reply_media'] = _val_reply_media
        else:
            _args['reply_media'] = None
        if flags & (1 << 1):
            _val_reply_to_top_id = reader.read_int()
            _args['reply_to_top_id'] = _val_reply_to_top_id
        else:
            _args['reply_to_top_id'] = None
        if flags & (1 << 6):
            _val_quote_text = reader.tgread_string()
            _args['quote_text'] = _val_quote_text
        else:
            _args['quote_text'] = None
        if flags & (1 << 7):
            reader.read_int(signed=False)  # skip vector id
            _count_quote_entities = reader.read_int()
            _list_quote_entities = []
            for _ in range(_count_quote_entities):
                _item_quote_entities = reader.tgread_object()
                _list_quote_entities.append(_item_quote_entities)
            _args['quote_entities'] = _list_quote_entities
        else:
            _args['quote_entities'] = None
        if flags & (1 << 10):
            _val_quote_offset = reader.read_int()
            _args['quote_offset'] = _val_quote_offset
        else:
            _args['quote_offset'] = None
        if flags & (1 << 11):
            _val_todo_item_id = reader.read_int()
            _args['todo_item_id'] = _val_todo_item_id
        else:
            _args['todo_item_id'] = None
        return cls(**_args)


class MessageReplyStoryHeader(TLObject):
    """TL type: messageReplyStoryHeader"""
    CONSTRUCTOR_ID = 0x0e5af939
    SUBCLASS_OF_ID = 0x5b4d9167

    def __init__(self, peer: 'TypePeer', story_id: int):
        self.peer = peer
        self.story_id = story_id

    def to_dict(self):
        return {
            '_': 'MessageReplyStoryHeader',
            'peer': self.peer,
            'story_id': self.story_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.story_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_story_id = reader.read_int()
        _args['story_id'] = _val_story_id
        return cls(**_args)


class MessageReportOption(TLObject):
    """TL type: messageReportOption"""
    CONSTRUCTOR_ID = 0x7903e3d9
    SUBCLASS_OF_ID = 0xfd79af88

    def __init__(self, text: str, option: bytes):
        self.text = text
        self.option = option

    def to_dict(self):
        return {
            '_': 'MessageReportOption',
            'text': self.text,
            'option': self.option,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.option))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_option = reader.tgread_bytes()
        _args['option'] = _val_option
        return cls(**_args)


class MessageService(TLObject):
    """TL type: messageService"""
    CONSTRUCTOR_ID = 0x7a800e0a
    SUBCLASS_OF_ID = 0x790009e3

    def __init__(self, id: int, peer_id: 'TypePeer', date: Optional[datetime], action: 'TypeMessageAction', out: Optional[bool] = None, mentioned: Optional[bool] = None, media_unread: Optional[bool] = None, reactions_are_possible: Optional[bool] = None, silent: Optional[bool] = None, post: Optional[bool] = None, legacy: Optional[bool] = None, from_id: Optional['TypePeer'] = None, saved_peer_id: Optional['TypePeer'] = None, reply_to: Optional['TypeMessageReplyHeader'] = None, reactions: Optional['TypeMessageReactions'] = None, ttl_period: Optional[int] = None):
        self.id = id
        self.peer_id = peer_id
        self.date = date
        self.action = action
        self.out = out
        self.mentioned = mentioned
        self.media_unread = media_unread
        self.reactions_are_possible = reactions_are_possible
        self.silent = silent
        self.post = post
        self.legacy = legacy
        self.from_id = from_id
        self.saved_peer_id = saved_peer_id
        self.reply_to = reply_to
        self.reactions = reactions
        self.ttl_period = ttl_period

    def to_dict(self):
        return {
            '_': 'MessageService',
            'id': self.id,
            'peer_id': self.peer_id,
            'date': self.date,
            'action': self.action,
            'out': self.out,
            'mentioned': self.mentioned,
            'media_unread': self.media_unread,
            'reactions_are_possible': self.reactions_are_possible,
            'silent': self.silent,
            'post': self.post,
            'legacy': self.legacy,
            'from_id': self.from_id,
            'saved_peer_id': self.saved_peer_id,
            'reply_to': self.reply_to,
            'reactions': self.reactions,
            'ttl_period': self.ttl_period,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.out:
            flags |= (1 << 1)
        if self.mentioned:
            flags |= (1 << 4)
        if self.media_unread:
            flags |= (1 << 5)
        if self.reactions_are_possible:
            flags |= (1 << 9)
        if self.silent:
            flags |= (1 << 13)
        if self.post:
            flags |= (1 << 14)
        if self.legacy:
            flags |= (1 << 19)
        if self.from_id is not None:
            flags |= (1 << 8)
        if self.saved_peer_id is not None:
            flags |= (1 << 28)
        if self.reply_to is not None:
            flags |= (1 << 3)
        if self.reactions is not None:
            flags |= (1 << 20)
        if self.ttl_period is not None:
            flags |= (1 << 25)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(bytes(self.peer_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(bytes(self.action))
        if self.from_id is not None:
            buf.write(bytes(self.from_id))
        if self.saved_peer_id is not None:
            buf.write(bytes(self.saved_peer_id))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        if self.reactions is not None:
            buf.write(bytes(self.reactions))
        if self.ttl_period is not None:
            buf.write(struct.pack('<i', self.ttl_period))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['out'] = bool(flags & (1 << 1))
        _args['mentioned'] = bool(flags & (1 << 4))
        _args['media_unread'] = bool(flags & (1 << 5))
        _args['reactions_are_possible'] = bool(flags & (1 << 9))
        _args['silent'] = bool(flags & (1 << 13))
        _args['post'] = bool(flags & (1 << 14))
        _args['legacy'] = bool(flags & (1 << 19))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        if flags & (1 << 8):
            _val_from_id = reader.tgread_object()
            _args['from_id'] = _val_from_id
        else:
            _args['from_id'] = None
        _val_peer_id = reader.tgread_object()
        _args['peer_id'] = _val_peer_id
        if flags & (1 << 28):
            _val_saved_peer_id = reader.tgread_object()
            _args['saved_peer_id'] = _val_saved_peer_id
        else:
            _args['saved_peer_id'] = None
        if flags & (1 << 3):
            _val_reply_to = reader.tgread_object()
            _args['reply_to'] = _val_reply_to
        else:
            _args['reply_to'] = None
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_action = reader.tgread_object()
        _args['action'] = _val_action
        if flags & (1 << 20):
            _val_reactions = reader.tgread_object()
            _args['reactions'] = _val_reactions
        else:
            _args['reactions'] = None
        if flags & (1 << 25):
            _val_ttl_period = reader.read_int()
            _args['ttl_period'] = _val_ttl_period
        else:
            _args['ttl_period'] = None
        return cls(**_args)


class MessageViews(TLObject):
    """TL type: messageViews"""
    CONSTRUCTOR_ID = 0x455b853d
    SUBCLASS_OF_ID = 0x3cb083b9

    def __init__(self, views: Optional[int] = None, forwards: Optional[int] = None, replies: Optional['TypeMessageReplies'] = None):
        self.views = views
        self.forwards = forwards
        self.replies = replies

    def to_dict(self):
        return {
            '_': 'MessageViews',
            'views': self.views,
            'forwards': self.forwards,
            'replies': self.replies,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.views is not None:
            flags |= (1 << 0)
        if self.forwards is not None:
            flags |= (1 << 1)
        if self.replies is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.views is not None:
            buf.write(struct.pack('<i', self.views))
        if self.forwards is not None:
            buf.write(struct.pack('<i', self.forwards))
        if self.replies is not None:
            buf.write(bytes(self.replies))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_views = reader.read_int()
            _args['views'] = _val_views
        else:
            _args['views'] = None
        if flags & (1 << 1):
            _val_forwards = reader.read_int()
            _args['forwards'] = _val_forwards
        else:
            _args['forwards'] = None
        if flags & (1 << 2):
            _val_replies = reader.tgread_object()
            _args['replies'] = _val_replies
        else:
            _args['replies'] = None
        return cls(**_args)


class MissingInvitee(TLObject):
    """TL type: missingInvitee"""
    CONSTRUCTOR_ID = 0x628c9224
    SUBCLASS_OF_ID = 0x5c8cacdc

    def __init__(self, user_id: int, premium_would_allow_invite: Optional[bool] = None, premium_required_for_pm: Optional[bool] = None):
        self.user_id = user_id
        self.premium_would_allow_invite = premium_would_allow_invite
        self.premium_required_for_pm = premium_required_for_pm

    def to_dict(self):
        return {
            '_': 'MissingInvitee',
            'user_id': self.user_id,
            'premium_would_allow_invite': self.premium_would_allow_invite,
            'premium_required_for_pm': self.premium_required_for_pm,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.premium_would_allow_invite:
            flags |= (1 << 0)
        if self.premium_required_for_pm:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['premium_would_allow_invite'] = bool(flags & (1 << 0))
        _args['premium_required_for_pm'] = bool(flags & (1 << 1))
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class MonoForumDialog(TLObject):
    """TL type: monoForumDialog"""
    CONSTRUCTOR_ID = 0x64407ea7
    SUBCLASS_OF_ID = 0x23ba6506

    def __init__(self, peer: 'TypePeer', top_message: int, read_inbox_max_id: int, read_outbox_max_id: int, unread_count: int, unread_reactions_count: int, unread_mark: Optional[bool] = None, nopaid_messages_exception: Optional[bool] = None, draft: Optional['TypeDraftMessage'] = None):
        self.peer = peer
        self.top_message = top_message
        self.read_inbox_max_id = read_inbox_max_id
        self.read_outbox_max_id = read_outbox_max_id
        self.unread_count = unread_count
        self.unread_reactions_count = unread_reactions_count
        self.unread_mark = unread_mark
        self.nopaid_messages_exception = nopaid_messages_exception
        self.draft = draft

    def to_dict(self):
        return {
            '_': 'MonoForumDialog',
            'peer': self.peer,
            'top_message': self.top_message,
            'read_inbox_max_id': self.read_inbox_max_id,
            'read_outbox_max_id': self.read_outbox_max_id,
            'unread_count': self.unread_count,
            'unread_reactions_count': self.unread_reactions_count,
            'unread_mark': self.unread_mark,
            'nopaid_messages_exception': self.nopaid_messages_exception,
            'draft': self.draft,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.unread_mark:
            flags |= (1 << 3)
        if self.nopaid_messages_exception:
            flags |= (1 << 4)
        if self.draft is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.top_message))
        buf.write(struct.pack('<i', self.read_inbox_max_id))
        buf.write(struct.pack('<i', self.read_outbox_max_id))
        buf.write(struct.pack('<i', self.unread_count))
        buf.write(struct.pack('<i', self.unread_reactions_count))
        if self.draft is not None:
            buf.write(bytes(self.draft))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['unread_mark'] = bool(flags & (1 << 3))
        _args['nopaid_messages_exception'] = bool(flags & (1 << 4))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_top_message = reader.read_int()
        _args['top_message'] = _val_top_message
        _val_read_inbox_max_id = reader.read_int()
        _args['read_inbox_max_id'] = _val_read_inbox_max_id
        _val_read_outbox_max_id = reader.read_int()
        _args['read_outbox_max_id'] = _val_read_outbox_max_id
        _val_unread_count = reader.read_int()
        _args['unread_count'] = _val_unread_count
        _val_unread_reactions_count = reader.read_int()
        _args['unread_reactions_count'] = _val_unread_reactions_count
        if flags & (1 << 1):
            _val_draft = reader.tgread_object()
            _args['draft'] = _val_draft
        else:
            _args['draft'] = None
        return cls(**_args)


class MyBoost(TLObject):
    """TL type: myBoost"""
    CONSTRUCTOR_ID = 0xc448415c
    SUBCLASS_OF_ID = 0xc51a68bf

    def __init__(self, slot: int, date: Optional[datetime], expires: Optional[datetime], peer: Optional['TypePeer'] = None, cooldown_until_date: Optional[datetime] = None):
        self.slot = slot
        self.date = date
        self.expires = expires
        self.peer = peer
        self.cooldown_until_date = cooldown_until_date

    def to_dict(self):
        return {
            '_': 'MyBoost',
            'slot': self.slot,
            'date': self.date,
            'expires': self.expires,
            'peer': self.peer,
            'cooldown_until_date': self.cooldown_until_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.peer is not None:
            flags |= (1 << 0)
        if self.cooldown_until_date is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.slot))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.expires))
        if self.peer is not None:
            buf.write(bytes(self.peer))
        if self.cooldown_until_date is not None:
            buf.write(struct.pack('<i', self.cooldown_until_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_slot = reader.read_int()
        _args['slot'] = _val_slot
        if flags & (1 << 0):
            _val_peer = reader.tgread_object()
            _args['peer'] = _val_peer
        else:
            _args['peer'] = None
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_expires = reader.read_int()
        _args['expires'] = _val_expires
        if flags & (1 << 1):
            _val_cooldown_until_date = reader.read_int()
            _args['cooldown_until_date'] = _val_cooldown_until_date
        else:
            _args['cooldown_until_date'] = None
        return cls(**_args)


class NearestDc(TLObject):
    """TL type: nearestDc"""
    CONSTRUCTOR_ID = 0x8e1a1775
    SUBCLASS_OF_ID = 0x3877045f

    def __init__(self, country: str, this_dc: int, nearest_dc: int):
        self.country = country
        self.this_dc = this_dc
        self.nearest_dc = nearest_dc

    def to_dict(self):
        return {
            '_': 'NearestDc',
            'country': self.country,
            'this_dc': self.this_dc,
            'nearest_dc': self.nearest_dc,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.country))
        buf.write(struct.pack('<i', self.this_dc))
        buf.write(struct.pack('<i', self.nearest_dc))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_country = reader.tgread_string()
        _args['country'] = _val_country
        _val_this_dc = reader.read_int()
        _args['this_dc'] = _val_this_dc
        _val_nearest_dc = reader.read_int()
        _args['nearest_dc'] = _val_nearest_dc
        return cls(**_args)


class NotificationSoundDefault(TLObject):
    """TL type: notificationSoundDefault"""
    CONSTRUCTOR_ID = 0x97e8bebe
    SUBCLASS_OF_ID = 0xf2f5e55b

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'NotificationSoundDefault',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class NotificationSoundLocal(TLObject):
    """TL type: notificationSoundLocal"""
    CONSTRUCTOR_ID = 0x830b9ae4
    SUBCLASS_OF_ID = 0xf2f5e55b

    def __init__(self, title: str, data: str):
        self.title = title
        self.data = data

    def to_dict(self):
        return {
            '_': 'NotificationSoundLocal',
            'title': self.title,
            'data': self.data,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_data = reader.tgread_string()
        _args['data'] = _val_data
        return cls(**_args)


class NotificationSoundNone(TLObject):
    """TL type: notificationSoundNone"""
    CONSTRUCTOR_ID = 0x6f0c34df
    SUBCLASS_OF_ID = 0xf2f5e55b

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'NotificationSoundNone',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class NotificationSoundRingtone(TLObject):
    """TL type: notificationSoundRingtone"""
    CONSTRUCTOR_ID = 0xff6c8049
    SUBCLASS_OF_ID = 0xf2f5e55b

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'NotificationSoundRingtone',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        return cls(**_args)


class NotifyBroadcasts(TLObject):
    """TL type: notifyBroadcasts"""
    CONSTRUCTOR_ID = 0xd612e8ef
    SUBCLASS_OF_ID = 0xdfe8602e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'NotifyBroadcasts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class NotifyChats(TLObject):
    """TL type: notifyChats"""
    CONSTRUCTOR_ID = 0xc007cec3
    SUBCLASS_OF_ID = 0xdfe8602e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'NotifyChats',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class NotifyForumTopic(TLObject):
    """TL type: notifyForumTopic"""
    CONSTRUCTOR_ID = 0x226e6308
    SUBCLASS_OF_ID = 0xdfe8602e

    def __init__(self, peer: 'TypePeer', top_msg_id: int):
        self.peer = peer
        self.top_msg_id = top_msg_id

    def to_dict(self):
        return {
            '_': 'NotifyForumTopic',
            'peer': self.peer,
            'top_msg_id': self.top_msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.top_msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_top_msg_id = reader.read_int()
        _args['top_msg_id'] = _val_top_msg_id
        return cls(**_args)


class NotifyPeer(TLObject):
    """TL type: notifyPeer"""
    CONSTRUCTOR_ID = 0x9fd40bd8
    SUBCLASS_OF_ID = 0xdfe8602e

    def __init__(self, peer: 'TypePeer'):
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'NotifyPeer',
            'peer': self.peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class NotifyUsers(TLObject):
    """TL type: notifyUsers"""
    CONSTRUCTOR_ID = 0xb4c83b4c
    SUBCLASS_OF_ID = 0xdfe8602e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'NotifyUsers',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class OutboxReadDate(TLObject):
    """TL type: outboxReadDate"""
    CONSTRUCTOR_ID = 0x3bb842ac
    SUBCLASS_OF_ID = 0x6f5183c6

    def __init__(self, date: Optional[datetime]):
        self.date = date

    def to_dict(self):
        return {
            '_': 'OutboxReadDate',
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class Page(TLObject):
    """TL type: page"""
    CONSTRUCTOR_ID = 0x98657f0d
    SUBCLASS_OF_ID = 0xb438191e

    def __init__(self, url: str, blocks: List['TypePageBlock'], photos: List['TypePhoto'], documents: List['TypeDocument'], part: Optional[bool] = None, rtl: Optional[bool] = None, v2: Optional[bool] = None, views: Optional[int] = None):
        self.url = url
        self.blocks = blocks
        self.photos = photos
        self.documents = documents
        self.part = part
        self.rtl = rtl
        self.v2 = v2
        self.views = views

    def to_dict(self):
        return {
            '_': 'Page',
            'url': self.url,
            'blocks': self.blocks,
            'photos': self.photos,
            'documents': self.documents,
            'part': self.part,
            'rtl': self.rtl,
            'v2': self.v2,
            'views': self.views,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.part:
            flags |= (1 << 0)
        if self.rtl:
            flags |= (1 << 1)
        if self.v2:
            flags |= (1 << 2)
        if self.views is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.blocks)))
        for item in self.blocks:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.photos)))
        for item in self.photos:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.documents)))
        for item in self.documents:
            buf.write(bytes(self.item))
        if self.views is not None:
            buf.write(struct.pack('<i', self.views))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['part'] = bool(flags & (1 << 0))
        _args['rtl'] = bool(flags & (1 << 1))
        _args['v2'] = bool(flags & (1 << 2))
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        reader.read_int(signed=False)  # skip vector id
        _count_blocks = reader.read_int()
        _list_blocks = []
        for _ in range(_count_blocks):
            _item_blocks = reader.tgread_object()
            _list_blocks.append(_item_blocks)
        _args['blocks'] = _list_blocks
        reader.read_int(signed=False)  # skip vector id
        _count_photos = reader.read_int()
        _list_photos = []
        for _ in range(_count_photos):
            _item_photos = reader.tgread_object()
            _list_photos.append(_item_photos)
        _args['photos'] = _list_photos
        reader.read_int(signed=False)  # skip vector id
        _count_documents = reader.read_int()
        _list_documents = []
        for _ in range(_count_documents):
            _item_documents = reader.tgread_object()
            _list_documents.append(_item_documents)
        _args['documents'] = _list_documents
        if flags & (1 << 3):
            _val_views = reader.read_int()
            _args['views'] = _val_views
        else:
            _args['views'] = None
        return cls(**_args)


class PageBlockAnchor(TLObject):
    """TL type: pageBlockAnchor"""
    CONSTRUCTOR_ID = 0xce0d37b0
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, name: str):
        self.name = name

    def to_dict(self):
        return {
            '_': 'PageBlockAnchor',
            'name': self.name,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.name))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        return cls(**_args)


class PageBlockAudio(TLObject):
    """TL type: pageBlockAudio"""
    CONSTRUCTOR_ID = 0x804361ea
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, audio_id: int, caption: 'TypePageCaption'):
        self.audio_id = audio_id
        self.caption = caption

    def to_dict(self):
        return {
            '_': 'PageBlockAudio',
            'audio_id': self.audio_id,
            'caption': self.caption,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.audio_id))
        buf.write(bytes(self.caption))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_audio_id = reader.read_long()
        _args['audio_id'] = _val_audio_id
        _val_caption = reader.tgread_object()
        _args['caption'] = _val_caption
        return cls(**_args)


class PageBlockAuthorDate(TLObject):
    """TL type: pageBlockAuthorDate"""
    CONSTRUCTOR_ID = 0xbaafe5e0
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, author: 'TypeRichText', published_date: Optional[datetime]):
        self.author = author
        self.published_date = published_date

    def to_dict(self):
        return {
            '_': 'PageBlockAuthorDate',
            'author': self.author,
            'published_date': self.published_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.author))
        buf.write(struct.pack('<i', self.published_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_author = reader.tgread_object()
        _args['author'] = _val_author
        _val_published_date = reader.read_int()
        _args['published_date'] = _val_published_date
        return cls(**_args)


class PageBlockBlockquote(TLObject):
    """TL type: pageBlockBlockquote"""
    CONSTRUCTOR_ID = 0x263d7c26
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, text: 'TypeRichText', caption: 'TypeRichText'):
        self.text = text
        self.caption = caption

    def to_dict(self):
        return {
            '_': 'PageBlockBlockquote',
            'text': self.text,
            'caption': self.caption,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        buf.write(bytes(self.caption))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        _val_caption = reader.tgread_object()
        _args['caption'] = _val_caption
        return cls(**_args)


class PageBlockChannel(TLObject):
    """TL type: pageBlockChannel"""
    CONSTRUCTOR_ID = 0xef1751b5
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, channel: 'TypeChat'):
        self.channel = channel

    def to_dict(self):
        return {
            '_': 'PageBlockChannel',
            'channel': self.channel,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.channel))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        return cls(**_args)


class PageBlockCollage(TLObject):
    """TL type: pageBlockCollage"""
    CONSTRUCTOR_ID = 0x65a0fa4d
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, items: List['TypePageBlock'], caption: 'TypePageCaption'):
        self.items = items
        self.caption = caption

    def to_dict(self):
        return {
            '_': 'PageBlockCollage',
            'items': self.items,
            'caption': self.caption,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.items)))
        for item in self.items:
            buf.write(bytes(self.item))
        buf.write(bytes(self.caption))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_items = reader.read_int()
        _list_items = []
        for _ in range(_count_items):
            _item_items = reader.tgread_object()
            _list_items.append(_item_items)
        _args['items'] = _list_items
        _val_caption = reader.tgread_object()
        _args['caption'] = _val_caption
        return cls(**_args)


class PageBlockCover(TLObject):
    """TL type: pageBlockCover"""
    CONSTRUCTOR_ID = 0x39f23300
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, cover: 'TypePageBlock'):
        self.cover = cover

    def to_dict(self):
        return {
            '_': 'PageBlockCover',
            'cover': self.cover,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.cover))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_cover = reader.tgread_object()
        _args['cover'] = _val_cover
        return cls(**_args)


class PageBlockDetails(TLObject):
    """TL type: pageBlockDetails"""
    CONSTRUCTOR_ID = 0x76768bed
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, blocks: List['TypePageBlock'], title: 'TypeRichText', open: Optional[bool] = None):
        self.blocks = blocks
        self.title = title
        self.open = open

    def to_dict(self):
        return {
            '_': 'PageBlockDetails',
            'blocks': self.blocks,
            'title': self.title,
            'open': self.open,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.open:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.blocks)))
        for item in self.blocks:
            buf.write(bytes(self.item))
        buf.write(bytes(self.title))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['open'] = bool(flags & (1 << 0))
        reader.read_int(signed=False)  # skip vector id
        _count_blocks = reader.read_int()
        _list_blocks = []
        for _ in range(_count_blocks):
            _item_blocks = reader.tgread_object()
            _list_blocks.append(_item_blocks)
        _args['blocks'] = _list_blocks
        _val_title = reader.tgread_object()
        _args['title'] = _val_title
        return cls(**_args)


class PageBlockDivider(TLObject):
    """TL type: pageBlockDivider"""
    CONSTRUCTOR_ID = 0xdb20b188
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PageBlockDivider',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PageBlockEmbed(TLObject):
    """TL type: pageBlockEmbed"""
    CONSTRUCTOR_ID = 0xa8718dc5
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, caption: 'TypePageCaption', full_width: Optional[bool] = None, allow_scrolling: Optional[bool] = None, url: Optional[str] = None, html: Optional[str] = None, poster_photo_id: Optional[int] = None, w: Optional[int] = None, h: Optional[int] = None):
        self.caption = caption
        self.full_width = full_width
        self.allow_scrolling = allow_scrolling
        self.url = url
        self.html = html
        self.poster_photo_id = poster_photo_id
        self.w = w
        self.h = h

    def to_dict(self):
        return {
            '_': 'PageBlockEmbed',
            'caption': self.caption,
            'full_width': self.full_width,
            'allow_scrolling': self.allow_scrolling,
            'url': self.url,
            'html': self.html,
            'poster_photo_id': self.poster_photo_id,
            'w': self.w,
            'h': self.h,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.full_width:
            flags |= (1 << 0)
        if self.allow_scrolling:
            flags |= (1 << 3)
        if self.url is not None:
            flags |= (1 << 1)
        if self.html is not None:
            flags |= (1 << 2)
        if self.poster_photo_id is not None:
            flags |= (1 << 4)
        if self.h is not None:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.caption))
        if self.url is not None:
            buf.write(TLObject.serialize_bytes(self.url))
        if self.html is not None:
            buf.write(TLObject.serialize_bytes(self.html))
        if self.poster_photo_id is not None:
            buf.write(struct.pack('<q', self.poster_photo_id))
        if self.w is not None:
            buf.write(struct.pack('<i', self.w))
        if self.h is not None:
            buf.write(struct.pack('<i', self.h))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['full_width'] = bool(flags & (1 << 0))
        _args['allow_scrolling'] = bool(flags & (1 << 3))
        if flags & (1 << 1):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        if flags & (1 << 2):
            _val_html = reader.tgread_string()
            _args['html'] = _val_html
        else:
            _args['html'] = None
        if flags & (1 << 4):
            _val_poster_photo_id = reader.read_long()
            _args['poster_photo_id'] = _val_poster_photo_id
        else:
            _args['poster_photo_id'] = None
        if flags & (1 << 5):
            _val_w = reader.read_int()
            _args['w'] = _val_w
        else:
            _args['w'] = None
        if flags & (1 << 5):
            _val_h = reader.read_int()
            _args['h'] = _val_h
        else:
            _args['h'] = None
        _val_caption = reader.tgread_object()
        _args['caption'] = _val_caption
        return cls(**_args)


class PageBlockEmbedPost(TLObject):
    """TL type: pageBlockEmbedPost"""
    CONSTRUCTOR_ID = 0xf259a80b
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, url: str, webpage_id: int, author_photo_id: int, author: str, date: Optional[datetime], blocks: List['TypePageBlock'], caption: 'TypePageCaption'):
        self.url = url
        self.webpage_id = webpage_id
        self.author_photo_id = author_photo_id
        self.author = author
        self.date = date
        self.blocks = blocks
        self.caption = caption

    def to_dict(self):
        return {
            '_': 'PageBlockEmbedPost',
            'url': self.url,
            'webpage_id': self.webpage_id,
            'author_photo_id': self.author_photo_id,
            'author': self.author,
            'date': self.date,
            'blocks': self.blocks,
            'caption': self.caption,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<q', self.webpage_id))
        buf.write(struct.pack('<q', self.author_photo_id))
        buf.write(TLObject.serialize_bytes(self.author))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.blocks)))
        for item in self.blocks:
            buf.write(bytes(self.item))
        buf.write(bytes(self.caption))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_webpage_id = reader.read_long()
        _args['webpage_id'] = _val_webpage_id
        _val_author_photo_id = reader.read_long()
        _args['author_photo_id'] = _val_author_photo_id
        _val_author = reader.tgread_string()
        _args['author'] = _val_author
        _val_date = reader.read_int()
        _args['date'] = _val_date
        reader.read_int(signed=False)  # skip vector id
        _count_blocks = reader.read_int()
        _list_blocks = []
        for _ in range(_count_blocks):
            _item_blocks = reader.tgread_object()
            _list_blocks.append(_item_blocks)
        _args['blocks'] = _list_blocks
        _val_caption = reader.tgread_object()
        _args['caption'] = _val_caption
        return cls(**_args)


class PageBlockFooter(TLObject):
    """TL type: pageBlockFooter"""
    CONSTRUCTOR_ID = 0x48870999
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'PageBlockFooter',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class PageBlockHeader(TLObject):
    """TL type: pageBlockHeader"""
    CONSTRUCTOR_ID = 0xbfd064ec
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'PageBlockHeader',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class PageBlockKicker(TLObject):
    """TL type: pageBlockKicker"""
    CONSTRUCTOR_ID = 0x1e148390
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'PageBlockKicker',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class PageBlockList(TLObject):
    """TL type: pageBlockList"""
    CONSTRUCTOR_ID = 0xe4e88011
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, items: List['TypePageListItem']):
        self.items = items

    def to_dict(self):
        return {
            '_': 'PageBlockList',
            'items': self.items,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.items)))
        for item in self.items:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_items = reader.read_int()
        _list_items = []
        for _ in range(_count_items):
            _item_items = reader.tgread_object()
            _list_items.append(_item_items)
        _args['items'] = _list_items
        return cls(**_args)


class PageBlockMap(TLObject):
    """TL type: pageBlockMap"""
    CONSTRUCTOR_ID = 0xa44f3ef6
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, geo: 'TypeGeoPoint', zoom: int, w: int, h: int, caption: 'TypePageCaption'):
        self.geo = geo
        self.zoom = zoom
        self.w = w
        self.h = h
        self.caption = caption

    def to_dict(self):
        return {
            '_': 'PageBlockMap',
            'geo': self.geo,
            'zoom': self.zoom,
            'w': self.w,
            'h': self.h,
            'caption': self.caption,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.geo))
        buf.write(struct.pack('<i', self.zoom))
        buf.write(struct.pack('<i', self.w))
        buf.write(struct.pack('<i', self.h))
        buf.write(bytes(self.caption))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_geo = reader.tgread_object()
        _args['geo'] = _val_geo
        _val_zoom = reader.read_int()
        _args['zoom'] = _val_zoom
        _val_w = reader.read_int()
        _args['w'] = _val_w
        _val_h = reader.read_int()
        _args['h'] = _val_h
        _val_caption = reader.tgread_object()
        _args['caption'] = _val_caption
        return cls(**_args)


class PageBlockOrderedList(TLObject):
    """TL type: pageBlockOrderedList"""
    CONSTRUCTOR_ID = 0x9a8ae1e1
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, items: List['TypePageListOrderedItem']):
        self.items = items

    def to_dict(self):
        return {
            '_': 'PageBlockOrderedList',
            'items': self.items,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.items)))
        for item in self.items:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_items = reader.read_int()
        _list_items = []
        for _ in range(_count_items):
            _item_items = reader.tgread_object()
            _list_items.append(_item_items)
        _args['items'] = _list_items
        return cls(**_args)


class PageBlockParagraph(TLObject):
    """TL type: pageBlockParagraph"""
    CONSTRUCTOR_ID = 0x467a0766
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'PageBlockParagraph',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class PageBlockPhoto(TLObject):
    """TL type: pageBlockPhoto"""
    CONSTRUCTOR_ID = 0x1759c560
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, photo_id: int, caption: 'TypePageCaption', url: Optional[str] = None, webpage_id: Optional[int] = None):
        self.photo_id = photo_id
        self.caption = caption
        self.url = url
        self.webpage_id = webpage_id

    def to_dict(self):
        return {
            '_': 'PageBlockPhoto',
            'photo_id': self.photo_id,
            'caption': self.caption,
            'url': self.url,
            'webpage_id': self.webpage_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.webpage_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.photo_id))
        buf.write(bytes(self.caption))
        if self.url is not None:
            buf.write(TLObject.serialize_bytes(self.url))
        if self.webpage_id is not None:
            buf.write(struct.pack('<q', self.webpage_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_photo_id = reader.read_long()
        _args['photo_id'] = _val_photo_id
        _val_caption = reader.tgread_object()
        _args['caption'] = _val_caption
        if flags & (1 << 0):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        if flags & (1 << 0):
            _val_webpage_id = reader.read_long()
            _args['webpage_id'] = _val_webpage_id
        else:
            _args['webpage_id'] = None
        return cls(**_args)


class PageBlockPreformatted(TLObject):
    """TL type: pageBlockPreformatted"""
    CONSTRUCTOR_ID = 0xc070d93e
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, text: 'TypeRichText', language: str):
        self.text = text
        self.language = language

    def to_dict(self):
        return {
            '_': 'PageBlockPreformatted',
            'text': self.text,
            'language': self.language,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.language))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        _val_language = reader.tgread_string()
        _args['language'] = _val_language
        return cls(**_args)


class PageBlockPullquote(TLObject):
    """TL type: pageBlockPullquote"""
    CONSTRUCTOR_ID = 0x4f4456d3
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, text: 'TypeRichText', caption: 'TypeRichText'):
        self.text = text
        self.caption = caption

    def to_dict(self):
        return {
            '_': 'PageBlockPullquote',
            'text': self.text,
            'caption': self.caption,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        buf.write(bytes(self.caption))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        _val_caption = reader.tgread_object()
        _args['caption'] = _val_caption
        return cls(**_args)


class PageBlockRelatedArticles(TLObject):
    """TL type: pageBlockRelatedArticles"""
    CONSTRUCTOR_ID = 0x16115a96
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, title: 'TypeRichText', articles: List['TypePageRelatedArticle']):
        self.title = title
        self.articles = articles

    def to_dict(self):
        return {
            '_': 'PageBlockRelatedArticles',
            'title': self.title,
            'articles': self.articles,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.title))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.articles)))
        for item in self.articles:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_object()
        _args['title'] = _val_title
        reader.read_int(signed=False)  # skip vector id
        _count_articles = reader.read_int()
        _list_articles = []
        for _ in range(_count_articles):
            _item_articles = reader.tgread_object()
            _list_articles.append(_item_articles)
        _args['articles'] = _list_articles
        return cls(**_args)


class PageBlockSlideshow(TLObject):
    """TL type: pageBlockSlideshow"""
    CONSTRUCTOR_ID = 0x031f9590
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, items: List['TypePageBlock'], caption: 'TypePageCaption'):
        self.items = items
        self.caption = caption

    def to_dict(self):
        return {
            '_': 'PageBlockSlideshow',
            'items': self.items,
            'caption': self.caption,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.items)))
        for item in self.items:
            buf.write(bytes(self.item))
        buf.write(bytes(self.caption))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_items = reader.read_int()
        _list_items = []
        for _ in range(_count_items):
            _item_items = reader.tgread_object()
            _list_items.append(_item_items)
        _args['items'] = _list_items
        _val_caption = reader.tgread_object()
        _args['caption'] = _val_caption
        return cls(**_args)


class PageBlockSubheader(TLObject):
    """TL type: pageBlockSubheader"""
    CONSTRUCTOR_ID = 0xf12bb6e1
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'PageBlockSubheader',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class PageBlockSubtitle(TLObject):
    """TL type: pageBlockSubtitle"""
    CONSTRUCTOR_ID = 0x8ffa9a1f
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'PageBlockSubtitle',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class PageBlockTable(TLObject):
    """TL type: pageBlockTable"""
    CONSTRUCTOR_ID = 0xbf4dea82
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, title: 'TypeRichText', rows: List['TypePageTableRow'], bordered: Optional[bool] = None, striped: Optional[bool] = None):
        self.title = title
        self.rows = rows
        self.bordered = bordered
        self.striped = striped

    def to_dict(self):
        return {
            '_': 'PageBlockTable',
            'title': self.title,
            'rows': self.rows,
            'bordered': self.bordered,
            'striped': self.striped,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.bordered:
            flags |= (1 << 0)
        if self.striped:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.title))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.rows)))
        for item in self.rows:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['bordered'] = bool(flags & (1 << 0))
        _args['striped'] = bool(flags & (1 << 1))
        _val_title = reader.tgread_object()
        _args['title'] = _val_title
        reader.read_int(signed=False)  # skip vector id
        _count_rows = reader.read_int()
        _list_rows = []
        for _ in range(_count_rows):
            _item_rows = reader.tgread_object()
            _list_rows.append(_item_rows)
        _args['rows'] = _list_rows
        return cls(**_args)


class PageBlockTitle(TLObject):
    """TL type: pageBlockTitle"""
    CONSTRUCTOR_ID = 0x70abc3fd
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'PageBlockTitle',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class PageBlockUnsupported(TLObject):
    """TL type: pageBlockUnsupported"""
    CONSTRUCTOR_ID = 0x13567e8a
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PageBlockUnsupported',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PageBlockVideo(TLObject):
    """TL type: pageBlockVideo"""
    CONSTRUCTOR_ID = 0x7c8fe7b6
    SUBCLASS_OF_ID = 0x1aca5644

    def __init__(self, video_id: int, caption: 'TypePageCaption', autoplay: Optional[bool] = None, loop: Optional[bool] = None):
        self.video_id = video_id
        self.caption = caption
        self.autoplay = autoplay
        self.loop = loop

    def to_dict(self):
        return {
            '_': 'PageBlockVideo',
            'video_id': self.video_id,
            'caption': self.caption,
            'autoplay': self.autoplay,
            'loop': self.loop,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.autoplay:
            flags |= (1 << 0)
        if self.loop:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.video_id))
        buf.write(bytes(self.caption))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['autoplay'] = bool(flags & (1 << 0))
        _args['loop'] = bool(flags & (1 << 1))
        _val_video_id = reader.read_long()
        _args['video_id'] = _val_video_id
        _val_caption = reader.tgread_object()
        _args['caption'] = _val_caption
        return cls(**_args)


class PageCaption(TLObject):
    """TL type: pageCaption"""
    CONSTRUCTOR_ID = 0x6f747657
    SUBCLASS_OF_ID = 0x29b8eeb3

    def __init__(self, text: 'TypeRichText', credit: 'TypeRichText'):
        self.text = text
        self.credit = credit

    def to_dict(self):
        return {
            '_': 'PageCaption',
            'text': self.text,
            'credit': self.credit,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        buf.write(bytes(self.credit))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        _val_credit = reader.tgread_object()
        _args['credit'] = _val_credit
        return cls(**_args)


class PageListItemBlocks(TLObject):
    """TL type: pageListItemBlocks"""
    CONSTRUCTOR_ID = 0x25e073fc
    SUBCLASS_OF_ID = 0x8caebcb1

    def __init__(self, blocks: List['TypePageBlock']):
        self.blocks = blocks

    def to_dict(self):
        return {
            '_': 'PageListItemBlocks',
            'blocks': self.blocks,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.blocks)))
        for item in self.blocks:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_blocks = reader.read_int()
        _list_blocks = []
        for _ in range(_count_blocks):
            _item_blocks = reader.tgread_object()
            _list_blocks.append(_item_blocks)
        _args['blocks'] = _list_blocks
        return cls(**_args)


class PageListItemText(TLObject):
    """TL type: pageListItemText"""
    CONSTRUCTOR_ID = 0xb92fb6cd
    SUBCLASS_OF_ID = 0x8caebcb1

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'PageListItemText',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class PageListOrderedItemBlocks(TLObject):
    """TL type: pageListOrderedItemBlocks"""
    CONSTRUCTOR_ID = 0x98dd8936
    SUBCLASS_OF_ID = 0xeeda0eb8

    def __init__(self, num: str, blocks: List['TypePageBlock']):
        self.num = num
        self.blocks = blocks

    def to_dict(self):
        return {
            '_': 'PageListOrderedItemBlocks',
            'num': self.num,
            'blocks': self.blocks,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.num))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.blocks)))
        for item in self.blocks:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_num = reader.tgread_string()
        _args['num'] = _val_num
        reader.read_int(signed=False)  # skip vector id
        _count_blocks = reader.read_int()
        _list_blocks = []
        for _ in range(_count_blocks):
            _item_blocks = reader.tgread_object()
            _list_blocks.append(_item_blocks)
        _args['blocks'] = _list_blocks
        return cls(**_args)


class PageListOrderedItemText(TLObject):
    """TL type: pageListOrderedItemText"""
    CONSTRUCTOR_ID = 0x5e068047
    SUBCLASS_OF_ID = 0xeeda0eb8

    def __init__(self, num: str, text: 'TypeRichText'):
        self.num = num
        self.text = text

    def to_dict(self):
        return {
            '_': 'PageListOrderedItemText',
            'num': self.num,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.num))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_num = reader.tgread_string()
        _args['num'] = _val_num
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class PageRelatedArticle(TLObject):
    """TL type: pageRelatedArticle"""
    CONSTRUCTOR_ID = 0xb390dc08
    SUBCLASS_OF_ID = 0x36d05822

    def __init__(self, url: str, webpage_id: int, title: Optional[str] = None, description: Optional[str] = None, photo_id: Optional[int] = None, author: Optional[str] = None, published_date: Optional[datetime] = None):
        self.url = url
        self.webpage_id = webpage_id
        self.title = title
        self.description = description
        self.photo_id = photo_id
        self.author = author
        self.published_date = published_date

    def to_dict(self):
        return {
            '_': 'PageRelatedArticle',
            'url': self.url,
            'webpage_id': self.webpage_id,
            'title': self.title,
            'description': self.description,
            'photo_id': self.photo_id,
            'author': self.author,
            'published_date': self.published_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.title is not None:
            flags |= (1 << 0)
        if self.description is not None:
            flags |= (1 << 1)
        if self.photo_id is not None:
            flags |= (1 << 2)
        if self.author is not None:
            flags |= (1 << 3)
        if self.published_date is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<q', self.webpage_id))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.description is not None:
            buf.write(TLObject.serialize_bytes(self.description))
        if self.photo_id is not None:
            buf.write(struct.pack('<q', self.photo_id))
        if self.author is not None:
            buf.write(TLObject.serialize_bytes(self.author))
        if self.published_date is not None:
            buf.write(struct.pack('<i', self.published_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_webpage_id = reader.read_long()
        _args['webpage_id'] = _val_webpage_id
        if flags & (1 << 0):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 1):
            _val_description = reader.tgread_string()
            _args['description'] = _val_description
        else:
            _args['description'] = None
        if flags & (1 << 2):
            _val_photo_id = reader.read_long()
            _args['photo_id'] = _val_photo_id
        else:
            _args['photo_id'] = None
        if flags & (1 << 3):
            _val_author = reader.tgread_string()
            _args['author'] = _val_author
        else:
            _args['author'] = None
        if flags & (1 << 4):
            _val_published_date = reader.read_int()
            _args['published_date'] = _val_published_date
        else:
            _args['published_date'] = None
        return cls(**_args)


class PageTableCell(TLObject):
    """TL type: pageTableCell"""
    CONSTRUCTOR_ID = 0x34566b6a
    SUBCLASS_OF_ID = 0xb0eb3054

    def __init__(self, header: Optional[bool] = None, align_center: Optional[bool] = None, align_right: Optional[bool] = None, valign_middle: Optional[bool] = None, valign_bottom: Optional[bool] = None, text: Optional['TypeRichText'] = None, colspan: Optional[int] = None, rowspan: Optional[int] = None):
        self.header = header
        self.align_center = align_center
        self.align_right = align_right
        self.valign_middle = valign_middle
        self.valign_bottom = valign_bottom
        self.text = text
        self.colspan = colspan
        self.rowspan = rowspan

    def to_dict(self):
        return {
            '_': 'PageTableCell',
            'header': self.header,
            'align_center': self.align_center,
            'align_right': self.align_right,
            'valign_middle': self.valign_middle,
            'valign_bottom': self.valign_bottom,
            'text': self.text,
            'colspan': self.colspan,
            'rowspan': self.rowspan,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.header:
            flags |= (1 << 0)
        if self.align_center:
            flags |= (1 << 3)
        if self.align_right:
            flags |= (1 << 4)
        if self.valign_middle:
            flags |= (1 << 5)
        if self.valign_bottom:
            flags |= (1 << 6)
        if self.text is not None:
            flags |= (1 << 7)
        if self.colspan is not None:
            flags |= (1 << 1)
        if self.rowspan is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.text is not None:
            buf.write(bytes(self.text))
        if self.colspan is not None:
            buf.write(struct.pack('<i', self.colspan))
        if self.rowspan is not None:
            buf.write(struct.pack('<i', self.rowspan))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['header'] = bool(flags & (1 << 0))
        _args['align_center'] = bool(flags & (1 << 3))
        _args['align_right'] = bool(flags & (1 << 4))
        _args['valign_middle'] = bool(flags & (1 << 5))
        _args['valign_bottom'] = bool(flags & (1 << 6))
        if flags & (1 << 7):
            _val_text = reader.tgread_object()
            _args['text'] = _val_text
        else:
            _args['text'] = None
        if flags & (1 << 1):
            _val_colspan = reader.read_int()
            _args['colspan'] = _val_colspan
        else:
            _args['colspan'] = None
        if flags & (1 << 2):
            _val_rowspan = reader.read_int()
            _args['rowspan'] = _val_rowspan
        else:
            _args['rowspan'] = None
        return cls(**_args)


class PageTableRow(TLObject):
    """TL type: pageTableRow"""
    CONSTRUCTOR_ID = 0xe0c0c5e5
    SUBCLASS_OF_ID = 0x59acee11

    def __init__(self, cells: List['TypePageTableCell']):
        self.cells = cells

    def to_dict(self):
        return {
            '_': 'PageTableRow',
            'cells': self.cells,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.cells)))
        for item in self.cells:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_cells = reader.read_int()
        _list_cells = []
        for _ in range(_count_cells):
            _item_cells = reader.tgread_object()
            _list_cells.append(_item_cells)
        _args['cells'] = _list_cells
        return cls(**_args)


class PaidReactionPrivacyAnonymous(TLObject):
    """TL type: paidReactionPrivacyAnonymous"""
    CONSTRUCTOR_ID = 0x1f0c1ad9
    SUBCLASS_OF_ID = 0x65d77636

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PaidReactionPrivacyAnonymous',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PaidReactionPrivacyDefault(TLObject):
    """TL type: paidReactionPrivacyDefault"""
    CONSTRUCTOR_ID = 0x206ad49e
    SUBCLASS_OF_ID = 0x65d77636

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PaidReactionPrivacyDefault',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PaidReactionPrivacyPeer(TLObject):
    """TL type: paidReactionPrivacyPeer"""
    CONSTRUCTOR_ID = 0xdc6cfcf0
    SUBCLASS_OF_ID = 0x65d77636

    def __init__(self, peer: 'TypeInputPeer'):
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'PaidReactionPrivacyPeer',
            'peer': self.peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class Passkey(TLObject):
    """TL type: passkey"""
    CONSTRUCTOR_ID = 0x98613ebf
    SUBCLASS_OF_ID = 0xcf380de0

    def __init__(self, id: str, name: str, date: Optional[datetime], software_emoji_id: Optional[int] = None, last_usage_date: Optional[datetime] = None):
        self.id = id
        self.name = name
        self.date = date
        self.software_emoji_id = software_emoji_id
        self.last_usage_date = last_usage_date

    def to_dict(self):
        return {
            '_': 'Passkey',
            'id': self.id,
            'name': self.name,
            'date': self.date,
            'software_emoji_id': self.software_emoji_id,
            'last_usage_date': self.last_usage_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.software_emoji_id is not None:
            flags |= (1 << 0)
        if self.last_usage_date is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.name))
        buf.write(struct.pack('<i', self.date))
        if self.software_emoji_id is not None:
            buf.write(struct.pack('<q', self.software_emoji_id))
        if self.last_usage_date is not None:
            buf.write(struct.pack('<i', self.last_usage_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 0):
            _val_software_emoji_id = reader.read_long()
            _args['software_emoji_id'] = _val_software_emoji_id
        else:
            _args['software_emoji_id'] = None
        if flags & (1 << 1):
            _val_last_usage_date = reader.read_int()
            _args['last_usage_date'] = _val_last_usage_date
        else:
            _args['last_usage_date'] = None
        return cls(**_args)


class PasswordKdfAlgoSha256sha256pbkdf2hmacsha512iter100000sha256modPow(TLObject):
    """TL type: passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow"""
    CONSTRUCTOR_ID = 0x3a912d4a
    SUBCLASS_OF_ID = 0x37bcf5cc

    def __init__(self, salt1: bytes, salt2: bytes, g: int, p: bytes):
        self.salt1 = salt1
        self.salt2 = salt2
        self.g = g
        self.p = p

    def to_dict(self):
        return {
            '_': 'PasswordKdfAlgoSha256sha256pbkdf2hmacsha512iter100000sha256modPow',
            'salt1': self.salt1,
            'salt2': self.salt2,
            'g': self.g,
            'p': self.p,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.salt1))
        buf.write(TLObject.serialize_bytes(self.salt2))
        buf.write(struct.pack('<i', self.g))
        buf.write(TLObject.serialize_bytes(self.p))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_salt1 = reader.tgread_bytes()
        _args['salt1'] = _val_salt1
        _val_salt2 = reader.tgread_bytes()
        _args['salt2'] = _val_salt2
        _val_g = reader.read_int()
        _args['g'] = _val_g
        _val_p = reader.tgread_bytes()
        _args['p'] = _val_p
        return cls(**_args)


class PasswordKdfAlgoUnknown(TLObject):
    """TL type: passwordKdfAlgoUnknown"""
    CONSTRUCTOR_ID = 0xd45ab096
    SUBCLASS_OF_ID = 0x37bcf5cc

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PasswordKdfAlgoUnknown',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PaymentCharge(TLObject):
    """TL type: paymentCharge"""
    CONSTRUCTOR_ID = 0xea02c27e
    SUBCLASS_OF_ID = 0x3cc830d9

    def __init__(self, id: str, provider_charge_id: str):
        self.id = id
        self.provider_charge_id = provider_charge_id

    def to_dict(self):
        return {
            '_': 'PaymentCharge',
            'id': self.id,
            'provider_charge_id': self.provider_charge_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.provider_charge_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_provider_charge_id = reader.tgread_string()
        _args['provider_charge_id'] = _val_provider_charge_id
        return cls(**_args)


class PaymentFormMethod(TLObject):
    """TL type: paymentFormMethod"""
    CONSTRUCTOR_ID = 0x88f8f21b
    SUBCLASS_OF_ID = 0x3fc1c816

    def __init__(self, url: str, title: str):
        self.url = url
        self.title = title

    def to_dict(self):
        return {
            '_': 'PaymentFormMethod',
            'url': self.url,
            'title': self.title,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(TLObject.serialize_bytes(self.title))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        return cls(**_args)


class PaymentRequestedInfo(TLObject):
    """TL type: paymentRequestedInfo"""
    CONSTRUCTOR_ID = 0x909c3f94
    SUBCLASS_OF_ID = 0x8db03146

    def __init__(self, name: Optional[str] = None, phone: Optional[str] = None, email: Optional[str] = None, shipping_address: Optional['TypePostAddress'] = None):
        self.name = name
        self.phone = phone
        self.email = email
        self.shipping_address = shipping_address

    def to_dict(self):
        return {
            '_': 'PaymentRequestedInfo',
            'name': self.name,
            'phone': self.phone,
            'email': self.email,
            'shipping_address': self.shipping_address,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.name is not None:
            flags |= (1 << 0)
        if self.phone is not None:
            flags |= (1 << 1)
        if self.email is not None:
            flags |= (1 << 2)
        if self.shipping_address is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        if self.name is not None:
            buf.write(TLObject.serialize_bytes(self.name))
        if self.phone is not None:
            buf.write(TLObject.serialize_bytes(self.phone))
        if self.email is not None:
            buf.write(TLObject.serialize_bytes(self.email))
        if self.shipping_address is not None:
            buf.write(bytes(self.shipping_address))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_name = reader.tgread_string()
            _args['name'] = _val_name
        else:
            _args['name'] = None
        if flags & (1 << 1):
            _val_phone = reader.tgread_string()
            _args['phone'] = _val_phone
        else:
            _args['phone'] = None
        if flags & (1 << 2):
            _val_email = reader.tgread_string()
            _args['email'] = _val_email
        else:
            _args['email'] = None
        if flags & (1 << 3):
            _val_shipping_address = reader.tgread_object()
            _args['shipping_address'] = _val_shipping_address
        else:
            _args['shipping_address'] = None
        return cls(**_args)


class PaymentSavedCredentialsCard(TLObject):
    """TL type: paymentSavedCredentialsCard"""
    CONSTRUCTOR_ID = 0xcdc27a1f
    SUBCLASS_OF_ID = 0xb3627ee3

    def __init__(self, id: str, title: str):
        self.id = id
        self.title = title

    def to_dict(self):
        return {
            '_': 'PaymentSavedCredentialsCard',
            'id': self.id,
            'title': self.title,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.title))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        return cls(**_args)


class PeerBlocked(TLObject):
    """TL type: peerBlocked"""
    CONSTRUCTOR_ID = 0xe8fd8014
    SUBCLASS_OF_ID = 0x54f2fc98

    def __init__(self, peer_id: 'TypePeer', date: Optional[datetime]):
        self.peer_id = peer_id
        self.date = date

    def to_dict(self):
        return {
            '_': 'PeerBlocked',
            'peer_id': self.peer_id,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer_id))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer_id = reader.tgread_object()
        _args['peer_id'] = _val_peer_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class PeerChannel(TLObject):
    """TL type: peerChannel"""
    CONSTRUCTOR_ID = 0xa2a5371e
    SUBCLASS_OF_ID = 0x02d45687

    def __init__(self, channel_id: int):
        self.channel_id = channel_id

    def to_dict(self):
        return {
            '_': 'PeerChannel',
            'channel_id': self.channel_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        return cls(**_args)


class PeerChat(TLObject):
    """TL type: peerChat"""
    CONSTRUCTOR_ID = 0x36c6019a
    SUBCLASS_OF_ID = 0x02d45687

    def __init__(self, chat_id: int):
        self.chat_id = chat_id

    def to_dict(self):
        return {
            '_': 'PeerChat',
            'chat_id': self.chat_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.chat_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        return cls(**_args)


class PeerColor(TLObject):
    """TL type: peerColor"""
    CONSTRUCTOR_ID = 0xb54b5acf
    SUBCLASS_OF_ID = 0xf281a47f

    def __init__(self, color: Optional[int] = None, background_emoji_id: Optional[int] = None):
        self.color = color
        self.background_emoji_id = background_emoji_id

    def to_dict(self):
        return {
            '_': 'PeerColor',
            'color': self.color,
            'background_emoji_id': self.background_emoji_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.color is not None:
            flags |= (1 << 0)
        if self.background_emoji_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        if self.color is not None:
            buf.write(struct.pack('<i', self.color))
        if self.background_emoji_id is not None:
            buf.write(struct.pack('<q', self.background_emoji_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_color = reader.read_int()
            _args['color'] = _val_color
        else:
            _args['color'] = None
        if flags & (1 << 1):
            _val_background_emoji_id = reader.read_long()
            _args['background_emoji_id'] = _val_background_emoji_id
        else:
            _args['background_emoji_id'] = None
        return cls(**_args)


class PeerColorCollectible(TLObject):
    """TL type: peerColorCollectible"""
    CONSTRUCTOR_ID = 0xb9c0639a
    SUBCLASS_OF_ID = 0xf281a47f

    def __init__(self, collectible_id: int, gift_emoji_id: int, background_emoji_id: int, accent_color: int, colors: List[int], dark_accent_color: Optional[int] = None, dark_colors: Optional[List[int]] = None):
        self.collectible_id = collectible_id
        self.gift_emoji_id = gift_emoji_id
        self.background_emoji_id = background_emoji_id
        self.accent_color = accent_color
        self.colors = colors
        self.dark_accent_color = dark_accent_color
        self.dark_colors = dark_colors

    def to_dict(self):
        return {
            '_': 'PeerColorCollectible',
            'collectible_id': self.collectible_id,
            'gift_emoji_id': self.gift_emoji_id,
            'background_emoji_id': self.background_emoji_id,
            'accent_color': self.accent_color,
            'colors': self.colors,
            'dark_accent_color': self.dark_accent_color,
            'dark_colors': self.dark_colors,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.dark_accent_color is not None:
            flags |= (1 << 0)
        if self.dark_colors is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.collectible_id))
        buf.write(struct.pack('<q', self.gift_emoji_id))
        buf.write(struct.pack('<q', self.background_emoji_id))
        buf.write(struct.pack('<i', self.accent_color))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.colors)))
        for item in self.colors:
            buf.write(struct.pack('<i', self.item))
        if self.dark_accent_color is not None:
            buf.write(struct.pack('<i', self.dark_accent_color))
        if self.dark_colors is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.dark_colors)))
            for item in self.dark_colors:
                buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_collectible_id = reader.read_long()
        _args['collectible_id'] = _val_collectible_id
        _val_gift_emoji_id = reader.read_long()
        _args['gift_emoji_id'] = _val_gift_emoji_id
        _val_background_emoji_id = reader.read_long()
        _args['background_emoji_id'] = _val_background_emoji_id
        _val_accent_color = reader.read_int()
        _args['accent_color'] = _val_accent_color
        reader.read_int(signed=False)  # skip vector id
        _count_colors = reader.read_int()
        _list_colors = []
        for _ in range(_count_colors):
            _item_colors = reader.read_int()
            _list_colors.append(_item_colors)
        _args['colors'] = _list_colors
        if flags & (1 << 0):
            _val_dark_accent_color = reader.read_int()
            _args['dark_accent_color'] = _val_dark_accent_color
        else:
            _args['dark_accent_color'] = None
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_dark_colors = reader.read_int()
            _list_dark_colors = []
            for _ in range(_count_dark_colors):
                _item_dark_colors = reader.read_int()
                _list_dark_colors.append(_item_dark_colors)
            _args['dark_colors'] = _list_dark_colors
        else:
            _args['dark_colors'] = None
        return cls(**_args)


class PeerLocated(TLObject):
    """TL type: peerLocated"""
    CONSTRUCTOR_ID = 0xca461b5d
    SUBCLASS_OF_ID = 0xfada34ac

    def __init__(self, peer: 'TypePeer', expires: Optional[datetime], distance: int):
        self.peer = peer
        self.expires = expires
        self.distance = distance

    def to_dict(self):
        return {
            '_': 'PeerLocated',
            'peer': self.peer,
            'expires': self.expires,
            'distance': self.distance,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.expires))
        buf.write(struct.pack('<i', self.distance))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_expires = reader.read_int()
        _args['expires'] = _val_expires
        _val_distance = reader.read_int()
        _args['distance'] = _val_distance
        return cls(**_args)


class PeerNotifySettings(TLObject):
    """TL type: peerNotifySettings"""
    CONSTRUCTOR_ID = 0x99622c0c
    SUBCLASS_OF_ID = 0xcf20c074

    def __init__(self, show_previews: Optional[bool] = None, silent: Optional[bool] = None, mute_until: Optional[datetime] = None, ios_sound: Optional['TypeNotificationSound'] = None, android_sound: Optional['TypeNotificationSound'] = None, other_sound: Optional['TypeNotificationSound'] = None, stories_muted: Optional[bool] = None, stories_hide_sender: Optional[bool] = None, stories_ios_sound: Optional['TypeNotificationSound'] = None, stories_android_sound: Optional['TypeNotificationSound'] = None, stories_other_sound: Optional['TypeNotificationSound'] = None):
        self.show_previews = show_previews
        self.silent = silent
        self.mute_until = mute_until
        self.ios_sound = ios_sound
        self.android_sound = android_sound
        self.other_sound = other_sound
        self.stories_muted = stories_muted
        self.stories_hide_sender = stories_hide_sender
        self.stories_ios_sound = stories_ios_sound
        self.stories_android_sound = stories_android_sound
        self.stories_other_sound = stories_other_sound

    def to_dict(self):
        return {
            '_': 'PeerNotifySettings',
            'show_previews': self.show_previews,
            'silent': self.silent,
            'mute_until': self.mute_until,
            'ios_sound': self.ios_sound,
            'android_sound': self.android_sound,
            'other_sound': self.other_sound,
            'stories_muted': self.stories_muted,
            'stories_hide_sender': self.stories_hide_sender,
            'stories_ios_sound': self.stories_ios_sound,
            'stories_android_sound': self.stories_android_sound,
            'stories_other_sound': self.stories_other_sound,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.show_previews is not None:
            flags |= (1 << 0)
        if self.silent is not None:
            flags |= (1 << 1)
        if self.mute_until is not None:
            flags |= (1 << 2)
        if self.ios_sound is not None:
            flags |= (1 << 3)
        if self.android_sound is not None:
            flags |= (1 << 4)
        if self.other_sound is not None:
            flags |= (1 << 5)
        if self.stories_muted is not None:
            flags |= (1 << 6)
        if self.stories_hide_sender is not None:
            flags |= (1 << 7)
        if self.stories_ios_sound is not None:
            flags |= (1 << 8)
        if self.stories_android_sound is not None:
            flags |= (1 << 9)
        if self.stories_other_sound is not None:
            flags |= (1 << 10)
        buf.write(struct.pack('<I', flags))
        if self.show_previews is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.show_previews else 0xbc799737))
        if self.silent is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.silent else 0xbc799737))
        if self.mute_until is not None:
            buf.write(struct.pack('<i', self.mute_until))
        if self.ios_sound is not None:
            buf.write(bytes(self.ios_sound))
        if self.android_sound is not None:
            buf.write(bytes(self.android_sound))
        if self.other_sound is not None:
            buf.write(bytes(self.other_sound))
        if self.stories_muted is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.stories_muted else 0xbc799737))
        if self.stories_hide_sender is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.stories_hide_sender else 0xbc799737))
        if self.stories_ios_sound is not None:
            buf.write(bytes(self.stories_ios_sound))
        if self.stories_android_sound is not None:
            buf.write(bytes(self.stories_android_sound))
        if self.stories_other_sound is not None:
            buf.write(bytes(self.stories_other_sound))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_show_previews = reader.tgread_bool()
            _args['show_previews'] = _val_show_previews
        else:
            _args['show_previews'] = None
        if flags & (1 << 1):
            _val_silent = reader.tgread_bool()
            _args['silent'] = _val_silent
        else:
            _args['silent'] = None
        if flags & (1 << 2):
            _val_mute_until = reader.read_int()
            _args['mute_until'] = _val_mute_until
        else:
            _args['mute_until'] = None
        if flags & (1 << 3):
            _val_ios_sound = reader.tgread_object()
            _args['ios_sound'] = _val_ios_sound
        else:
            _args['ios_sound'] = None
        if flags & (1 << 4):
            _val_android_sound = reader.tgread_object()
            _args['android_sound'] = _val_android_sound
        else:
            _args['android_sound'] = None
        if flags & (1 << 5):
            _val_other_sound = reader.tgread_object()
            _args['other_sound'] = _val_other_sound
        else:
            _args['other_sound'] = None
        if flags & (1 << 6):
            _val_stories_muted = reader.tgread_bool()
            _args['stories_muted'] = _val_stories_muted
        else:
            _args['stories_muted'] = None
        if flags & (1 << 7):
            _val_stories_hide_sender = reader.tgread_bool()
            _args['stories_hide_sender'] = _val_stories_hide_sender
        else:
            _args['stories_hide_sender'] = None
        if flags & (1 << 8):
            _val_stories_ios_sound = reader.tgread_object()
            _args['stories_ios_sound'] = _val_stories_ios_sound
        else:
            _args['stories_ios_sound'] = None
        if flags & (1 << 9):
            _val_stories_android_sound = reader.tgread_object()
            _args['stories_android_sound'] = _val_stories_android_sound
        else:
            _args['stories_android_sound'] = None
        if flags & (1 << 10):
            _val_stories_other_sound = reader.tgread_object()
            _args['stories_other_sound'] = _val_stories_other_sound
        else:
            _args['stories_other_sound'] = None
        return cls(**_args)


class PeerSelfLocated(TLObject):
    """TL type: peerSelfLocated"""
    CONSTRUCTOR_ID = 0xf8ec284b
    SUBCLASS_OF_ID = 0xfada34ac

    def __init__(self, expires: Optional[datetime]):
        self.expires = expires

    def to_dict(self):
        return {
            '_': 'PeerSelfLocated',
            'expires': self.expires,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.expires))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_expires = reader.read_int()
        _args['expires'] = _val_expires
        return cls(**_args)


class PeerSettings(TLObject):
    """TL type: peerSettings"""
    CONSTRUCTOR_ID = 0xf47741f7
    SUBCLASS_OF_ID = 0xf6a79f84

    def __init__(self, report_spam: Optional[bool] = None, add_contact: Optional[bool] = None, block_contact: Optional[bool] = None, share_contact: Optional[bool] = None, need_contacts_exception: Optional[bool] = None, report_geo: Optional[bool] = None, autoarchived: Optional[bool] = None, invite_members: Optional[bool] = None, request_chat_broadcast: Optional[bool] = None, business_bot_paused: Optional[bool] = None, business_bot_can_reply: Optional[bool] = None, geo_distance: Optional[int] = None, request_chat_title: Optional[str] = None, request_chat_date: Optional[datetime] = None, business_bot_id: Optional[int] = None, business_bot_manage_url: Optional[str] = None, charge_paid_message_stars: Optional[int] = None, registration_month: Optional[str] = None, phone_country: Optional[str] = None, name_change_date: Optional[datetime] = None, photo_change_date: Optional[datetime] = None):
        self.report_spam = report_spam
        self.add_contact = add_contact
        self.block_contact = block_contact
        self.share_contact = share_contact
        self.need_contacts_exception = need_contacts_exception
        self.report_geo = report_geo
        self.autoarchived = autoarchived
        self.invite_members = invite_members
        self.request_chat_broadcast = request_chat_broadcast
        self.business_bot_paused = business_bot_paused
        self.business_bot_can_reply = business_bot_can_reply
        self.geo_distance = geo_distance
        self.request_chat_title = request_chat_title
        self.request_chat_date = request_chat_date
        self.business_bot_id = business_bot_id
        self.business_bot_manage_url = business_bot_manage_url
        self.charge_paid_message_stars = charge_paid_message_stars
        self.registration_month = registration_month
        self.phone_country = phone_country
        self.name_change_date = name_change_date
        self.photo_change_date = photo_change_date

    def to_dict(self):
        return {
            '_': 'PeerSettings',
            'report_spam': self.report_spam,
            'add_contact': self.add_contact,
            'block_contact': self.block_contact,
            'share_contact': self.share_contact,
            'need_contacts_exception': self.need_contacts_exception,
            'report_geo': self.report_geo,
            'autoarchived': self.autoarchived,
            'invite_members': self.invite_members,
            'request_chat_broadcast': self.request_chat_broadcast,
            'business_bot_paused': self.business_bot_paused,
            'business_bot_can_reply': self.business_bot_can_reply,
            'geo_distance': self.geo_distance,
            'request_chat_title': self.request_chat_title,
            'request_chat_date': self.request_chat_date,
            'business_bot_id': self.business_bot_id,
            'business_bot_manage_url': self.business_bot_manage_url,
            'charge_paid_message_stars': self.charge_paid_message_stars,
            'registration_month': self.registration_month,
            'phone_country': self.phone_country,
            'name_change_date': self.name_change_date,
            'photo_change_date': self.photo_change_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.report_spam:
            flags |= (1 << 0)
        if self.add_contact:
            flags |= (1 << 1)
        if self.block_contact:
            flags |= (1 << 2)
        if self.share_contact:
            flags |= (1 << 3)
        if self.need_contacts_exception:
            flags |= (1 << 4)
        if self.report_geo:
            flags |= (1 << 5)
        if self.autoarchived:
            flags |= (1 << 7)
        if self.invite_members:
            flags |= (1 << 8)
        if self.request_chat_broadcast:
            flags |= (1 << 10)
        if self.business_bot_paused:
            flags |= (1 << 11)
        if self.business_bot_can_reply:
            flags |= (1 << 12)
        if self.geo_distance is not None:
            flags |= (1 << 6)
        if self.request_chat_date is not None:
            flags |= (1 << 9)
        if self.business_bot_manage_url is not None:
            flags |= (1 << 13)
        if self.charge_paid_message_stars is not None:
            flags |= (1 << 14)
        if self.registration_month is not None:
            flags |= (1 << 15)
        if self.phone_country is not None:
            flags |= (1 << 16)
        if self.name_change_date is not None:
            flags |= (1 << 17)
        if self.photo_change_date is not None:
            flags |= (1 << 18)
        buf.write(struct.pack('<I', flags))
        if self.geo_distance is not None:
            buf.write(struct.pack('<i', self.geo_distance))
        if self.request_chat_title is not None:
            buf.write(TLObject.serialize_bytes(self.request_chat_title))
        if self.request_chat_date is not None:
            buf.write(struct.pack('<i', self.request_chat_date))
        if self.business_bot_id is not None:
            buf.write(struct.pack('<q', self.business_bot_id))
        if self.business_bot_manage_url is not None:
            buf.write(TLObject.serialize_bytes(self.business_bot_manage_url))
        if self.charge_paid_message_stars is not None:
            buf.write(struct.pack('<q', self.charge_paid_message_stars))
        if self.registration_month is not None:
            buf.write(TLObject.serialize_bytes(self.registration_month))
        if self.phone_country is not None:
            buf.write(TLObject.serialize_bytes(self.phone_country))
        if self.name_change_date is not None:
            buf.write(struct.pack('<i', self.name_change_date))
        if self.photo_change_date is not None:
            buf.write(struct.pack('<i', self.photo_change_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['report_spam'] = bool(flags & (1 << 0))
        _args['add_contact'] = bool(flags & (1 << 1))
        _args['block_contact'] = bool(flags & (1 << 2))
        _args['share_contact'] = bool(flags & (1 << 3))
        _args['need_contacts_exception'] = bool(flags & (1 << 4))
        _args['report_geo'] = bool(flags & (1 << 5))
        _args['autoarchived'] = bool(flags & (1 << 7))
        _args['invite_members'] = bool(flags & (1 << 8))
        _args['request_chat_broadcast'] = bool(flags & (1 << 10))
        _args['business_bot_paused'] = bool(flags & (1 << 11))
        _args['business_bot_can_reply'] = bool(flags & (1 << 12))
        if flags & (1 << 6):
            _val_geo_distance = reader.read_int()
            _args['geo_distance'] = _val_geo_distance
        else:
            _args['geo_distance'] = None
        if flags & (1 << 9):
            _val_request_chat_title = reader.tgread_string()
            _args['request_chat_title'] = _val_request_chat_title
        else:
            _args['request_chat_title'] = None
        if flags & (1 << 9):
            _val_request_chat_date = reader.read_int()
            _args['request_chat_date'] = _val_request_chat_date
        else:
            _args['request_chat_date'] = None
        if flags & (1 << 13):
            _val_business_bot_id = reader.read_long()
            _args['business_bot_id'] = _val_business_bot_id
        else:
            _args['business_bot_id'] = None
        if flags & (1 << 13):
            _val_business_bot_manage_url = reader.tgread_string()
            _args['business_bot_manage_url'] = _val_business_bot_manage_url
        else:
            _args['business_bot_manage_url'] = None
        if flags & (1 << 14):
            _val_charge_paid_message_stars = reader.read_long()
            _args['charge_paid_message_stars'] = _val_charge_paid_message_stars
        else:
            _args['charge_paid_message_stars'] = None
        if flags & (1 << 15):
            _val_registration_month = reader.tgread_string()
            _args['registration_month'] = _val_registration_month
        else:
            _args['registration_month'] = None
        if flags & (1 << 16):
            _val_phone_country = reader.tgread_string()
            _args['phone_country'] = _val_phone_country
        else:
            _args['phone_country'] = None
        if flags & (1 << 17):
            _val_name_change_date = reader.read_int()
            _args['name_change_date'] = _val_name_change_date
        else:
            _args['name_change_date'] = None
        if flags & (1 << 18):
            _val_photo_change_date = reader.read_int()
            _args['photo_change_date'] = _val_photo_change_date
        else:
            _args['photo_change_date'] = None
        return cls(**_args)


class PeerStories(TLObject):
    """TL type: peerStories"""
    CONSTRUCTOR_ID = 0x9a35e999
    SUBCLASS_OF_ID = 0x122c8a47

    def __init__(self, peer: 'TypePeer', stories: List['TypeStoryItem'], max_read_id: Optional[int] = None):
        self.peer = peer
        self.stories = stories
        self.max_read_id = max_read_id

    def to_dict(self):
        return {
            '_': 'PeerStories',
            'peer': self.peer,
            'stories': self.stories,
            'max_read_id': self.max_read_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.max_read_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.stories)))
        for item in self.stories:
            buf.write(bytes(self.item))
        if self.max_read_id is not None:
            buf.write(struct.pack('<i', self.max_read_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _val_max_read_id = reader.read_int()
            _args['max_read_id'] = _val_max_read_id
        else:
            _args['max_read_id'] = None
        reader.read_int(signed=False)  # skip vector id
        _count_stories = reader.read_int()
        _list_stories = []
        for _ in range(_count_stories):
            _item_stories = reader.tgread_object()
            _list_stories.append(_item_stories)
        _args['stories'] = _list_stories
        return cls(**_args)


class PeerUser(TLObject):
    """TL type: peerUser"""
    CONSTRUCTOR_ID = 0x59511722
    SUBCLASS_OF_ID = 0x02d45687

    def __init__(self, user_id: int):
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'PeerUser',
            'user_id': self.user_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class PendingSuggestion(TLObject):
    """TL type: pendingSuggestion"""
    CONSTRUCTOR_ID = 0xe7e82e12
    SUBCLASS_OF_ID = 0xba6174a7

    def __init__(self, suggestion: str, title: 'TypeTextWithEntities', description: 'TypeTextWithEntities', url: str):
        self.suggestion = suggestion
        self.title = title
        self.description = description
        self.url = url

    def to_dict(self):
        return {
            '_': 'PendingSuggestion',
            'suggestion': self.suggestion,
            'title': self.title,
            'description': self.description,
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.suggestion))
        buf.write(bytes(self.title))
        buf.write(bytes(self.description))
        buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_suggestion = reader.tgread_string()
        _args['suggestion'] = _val_suggestion
        _val_title = reader.tgread_object()
        _args['title'] = _val_title
        _val_description = reader.tgread_object()
        _args['description'] = _val_description
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class PhoneCall(TLObject):
    """TL type: phoneCall"""
    CONSTRUCTOR_ID = 0x30535af5
    SUBCLASS_OF_ID = 0xc47f1bd1

    def __init__(self, id: int, access_hash: int, date: Optional[datetime], admin_id: int, participant_id: int, g_a_or_b: bytes, key_fingerprint: int, protocol: 'TypePhoneCallProtocol', connections: List['TypePhoneConnection'], start_date: Optional[datetime], p2p_allowed: Optional[bool] = None, video: Optional[bool] = None, conference_supported: Optional[bool] = None, custom_parameters: Optional['TypeDataJSON'] = None):
        self.id = id
        self.access_hash = access_hash
        self.date = date
        self.admin_id = admin_id
        self.participant_id = participant_id
        self.g_a_or_b = g_a_or_b
        self.key_fingerprint = key_fingerprint
        self.protocol = protocol
        self.connections = connections
        self.start_date = start_date
        self.p2p_allowed = p2p_allowed
        self.video = video
        self.conference_supported = conference_supported
        self.custom_parameters = custom_parameters

    def to_dict(self):
        return {
            '_': 'PhoneCall',
            'id': self.id,
            'access_hash': self.access_hash,
            'date': self.date,
            'admin_id': self.admin_id,
            'participant_id': self.participant_id,
            'g_a_or_b': self.g_a_or_b,
            'key_fingerprint': self.key_fingerprint,
            'protocol': self.protocol,
            'connections': self.connections,
            'start_date': self.start_date,
            'p2p_allowed': self.p2p_allowed,
            'video': self.video,
            'conference_supported': self.conference_supported,
            'custom_parameters': self.custom_parameters,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.p2p_allowed:
            flags |= (1 << 5)
        if self.video:
            flags |= (1 << 6)
        if self.conference_supported:
            flags |= (1 << 8)
        if self.custom_parameters is not None:
            flags |= (1 << 7)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.admin_id))
        buf.write(struct.pack('<q', self.participant_id))
        buf.write(TLObject.serialize_bytes(self.g_a_or_b))
        buf.write(struct.pack('<q', self.key_fingerprint))
        buf.write(bytes(self.protocol))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.connections)))
        for item in self.connections:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', self.start_date))
        if self.custom_parameters is not None:
            buf.write(bytes(self.custom_parameters))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['p2p_allowed'] = bool(flags & (1 << 5))
        _args['video'] = bool(flags & (1 << 6))
        _args['conference_supported'] = bool(flags & (1 << 8))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_admin_id = reader.read_long()
        _args['admin_id'] = _val_admin_id
        _val_participant_id = reader.read_long()
        _args['participant_id'] = _val_participant_id
        _val_g_a_or_b = reader.tgread_bytes()
        _args['g_a_or_b'] = _val_g_a_or_b
        _val_key_fingerprint = reader.read_long()
        _args['key_fingerprint'] = _val_key_fingerprint
        _val_protocol = reader.tgread_object()
        _args['protocol'] = _val_protocol
        reader.read_int(signed=False)  # skip vector id
        _count_connections = reader.read_int()
        _list_connections = []
        for _ in range(_count_connections):
            _item_connections = reader.tgread_object()
            _list_connections.append(_item_connections)
        _args['connections'] = _list_connections
        _val_start_date = reader.read_int()
        _args['start_date'] = _val_start_date
        if flags & (1 << 7):
            _val_custom_parameters = reader.tgread_object()
            _args['custom_parameters'] = _val_custom_parameters
        else:
            _args['custom_parameters'] = None
        return cls(**_args)


class PhoneCallAccepted(TLObject):
    """TL type: phoneCallAccepted"""
    CONSTRUCTOR_ID = 0x3660c311
    SUBCLASS_OF_ID = 0xc47f1bd1

    def __init__(self, id: int, access_hash: int, date: Optional[datetime], admin_id: int, participant_id: int, g_b: bytes, protocol: 'TypePhoneCallProtocol', video: Optional[bool] = None):
        self.id = id
        self.access_hash = access_hash
        self.date = date
        self.admin_id = admin_id
        self.participant_id = participant_id
        self.g_b = g_b
        self.protocol = protocol
        self.video = video

    def to_dict(self):
        return {
            '_': 'PhoneCallAccepted',
            'id': self.id,
            'access_hash': self.access_hash,
            'date': self.date,
            'admin_id': self.admin_id,
            'participant_id': self.participant_id,
            'g_b': self.g_b,
            'protocol': self.protocol,
            'video': self.video,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.video:
            flags |= (1 << 6)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.admin_id))
        buf.write(struct.pack('<q', self.participant_id))
        buf.write(TLObject.serialize_bytes(self.g_b))
        buf.write(bytes(self.protocol))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['video'] = bool(flags & (1 << 6))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_admin_id = reader.read_long()
        _args['admin_id'] = _val_admin_id
        _val_participant_id = reader.read_long()
        _args['participant_id'] = _val_participant_id
        _val_g_b = reader.tgread_bytes()
        _args['g_b'] = _val_g_b
        _val_protocol = reader.tgread_object()
        _args['protocol'] = _val_protocol
        return cls(**_args)


class PhoneCallDiscardReasonBusy(TLObject):
    """TL type: phoneCallDiscardReasonBusy"""
    CONSTRUCTOR_ID = 0xfaf7e8c9
    SUBCLASS_OF_ID = 0xd89bad3d

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PhoneCallDiscardReasonBusy',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PhoneCallDiscardReasonDisconnect(TLObject):
    """TL type: phoneCallDiscardReasonDisconnect"""
    CONSTRUCTOR_ID = 0xe095c1a0
    SUBCLASS_OF_ID = 0xd89bad3d

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PhoneCallDiscardReasonDisconnect',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PhoneCallDiscardReasonHangup(TLObject):
    """TL type: phoneCallDiscardReasonHangup"""
    CONSTRUCTOR_ID = 0x57adc690
    SUBCLASS_OF_ID = 0xd89bad3d

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PhoneCallDiscardReasonHangup',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PhoneCallDiscardReasonMigrateConferenceCall(TLObject):
    """TL type: phoneCallDiscardReasonMigrateConferenceCall"""
    CONSTRUCTOR_ID = 0x9fbbf1f7
    SUBCLASS_OF_ID = 0xd89bad3d

    def __init__(self, slug: str):
        self.slug = slug

    def to_dict(self):
        return {
            '_': 'PhoneCallDiscardReasonMigrateConferenceCall',
            'slug': self.slug,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.slug))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        return cls(**_args)


class PhoneCallDiscardReasonMissed(TLObject):
    """TL type: phoneCallDiscardReasonMissed"""
    CONSTRUCTOR_ID = 0x85e42301
    SUBCLASS_OF_ID = 0xd89bad3d

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PhoneCallDiscardReasonMissed',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PhoneCallDiscarded(TLObject):
    """TL type: phoneCallDiscarded"""
    CONSTRUCTOR_ID = 0x50ca4de1
    SUBCLASS_OF_ID = 0xc47f1bd1

    def __init__(self, id: int, need_rating: Optional[bool] = None, need_debug: Optional[bool] = None, video: Optional[bool] = None, reason: Optional['TypePhoneCallDiscardReason'] = None, duration: Optional[int] = None):
        self.id = id
        self.need_rating = need_rating
        self.need_debug = need_debug
        self.video = video
        self.reason = reason
        self.duration = duration

    def to_dict(self):
        return {
            '_': 'PhoneCallDiscarded',
            'id': self.id,
            'need_rating': self.need_rating,
            'need_debug': self.need_debug,
            'video': self.video,
            'reason': self.reason,
            'duration': self.duration,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.need_rating:
            flags |= (1 << 2)
        if self.need_debug:
            flags |= (1 << 3)
        if self.video:
            flags |= (1 << 6)
        if self.reason is not None:
            flags |= (1 << 0)
        if self.duration is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        if self.reason is not None:
            buf.write(bytes(self.reason))
        if self.duration is not None:
            buf.write(struct.pack('<i', self.duration))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['need_rating'] = bool(flags & (1 << 2))
        _args['need_debug'] = bool(flags & (1 << 3))
        _args['video'] = bool(flags & (1 << 6))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        if flags & (1 << 0):
            _val_reason = reader.tgread_object()
            _args['reason'] = _val_reason
        else:
            _args['reason'] = None
        if flags & (1 << 1):
            _val_duration = reader.read_int()
            _args['duration'] = _val_duration
        else:
            _args['duration'] = None
        return cls(**_args)


class PhoneCallEmpty(TLObject):
    """TL type: phoneCallEmpty"""
    CONSTRUCTOR_ID = 0x5366c915
    SUBCLASS_OF_ID = 0xc47f1bd1

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'PhoneCallEmpty',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        return cls(**_args)


class PhoneCallProtocol(TLObject):
    """TL type: phoneCallProtocol"""
    CONSTRUCTOR_ID = 0xfc878fc8
    SUBCLASS_OF_ID = 0x783991a3

    def __init__(self, min_layer: int, max_layer: int, library_versions: List[str], udp_p2p: Optional[bool] = None, udp_reflector: Optional[bool] = None):
        self.min_layer = min_layer
        self.max_layer = max_layer
        self.library_versions = library_versions
        self.udp_p2p = udp_p2p
        self.udp_reflector = udp_reflector

    def to_dict(self):
        return {
            '_': 'PhoneCallProtocol',
            'min_layer': self.min_layer,
            'max_layer': self.max_layer,
            'library_versions': self.library_versions,
            'udp_p2p': self.udp_p2p,
            'udp_reflector': self.udp_reflector,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.udp_p2p:
            flags |= (1 << 0)
        if self.udp_reflector:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.min_layer))
        buf.write(struct.pack('<i', self.max_layer))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.library_versions)))
        for item in self.library_versions:
            buf.write(TLObject.serialize_bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['udp_p2p'] = bool(flags & (1 << 0))
        _args['udp_reflector'] = bool(flags & (1 << 1))
        _val_min_layer = reader.read_int()
        _args['min_layer'] = _val_min_layer
        _val_max_layer = reader.read_int()
        _args['max_layer'] = _val_max_layer
        reader.read_int(signed=False)  # skip vector id
        _count_library_versions = reader.read_int()
        _list_library_versions = []
        for _ in range(_count_library_versions):
            _item_library_versions = reader.tgread_string()
            _list_library_versions.append(_item_library_versions)
        _args['library_versions'] = _list_library_versions
        return cls(**_args)


class PhoneCallRequested(TLObject):
    """TL type: phoneCallRequested"""
    CONSTRUCTOR_ID = 0x14b0ed0c
    SUBCLASS_OF_ID = 0xc47f1bd1

    def __init__(self, id: int, access_hash: int, date: Optional[datetime], admin_id: int, participant_id: int, g_a_hash: bytes, protocol: 'TypePhoneCallProtocol', video: Optional[bool] = None):
        self.id = id
        self.access_hash = access_hash
        self.date = date
        self.admin_id = admin_id
        self.participant_id = participant_id
        self.g_a_hash = g_a_hash
        self.protocol = protocol
        self.video = video

    def to_dict(self):
        return {
            '_': 'PhoneCallRequested',
            'id': self.id,
            'access_hash': self.access_hash,
            'date': self.date,
            'admin_id': self.admin_id,
            'participant_id': self.participant_id,
            'g_a_hash': self.g_a_hash,
            'protocol': self.protocol,
            'video': self.video,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.video:
            flags |= (1 << 6)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.admin_id))
        buf.write(struct.pack('<q', self.participant_id))
        buf.write(TLObject.serialize_bytes(self.g_a_hash))
        buf.write(bytes(self.protocol))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['video'] = bool(flags & (1 << 6))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_admin_id = reader.read_long()
        _args['admin_id'] = _val_admin_id
        _val_participant_id = reader.read_long()
        _args['participant_id'] = _val_participant_id
        _val_g_a_hash = reader.tgread_bytes()
        _args['g_a_hash'] = _val_g_a_hash
        _val_protocol = reader.tgread_object()
        _args['protocol'] = _val_protocol
        return cls(**_args)


class PhoneCallWaiting(TLObject):
    """TL type: phoneCallWaiting"""
    CONSTRUCTOR_ID = 0xc5226f17
    SUBCLASS_OF_ID = 0xc47f1bd1

    def __init__(self, id: int, access_hash: int, date: Optional[datetime], admin_id: int, participant_id: int, protocol: 'TypePhoneCallProtocol', video: Optional[bool] = None, receive_date: Optional[datetime] = None):
        self.id = id
        self.access_hash = access_hash
        self.date = date
        self.admin_id = admin_id
        self.participant_id = participant_id
        self.protocol = protocol
        self.video = video
        self.receive_date = receive_date

    def to_dict(self):
        return {
            '_': 'PhoneCallWaiting',
            'id': self.id,
            'access_hash': self.access_hash,
            'date': self.date,
            'admin_id': self.admin_id,
            'participant_id': self.participant_id,
            'protocol': self.protocol,
            'video': self.video,
            'receive_date': self.receive_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.video:
            flags |= (1 << 6)
        if self.receive_date is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.admin_id))
        buf.write(struct.pack('<q', self.participant_id))
        buf.write(bytes(self.protocol))
        if self.receive_date is not None:
            buf.write(struct.pack('<i', self.receive_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['video'] = bool(flags & (1 << 6))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_admin_id = reader.read_long()
        _args['admin_id'] = _val_admin_id
        _val_participant_id = reader.read_long()
        _args['participant_id'] = _val_participant_id
        _val_protocol = reader.tgread_object()
        _args['protocol'] = _val_protocol
        if flags & (1 << 0):
            _val_receive_date = reader.read_int()
            _args['receive_date'] = _val_receive_date
        else:
            _args['receive_date'] = None
        return cls(**_args)


class PhoneConnection(TLObject):
    """TL type: phoneConnection"""
    CONSTRUCTOR_ID = 0x9cc123c7
    SUBCLASS_OF_ID = 0xaa8de40d

    def __init__(self, id: int, ip: str, ipv6: str, port: int, peer_tag: bytes, tcp: Optional[bool] = None):
        self.id = id
        self.ip = ip
        self.ipv6 = ipv6
        self.port = port
        self.peer_tag = peer_tag
        self.tcp = tcp

    def to_dict(self):
        return {
            '_': 'PhoneConnection',
            'id': self.id,
            'ip': self.ip,
            'ipv6': self.ipv6,
            'port': self.port,
            'peer_tag': self.peer_tag,
            'tcp': self.tcp,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.tcp:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(TLObject.serialize_bytes(self.ip))
        buf.write(TLObject.serialize_bytes(self.ipv6))
        buf.write(struct.pack('<i', self.port))
        buf.write(TLObject.serialize_bytes(self.peer_tag))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['tcp'] = bool(flags & (1 << 0))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_ip = reader.tgread_string()
        _args['ip'] = _val_ip
        _val_ipv6 = reader.tgread_string()
        _args['ipv6'] = _val_ipv6
        _val_port = reader.read_int()
        _args['port'] = _val_port
        _val_peer_tag = reader.tgread_bytes()
        _args['peer_tag'] = _val_peer_tag
        return cls(**_args)


class PhoneConnectionWebrtc(TLObject):
    """TL type: phoneConnectionWebrtc"""
    CONSTRUCTOR_ID = 0x635fe375
    SUBCLASS_OF_ID = 0xaa8de40d

    def __init__(self, id: int, ip: str, ipv6: str, port: int, username: str, password: str, turn: Optional[bool] = None, stun: Optional[bool] = None):
        self.id = id
        self.ip = ip
        self.ipv6 = ipv6
        self.port = port
        self.username = username
        self.password = password
        self.turn = turn
        self.stun = stun

    def to_dict(self):
        return {
            '_': 'PhoneConnectionWebrtc',
            'id': self.id,
            'ip': self.ip,
            'ipv6': self.ipv6,
            'port': self.port,
            'username': self.username,
            'password': self.password,
            'turn': self.turn,
            'stun': self.stun,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.turn:
            flags |= (1 << 0)
        if self.stun:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(TLObject.serialize_bytes(self.ip))
        buf.write(TLObject.serialize_bytes(self.ipv6))
        buf.write(struct.pack('<i', self.port))
        buf.write(TLObject.serialize_bytes(self.username))
        buf.write(TLObject.serialize_bytes(self.password))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['turn'] = bool(flags & (1 << 0))
        _args['stun'] = bool(flags & (1 << 1))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_ip = reader.tgread_string()
        _args['ip'] = _val_ip
        _val_ipv6 = reader.tgread_string()
        _args['ipv6'] = _val_ipv6
        _val_port = reader.read_int()
        _args['port'] = _val_port
        _val_username = reader.tgread_string()
        _args['username'] = _val_username
        _val_password = reader.tgread_string()
        _args['password'] = _val_password
        return cls(**_args)


class Photo(TLObject):
    """TL type: photo"""
    CONSTRUCTOR_ID = 0xfb197a65
    SUBCLASS_OF_ID = 0xd576ab1c

    def __init__(self, id: int, access_hash: int, file_reference: bytes, date: Optional[datetime], sizes: List['TypePhotoSize'], dc_id: int, has_stickers: Optional[bool] = None, video_sizes: Optional[List['TypeVideoSize']] = None):
        self.id = id
        self.access_hash = access_hash
        self.file_reference = file_reference
        self.date = date
        self.sizes = sizes
        self.dc_id = dc_id
        self.has_stickers = has_stickers
        self.video_sizes = video_sizes

    def to_dict(self):
        return {
            '_': 'Photo',
            'id': self.id,
            'access_hash': self.access_hash,
            'file_reference': self.file_reference,
            'date': self.date,
            'sizes': self.sizes,
            'dc_id': self.dc_id,
            'has_stickers': self.has_stickers,
            'video_sizes': self.video_sizes,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.has_stickers:
            flags |= (1 << 0)
        if self.video_sizes is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.file_reference))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.sizes)))
        for item in self.sizes:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', self.dc_id))
        if self.video_sizes is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.video_sizes)))
            for item in self.video_sizes:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['has_stickers'] = bool(flags & (1 << 0))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_file_reference = reader.tgread_bytes()
        _args['file_reference'] = _val_file_reference
        _val_date = reader.read_int()
        _args['date'] = _val_date
        reader.read_int(signed=False)  # skip vector id
        _count_sizes = reader.read_int()
        _list_sizes = []
        for _ in range(_count_sizes):
            _item_sizes = reader.tgread_object()
            _list_sizes.append(_item_sizes)
        _args['sizes'] = _list_sizes
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_video_sizes = reader.read_int()
            _list_video_sizes = []
            for _ in range(_count_video_sizes):
                _item_video_sizes = reader.tgread_object()
                _list_video_sizes.append(_item_video_sizes)
            _args['video_sizes'] = _list_video_sizes
        else:
            _args['video_sizes'] = None
        _val_dc_id = reader.read_int()
        _args['dc_id'] = _val_dc_id
        return cls(**_args)


class PhotoCachedSize(TLObject):
    """TL type: photoCachedSize"""
    CONSTRUCTOR_ID = 0x021e1ad6
    SUBCLASS_OF_ID = 0x17cc29d9

    def __init__(self, type: str, w: int, h: int, bytes: bytes):
        self.type = type
        self.w = w
        self.h = h
        self.bytes = bytes

    def to_dict(self):
        return {
            '_': 'PhotoCachedSize',
            'type': self.type,
            'w': self.w,
            'h': self.h,
            'bytes': self.bytes,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(struct.pack('<i', self.w))
        buf.write(struct.pack('<i', self.h))
        buf.write(TLObject.serialize_bytes(self.bytes))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        _val_w = reader.read_int()
        _args['w'] = _val_w
        _val_h = reader.read_int()
        _args['h'] = _val_h
        _val_bytes = reader.tgread_bytes()
        _args['bytes'] = _val_bytes
        return cls(**_args)


class PhotoEmpty(TLObject):
    """TL type: photoEmpty"""
    CONSTRUCTOR_ID = 0x2331b22d
    SUBCLASS_OF_ID = 0xd576ab1c

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'PhotoEmpty',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        return cls(**_args)


class PhotoPathSize(TLObject):
    """TL type: photoPathSize"""
    CONSTRUCTOR_ID = 0xd8214d41
    SUBCLASS_OF_ID = 0x17cc29d9

    def __init__(self, type: str, bytes: bytes):
        self.type = type
        self.bytes = bytes

    def to_dict(self):
        return {
            '_': 'PhotoPathSize',
            'type': self.type,
            'bytes': self.bytes,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.bytes))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        _val_bytes = reader.tgread_bytes()
        _args['bytes'] = _val_bytes
        return cls(**_args)


class PhotoSize(TLObject):
    """TL type: photoSize"""
    CONSTRUCTOR_ID = 0x75c78e60
    SUBCLASS_OF_ID = 0x17cc29d9

    def __init__(self, type: str, w: int, h: int, size: int):
        self.type = type
        self.w = w
        self.h = h
        self.size = size

    def to_dict(self):
        return {
            '_': 'PhotoSize',
            'type': self.type,
            'w': self.w,
            'h': self.h,
            'size': self.size,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(struct.pack('<i', self.w))
        buf.write(struct.pack('<i', self.h))
        buf.write(struct.pack('<i', self.size))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        _val_w = reader.read_int()
        _args['w'] = _val_w
        _val_h = reader.read_int()
        _args['h'] = _val_h
        _val_size = reader.read_int()
        _args['size'] = _val_size
        return cls(**_args)


class PhotoSizeEmpty(TLObject):
    """TL type: photoSizeEmpty"""
    CONSTRUCTOR_ID = 0x0e17e23c
    SUBCLASS_OF_ID = 0x17cc29d9

    def __init__(self, type: str):
        self.type = type

    def to_dict(self):
        return {
            '_': 'PhotoSizeEmpty',
            'type': self.type,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.type))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        return cls(**_args)


class PhotoSizeProgressive(TLObject):
    """TL type: photoSizeProgressive"""
    CONSTRUCTOR_ID = 0xfa3efb95
    SUBCLASS_OF_ID = 0x17cc29d9

    def __init__(self, type: str, w: int, h: int, sizes: List[int]):
        self.type = type
        self.w = w
        self.h = h
        self.sizes = sizes

    def to_dict(self):
        return {
            '_': 'PhotoSizeProgressive',
            'type': self.type,
            'w': self.w,
            'h': self.h,
            'sizes': self.sizes,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(struct.pack('<i', self.w))
        buf.write(struct.pack('<i', self.h))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.sizes)))
        for item in self.sizes:
            buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        _val_w = reader.read_int()
        _args['w'] = _val_w
        _val_h = reader.read_int()
        _args['h'] = _val_h
        reader.read_int(signed=False)  # skip vector id
        _count_sizes = reader.read_int()
        _list_sizes = []
        for _ in range(_count_sizes):
            _item_sizes = reader.read_int()
            _list_sizes.append(_item_sizes)
        _args['sizes'] = _list_sizes
        return cls(**_args)


class PhotoStrippedSize(TLObject):
    """TL type: photoStrippedSize"""
    CONSTRUCTOR_ID = 0xe0b0bc2e
    SUBCLASS_OF_ID = 0x17cc29d9

    def __init__(self, type: str, bytes: bytes):
        self.type = type
        self.bytes = bytes

    def to_dict(self):
        return {
            '_': 'PhotoStrippedSize',
            'type': self.type,
            'bytes': self.bytes,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.bytes))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        _val_bytes = reader.tgread_bytes()
        _args['bytes'] = _val_bytes
        return cls(**_args)


class Poll(TLObject):
    """TL type: poll"""
    CONSTRUCTOR_ID = 0x58747131
    SUBCLASS_OF_ID = 0x248e557b

    def __init__(self, id: int, question: 'TypeTextWithEntities', answers: List['TypePollAnswer'], closed: Optional[bool] = None, public_voters: Optional[bool] = None, multiple_choice: Optional[bool] = None, quiz: Optional[bool] = None, close_period: Optional[int] = None, close_date: Optional[datetime] = None):
        self.id = id
        self.question = question
        self.answers = answers
        self.closed = closed
        self.public_voters = public_voters
        self.multiple_choice = multiple_choice
        self.quiz = quiz
        self.close_period = close_period
        self.close_date = close_date

    def to_dict(self):
        return {
            '_': 'Poll',
            'id': self.id,
            'question': self.question,
            'answers': self.answers,
            'closed': self.closed,
            'public_voters': self.public_voters,
            'multiple_choice': self.multiple_choice,
            'quiz': self.quiz,
            'close_period': self.close_period,
            'close_date': self.close_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.closed:
            flags |= (1 << 0)
        if self.public_voters:
            flags |= (1 << 1)
        if self.multiple_choice:
            flags |= (1 << 2)
        if self.quiz:
            flags |= (1 << 3)
        if self.close_period is not None:
            flags |= (1 << 4)
        if self.close_date is not None:
            flags |= (1 << 5)
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.question))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.answers)))
        for item in self.answers:
            buf.write(bytes(self.item))
        if self.close_period is not None:
            buf.write(struct.pack('<i', self.close_period))
        if self.close_date is not None:
            buf.write(struct.pack('<i', self.close_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        flags = reader.read_int(signed=False)
        _args['closed'] = bool(flags & (1 << 0))
        _args['public_voters'] = bool(flags & (1 << 1))
        _args['multiple_choice'] = bool(flags & (1 << 2))
        _args['quiz'] = bool(flags & (1 << 3))
        _val_question = reader.tgread_object()
        _args['question'] = _val_question
        reader.read_int(signed=False)  # skip vector id
        _count_answers = reader.read_int()
        _list_answers = []
        for _ in range(_count_answers):
            _item_answers = reader.tgread_object()
            _list_answers.append(_item_answers)
        _args['answers'] = _list_answers
        if flags & (1 << 4):
            _val_close_period = reader.read_int()
            _args['close_period'] = _val_close_period
        else:
            _args['close_period'] = None
        if flags & (1 << 5):
            _val_close_date = reader.read_int()
            _args['close_date'] = _val_close_date
        else:
            _args['close_date'] = None
        return cls(**_args)


class PollAnswer(TLObject):
    """TL type: pollAnswer"""
    CONSTRUCTOR_ID = 0xff16e2ca
    SUBCLASS_OF_ID = 0x7ea5dd9e

    def __init__(self, text: 'TypeTextWithEntities', option: bytes):
        self.text = text
        self.option = option

    def to_dict(self):
        return {
            '_': 'PollAnswer',
            'text': self.text,
            'option': self.option,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.option))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        _val_option = reader.tgread_bytes()
        _args['option'] = _val_option
        return cls(**_args)


class PollAnswerVoters(TLObject):
    """TL type: pollAnswerVoters"""
    CONSTRUCTOR_ID = 0x3b6ddad2
    SUBCLASS_OF_ID = 0x7ce0cf91

    def __init__(self, option: bytes, voters: int, chosen: Optional[bool] = None, correct: Optional[bool] = None):
        self.option = option
        self.voters = voters
        self.chosen = chosen
        self.correct = correct

    def to_dict(self):
        return {
            '_': 'PollAnswerVoters',
            'option': self.option,
            'voters': self.voters,
            'chosen': self.chosen,
            'correct': self.correct,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.chosen:
            flags |= (1 << 0)
        if self.correct:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.option))
        buf.write(struct.pack('<i', self.voters))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['chosen'] = bool(flags & (1 << 0))
        _args['correct'] = bool(flags & (1 << 1))
        _val_option = reader.tgread_bytes()
        _args['option'] = _val_option
        _val_voters = reader.read_int()
        _args['voters'] = _val_voters
        return cls(**_args)


class PollResults(TLObject):
    """TL type: pollResults"""
    CONSTRUCTOR_ID = 0x7adf2420
    SUBCLASS_OF_ID = 0xc3b4f687

    def __init__(self, min: Optional[bool] = None, results: Optional[List['TypePollAnswerVoters']] = None, total_voters: Optional[int] = None, recent_voters: Optional[List['TypePeer']] = None, solution: Optional[str] = None, solution_entities: Optional[List['TypeMessageEntity']] = None):
        self.min = min
        self.results = results
        self.total_voters = total_voters
        self.recent_voters = recent_voters
        self.solution = solution
        self.solution_entities = solution_entities

    def to_dict(self):
        return {
            '_': 'PollResults',
            'min': self.min,
            'results': self.results,
            'total_voters': self.total_voters,
            'recent_voters': self.recent_voters,
            'solution': self.solution,
            'solution_entities': self.solution_entities,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.min:
            flags |= (1 << 0)
        if self.results is not None:
            flags |= (1 << 1)
        if self.total_voters is not None:
            flags |= (1 << 2)
        if self.recent_voters is not None:
            flags |= (1 << 3)
        if self.solution_entities is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        if self.results is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.results)))
            for item in self.results:
                buf.write(bytes(self.item))
        if self.total_voters is not None:
            buf.write(struct.pack('<i', self.total_voters))
        if self.recent_voters is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.recent_voters)))
            for item in self.recent_voters:
                buf.write(bytes(self.item))
        if self.solution is not None:
            buf.write(TLObject.serialize_bytes(self.solution))
        if self.solution_entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.solution_entities)))
            for item in self.solution_entities:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['min'] = bool(flags & (1 << 0))
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_results = reader.read_int()
            _list_results = []
            for _ in range(_count_results):
                _item_results = reader.tgread_object()
                _list_results.append(_item_results)
            _args['results'] = _list_results
        else:
            _args['results'] = None
        if flags & (1 << 2):
            _val_total_voters = reader.read_int()
            _args['total_voters'] = _val_total_voters
        else:
            _args['total_voters'] = None
        if flags & (1 << 3):
            reader.read_int(signed=False)  # skip vector id
            _count_recent_voters = reader.read_int()
            _list_recent_voters = []
            for _ in range(_count_recent_voters):
                _item_recent_voters = reader.tgread_object()
                _list_recent_voters.append(_item_recent_voters)
            _args['recent_voters'] = _list_recent_voters
        else:
            _args['recent_voters'] = None
        if flags & (1 << 4):
            _val_solution = reader.tgread_string()
            _args['solution'] = _val_solution
        else:
            _args['solution'] = None
        if flags & (1 << 4):
            reader.read_int(signed=False)  # skip vector id
            _count_solution_entities = reader.read_int()
            _list_solution_entities = []
            for _ in range(_count_solution_entities):
                _item_solution_entities = reader.tgread_object()
                _list_solution_entities.append(_item_solution_entities)
            _args['solution_entities'] = _list_solution_entities
        else:
            _args['solution_entities'] = None
        return cls(**_args)


class PopularContact(TLObject):
    """TL type: popularContact"""
    CONSTRUCTOR_ID = 0x5ce14175
    SUBCLASS_OF_ID = 0x0409255a

    def __init__(self, client_id: int, importers: int):
        self.client_id = client_id
        self.importers = importers

    def to_dict(self):
        return {
            '_': 'PopularContact',
            'client_id': self.client_id,
            'importers': self.importers,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.client_id))
        buf.write(struct.pack('<i', self.importers))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_client_id = reader.read_long()
        _args['client_id'] = _val_client_id
        _val_importers = reader.read_int()
        _args['importers'] = _val_importers
        return cls(**_args)


class PostAddress(TLObject):
    """TL type: postAddress"""
    CONSTRUCTOR_ID = 0x1e8caaeb
    SUBCLASS_OF_ID = 0x8d7eda2c

    def __init__(self, street_line1: str, street_line2: str, city: str, state: str, country_iso2: str, post_code: str):
        self.street_line1 = street_line1
        self.street_line2 = street_line2
        self.city = city
        self.state = state
        self.country_iso2 = country_iso2
        self.post_code = post_code

    def to_dict(self):
        return {
            '_': 'PostAddress',
            'street_line1': self.street_line1,
            'street_line2': self.street_line2,
            'city': self.city,
            'state': self.state,
            'country_iso2': self.country_iso2,
            'post_code': self.post_code,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.street_line1))
        buf.write(TLObject.serialize_bytes(self.street_line2))
        buf.write(TLObject.serialize_bytes(self.city))
        buf.write(TLObject.serialize_bytes(self.state))
        buf.write(TLObject.serialize_bytes(self.country_iso2))
        buf.write(TLObject.serialize_bytes(self.post_code))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_street_line1 = reader.tgread_string()
        _args['street_line1'] = _val_street_line1
        _val_street_line2 = reader.tgread_string()
        _args['street_line2'] = _val_street_line2
        _val_city = reader.tgread_string()
        _args['city'] = _val_city
        _val_state = reader.tgread_string()
        _args['state'] = _val_state
        _val_country_iso2 = reader.tgread_string()
        _args['country_iso2'] = _val_country_iso2
        _val_post_code = reader.tgread_string()
        _args['post_code'] = _val_post_code
        return cls(**_args)


class PostInteractionCountersMessage(TLObject):
    """TL type: postInteractionCountersMessage"""
    CONSTRUCTOR_ID = 0xe7058e7f
    SUBCLASS_OF_ID = 0x6e4a459b

    def __init__(self, msg_id: int, views: int, forwards: int, reactions: int):
        self.msg_id = msg_id
        self.views = views
        self.forwards = forwards
        self.reactions = reactions

    def to_dict(self):
        return {
            '_': 'PostInteractionCountersMessage',
            'msg_id': self.msg_id,
            'views': self.views,
            'forwards': self.forwards,
            'reactions': self.reactions,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<i', self.views))
        buf.write(struct.pack('<i', self.forwards))
        buf.write(struct.pack('<i', self.reactions))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        _val_views = reader.read_int()
        _args['views'] = _val_views
        _val_forwards = reader.read_int()
        _args['forwards'] = _val_forwards
        _val_reactions = reader.read_int()
        _args['reactions'] = _val_reactions
        return cls(**_args)


class PostInteractionCountersStory(TLObject):
    """TL type: postInteractionCountersStory"""
    CONSTRUCTOR_ID = 0x8a480e27
    SUBCLASS_OF_ID = 0x6e4a459b

    def __init__(self, story_id: int, views: int, forwards: int, reactions: int):
        self.story_id = story_id
        self.views = views
        self.forwards = forwards
        self.reactions = reactions

    def to_dict(self):
        return {
            '_': 'PostInteractionCountersStory',
            'story_id': self.story_id,
            'views': self.views,
            'forwards': self.forwards,
            'reactions': self.reactions,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.story_id))
        buf.write(struct.pack('<i', self.views))
        buf.write(struct.pack('<i', self.forwards))
        buf.write(struct.pack('<i', self.reactions))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_story_id = reader.read_int()
        _args['story_id'] = _val_story_id
        _val_views = reader.read_int()
        _args['views'] = _val_views
        _val_forwards = reader.read_int()
        _args['forwards'] = _val_forwards
        _val_reactions = reader.read_int()
        _args['reactions'] = _val_reactions
        return cls(**_args)


class PremiumGiftCodeOption(TLObject):
    """TL type: premiumGiftCodeOption"""
    CONSTRUCTOR_ID = 0x257e962b
    SUBCLASS_OF_ID = 0x0021d3c2

    def __init__(self, users: int, months: int, currency: str, amount: int, store_product: Optional[str] = None, store_quantity: Optional[int] = None):
        self.users = users
        self.months = months
        self.currency = currency
        self.amount = amount
        self.store_product = store_product
        self.store_quantity = store_quantity

    def to_dict(self):
        return {
            '_': 'PremiumGiftCodeOption',
            'users': self.users,
            'months': self.months,
            'currency': self.currency,
            'amount': self.amount,
            'store_product': self.store_product,
            'store_quantity': self.store_quantity,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.store_product is not None:
            flags |= (1 << 0)
        if self.store_quantity is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.users))
        buf.write(struct.pack('<i', self.months))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        if self.store_product is not None:
            buf.write(TLObject.serialize_bytes(self.store_product))
        if self.store_quantity is not None:
            buf.write(struct.pack('<i', self.store_quantity))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_users = reader.read_int()
        _args['users'] = _val_users
        _val_months = reader.read_int()
        _args['months'] = _val_months
        if flags & (1 << 0):
            _val_store_product = reader.tgread_string()
            _args['store_product'] = _val_store_product
        else:
            _args['store_product'] = None
        if flags & (1 << 1):
            _val_store_quantity = reader.read_int()
            _args['store_quantity'] = _val_store_quantity
        else:
            _args['store_quantity'] = None
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        return cls(**_args)


class PremiumGiftOption(TLObject):
    """TL type: premiumGiftOption"""
    CONSTRUCTOR_ID = 0x79c059f7
    SUBCLASS_OF_ID = 0x5182b03e

    def __init__(self, months: int, currency: str, amount: int, bot_url: Optional[str] = None, store_product: Optional[str] = None):
        self.months = months
        self.currency = currency
        self.amount = amount
        self.bot_url = bot_url
        self.store_product = store_product

    def to_dict(self):
        return {
            '_': 'PremiumGiftOption',
            'months': self.months,
            'currency': self.currency,
            'amount': self.amount,
            'bot_url': self.bot_url,
            'store_product': self.store_product,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.bot_url is not None:
            flags |= (1 << 1)
        if self.store_product is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.months))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        if self.bot_url is not None:
            buf.write(TLObject.serialize_bytes(self.bot_url))
        if self.store_product is not None:
            buf.write(TLObject.serialize_bytes(self.store_product))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_months = reader.read_int()
        _args['months'] = _val_months
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        if flags & (1 << 1):
            _val_bot_url = reader.tgread_string()
            _args['bot_url'] = _val_bot_url
        else:
            _args['bot_url'] = None
        if flags & (1 << 0):
            _val_store_product = reader.tgread_string()
            _args['store_product'] = _val_store_product
        else:
            _args['store_product'] = None
        return cls(**_args)


class PremiumSubscriptionOption(TLObject):
    """TL type: premiumSubscriptionOption"""
    CONSTRUCTOR_ID = 0x5f2d1df2
    SUBCLASS_OF_ID = 0x2e2dc73f

    def __init__(self, months: int, currency: str, amount: int, bot_url: str, current: Optional[bool] = None, can_purchase_upgrade: Optional[bool] = None, transaction: Optional[str] = None, store_product: Optional[str] = None):
        self.months = months
        self.currency = currency
        self.amount = amount
        self.bot_url = bot_url
        self.current = current
        self.can_purchase_upgrade = can_purchase_upgrade
        self.transaction = transaction
        self.store_product = store_product

    def to_dict(self):
        return {
            '_': 'PremiumSubscriptionOption',
            'months': self.months,
            'currency': self.currency,
            'amount': self.amount,
            'bot_url': self.bot_url,
            'current': self.current,
            'can_purchase_upgrade': self.can_purchase_upgrade,
            'transaction': self.transaction,
            'store_product': self.store_product,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.current:
            flags |= (1 << 1)
        if self.can_purchase_upgrade:
            flags |= (1 << 2)
        if self.transaction is not None:
            flags |= (1 << 3)
        if self.store_product is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.months))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        buf.write(TLObject.serialize_bytes(self.bot_url))
        if self.transaction is not None:
            buf.write(TLObject.serialize_bytes(self.transaction))
        if self.store_product is not None:
            buf.write(TLObject.serialize_bytes(self.store_product))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['current'] = bool(flags & (1 << 1))
        _args['can_purchase_upgrade'] = bool(flags & (1 << 2))
        if flags & (1 << 3):
            _val_transaction = reader.tgread_string()
            _args['transaction'] = _val_transaction
        else:
            _args['transaction'] = None
        _val_months = reader.read_int()
        _args['months'] = _val_months
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        _val_bot_url = reader.tgread_string()
        _args['bot_url'] = _val_bot_url
        if flags & (1 << 0):
            _val_store_product = reader.tgread_string()
            _args['store_product'] = _val_store_product
        else:
            _args['store_product'] = None
        return cls(**_args)


class PrepaidGiveaway(TLObject):
    """TL type: prepaidGiveaway"""
    CONSTRUCTOR_ID = 0xb2539d54
    SUBCLASS_OF_ID = 0xee3e6780

    def __init__(self, id: int, months: int, quantity: int, date: Optional[datetime]):
        self.id = id
        self.months = months
        self.quantity = quantity
        self.date = date

    def to_dict(self):
        return {
            '_': 'PrepaidGiveaway',
            'id': self.id,
            'months': self.months,
            'quantity': self.quantity,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<i', self.months))
        buf.write(struct.pack('<i', self.quantity))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_months = reader.read_int()
        _args['months'] = _val_months
        _val_quantity = reader.read_int()
        _args['quantity'] = _val_quantity
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class PrepaidStarsGiveaway(TLObject):
    """TL type: prepaidStarsGiveaway"""
    CONSTRUCTOR_ID = 0x9a9d77e0
    SUBCLASS_OF_ID = 0xee3e6780

    def __init__(self, id: int, stars: int, quantity: int, boosts: int, date: Optional[datetime]):
        self.id = id
        self.stars = stars
        self.quantity = quantity
        self.boosts = boosts
        self.date = date

    def to_dict(self):
        return {
            '_': 'PrepaidStarsGiveaway',
            'id': self.id,
            'stars': self.stars,
            'quantity': self.quantity,
            'boosts': self.boosts,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.stars))
        buf.write(struct.pack('<i', self.quantity))
        buf.write(struct.pack('<i', self.boosts))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        _val_quantity = reader.read_int()
        _args['quantity'] = _val_quantity
        _val_boosts = reader.read_int()
        _args['boosts'] = _val_boosts
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class PrivacyKeyAbout(TLObject):
    """TL type: privacyKeyAbout"""
    CONSTRUCTOR_ID = 0xa486b761
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyAbout',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyAddedByPhone(TLObject):
    """TL type: privacyKeyAddedByPhone"""
    CONSTRUCTOR_ID = 0x42ffd42b
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyAddedByPhone',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyBirthday(TLObject):
    """TL type: privacyKeyBirthday"""
    CONSTRUCTOR_ID = 0x2000a518
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyBirthday',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyChatInvite(TLObject):
    """TL type: privacyKeyChatInvite"""
    CONSTRUCTOR_ID = 0x500e6dfa
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyChatInvite',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyForwards(TLObject):
    """TL type: privacyKeyForwards"""
    CONSTRUCTOR_ID = 0x69ec56a3
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyForwards',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyNoPaidMessages(TLObject):
    """TL type: privacyKeyNoPaidMessages"""
    CONSTRUCTOR_ID = 0x17d348d2
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyNoPaidMessages',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyPhoneCall(TLObject):
    """TL type: privacyKeyPhoneCall"""
    CONSTRUCTOR_ID = 0x3d662b7b
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyPhoneCall',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyPhoneNumber(TLObject):
    """TL type: privacyKeyPhoneNumber"""
    CONSTRUCTOR_ID = 0xd19ae46d
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyPhoneNumber',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyPhoneP2p(TLObject):
    """TL type: privacyKeyPhoneP2P"""
    CONSTRUCTOR_ID = 0x39491cc8
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyPhoneP2p',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyProfilePhoto(TLObject):
    """TL type: privacyKeyProfilePhoto"""
    CONSTRUCTOR_ID = 0x96151fed
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyProfilePhoto',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeySavedMusic(TLObject):
    """TL type: privacyKeySavedMusic"""
    CONSTRUCTOR_ID = 0xff7a571b
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeySavedMusic',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyStarGiftsAutoSave(TLObject):
    """TL type: privacyKeyStarGiftsAutoSave"""
    CONSTRUCTOR_ID = 0x2ca4fdf8
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyStarGiftsAutoSave',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyStatusTimestamp(TLObject):
    """TL type: privacyKeyStatusTimestamp"""
    CONSTRUCTOR_ID = 0xbc2eab30
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyStatusTimestamp',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyKeyVoiceMessages(TLObject):
    """TL type: privacyKeyVoiceMessages"""
    CONSTRUCTOR_ID = 0x0697f414
    SUBCLASS_OF_ID = 0x824651c3

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyKeyVoiceMessages',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyValueAllowAll(TLObject):
    """TL type: privacyValueAllowAll"""
    CONSTRUCTOR_ID = 0x65427b82
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyValueAllowAll',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyValueAllowBots(TLObject):
    """TL type: privacyValueAllowBots"""
    CONSTRUCTOR_ID = 0x21461b5d
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyValueAllowBots',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyValueAllowChatParticipants(TLObject):
    """TL type: privacyValueAllowChatParticipants"""
    CONSTRUCTOR_ID = 0x6b134e8e
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self, chats: List[int]):
        self.chats = chats

    def to_dict(self):
        return {
            '_': 'PrivacyValueAllowChatParticipants',
            'chats': self.chats,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.read_long()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        return cls(**_args)


class PrivacyValueAllowCloseFriends(TLObject):
    """TL type: privacyValueAllowCloseFriends"""
    CONSTRUCTOR_ID = 0xf7e8d89b
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyValueAllowCloseFriends',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyValueAllowContacts(TLObject):
    """TL type: privacyValueAllowContacts"""
    CONSTRUCTOR_ID = 0xfffe1bac
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyValueAllowContacts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyValueAllowPremium(TLObject):
    """TL type: privacyValueAllowPremium"""
    CONSTRUCTOR_ID = 0xece9814b
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyValueAllowPremium',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyValueAllowUsers(TLObject):
    """TL type: privacyValueAllowUsers"""
    CONSTRUCTOR_ID = 0xb8905fb2
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self, users: List[int]):
        self.users = users

    def to_dict(self):
        return {
            '_': 'PrivacyValueAllowUsers',
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.read_long()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class PrivacyValueDisallowAll(TLObject):
    """TL type: privacyValueDisallowAll"""
    CONSTRUCTOR_ID = 0x8b73e763
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyValueDisallowAll',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyValueDisallowBots(TLObject):
    """TL type: privacyValueDisallowBots"""
    CONSTRUCTOR_ID = 0xf6a5f82f
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyValueDisallowBots',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyValueDisallowChatParticipants(TLObject):
    """TL type: privacyValueDisallowChatParticipants"""
    CONSTRUCTOR_ID = 0x41c87565
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self, chats: List[int]):
        self.chats = chats

    def to_dict(self):
        return {
            '_': 'PrivacyValueDisallowChatParticipants',
            'chats': self.chats,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.read_long()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        return cls(**_args)


class PrivacyValueDisallowContacts(TLObject):
    """TL type: privacyValueDisallowContacts"""
    CONSTRUCTOR_ID = 0xf888fa1a
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'PrivacyValueDisallowContacts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PrivacyValueDisallowUsers(TLObject):
    """TL type: privacyValueDisallowUsers"""
    CONSTRUCTOR_ID = 0xe4621141
    SUBCLASS_OF_ID = 0xebb7f270

    def __init__(self, users: List[int]):
        self.users = users

    def to_dict(self):
        return {
            '_': 'PrivacyValueDisallowUsers',
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.read_long()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        return cls(**_args)


class ProfileTabFiles(TLObject):
    """TL type: profileTabFiles"""
    CONSTRUCTOR_ID = 0xab339c00
    SUBCLASS_OF_ID = 0xae48d1b4

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ProfileTabFiles',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ProfileTabGifs(TLObject):
    """TL type: profileTabGifs"""
    CONSTRUCTOR_ID = 0xa2c0f695
    SUBCLASS_OF_ID = 0xae48d1b4

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ProfileTabGifs',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ProfileTabGifts(TLObject):
    """TL type: profileTabGifts"""
    CONSTRUCTOR_ID = 0x4d4bd46a
    SUBCLASS_OF_ID = 0xae48d1b4

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ProfileTabGifts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ProfileTabLinks(TLObject):
    """TL type: profileTabLinks"""
    CONSTRUCTOR_ID = 0xd3656499
    SUBCLASS_OF_ID = 0xae48d1b4

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ProfileTabLinks',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ProfileTabMedia(TLObject):
    """TL type: profileTabMedia"""
    CONSTRUCTOR_ID = 0x72c64955
    SUBCLASS_OF_ID = 0xae48d1b4

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ProfileTabMedia',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ProfileTabMusic(TLObject):
    """TL type: profileTabMusic"""
    CONSTRUCTOR_ID = 0x9f27d26e
    SUBCLASS_OF_ID = 0xae48d1b4

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ProfileTabMusic',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ProfileTabPosts(TLObject):
    """TL type: profileTabPosts"""
    CONSTRUCTOR_ID = 0xb98cd696
    SUBCLASS_OF_ID = 0xae48d1b4

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ProfileTabPosts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ProfileTabVoice(TLObject):
    """TL type: profileTabVoice"""
    CONSTRUCTOR_ID = 0xe477092e
    SUBCLASS_OF_ID = 0xae48d1b4

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ProfileTabVoice',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class PublicForwardMessage(TLObject):
    """TL type: publicForwardMessage"""
    CONSTRUCTOR_ID = 0x01f2bf4a
    SUBCLASS_OF_ID = 0x629015d3

    def __init__(self, message: 'TypeMessage'):
        self.message = message

    def to_dict(self):
        return {
            '_': 'PublicForwardMessage',
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        return cls(**_args)


class PublicForwardStory(TLObject):
    """TL type: publicForwardStory"""
    CONSTRUCTOR_ID = 0xedf3add0
    SUBCLASS_OF_ID = 0x629015d3

    def __init__(self, peer: 'TypePeer', story: 'TypeStoryItem'):
        self.peer = peer
        self.story = story

    def to_dict(self):
        return {
            '_': 'PublicForwardStory',
            'peer': self.peer,
            'story': self.story,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.story))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_story = reader.tgread_object()
        _args['story'] = _val_story
        return cls(**_args)


class QuickReply(TLObject):
    """TL type: quickReply"""
    CONSTRUCTOR_ID = 0x0697102b
    SUBCLASS_OF_ID = 0xe2ea0f12

    def __init__(self, shortcut_id: int, shortcut: str, top_message: int, count: int):
        self.shortcut_id = shortcut_id
        self.shortcut = shortcut
        self.top_message = top_message
        self.count = count

    def to_dict(self):
        return {
            '_': 'QuickReply',
            'shortcut_id': self.shortcut_id,
            'shortcut': self.shortcut,
            'top_message': self.top_message,
            'count': self.count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.shortcut_id))
        buf.write(TLObject.serialize_bytes(self.shortcut))
        buf.write(struct.pack('<i', self.top_message))
        buf.write(struct.pack('<i', self.count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_shortcut_id = reader.read_int()
        _args['shortcut_id'] = _val_shortcut_id
        _val_shortcut = reader.tgread_string()
        _args['shortcut'] = _val_shortcut
        _val_top_message = reader.read_int()
        _args['top_message'] = _val_top_message
        _val_count = reader.read_int()
        _args['count'] = _val_count
        return cls(**_args)


class ReactionCount(TLObject):
    """TL type: reactionCount"""
    CONSTRUCTOR_ID = 0xa3d1cb80
    SUBCLASS_OF_ID = 0xd208ce3f

    def __init__(self, reaction: 'TypeReaction', count: int, chosen_order: Optional[int] = None):
        self.reaction = reaction
        self.count = count
        self.chosen_order = chosen_order

    def to_dict(self):
        return {
            '_': 'ReactionCount',
            'reaction': self.reaction,
            'count': self.count,
            'chosen_order': self.chosen_order,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.chosen_order is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.reaction))
        buf.write(struct.pack('<i', self.count))
        if self.chosen_order is not None:
            buf.write(struct.pack('<i', self.chosen_order))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_chosen_order = reader.read_int()
            _args['chosen_order'] = _val_chosen_order
        else:
            _args['chosen_order'] = None
        _val_reaction = reader.tgread_object()
        _args['reaction'] = _val_reaction
        _val_count = reader.read_int()
        _args['count'] = _val_count
        return cls(**_args)


class ReactionCustomEmoji(TLObject):
    """TL type: reactionCustomEmoji"""
    CONSTRUCTOR_ID = 0x8935fc73
    SUBCLASS_OF_ID = 0x5da165a1

    def __init__(self, document_id: int):
        self.document_id = document_id

    def to_dict(self):
        return {
            '_': 'ReactionCustomEmoji',
            'document_id': self.document_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.document_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_document_id = reader.read_long()
        _args['document_id'] = _val_document_id
        return cls(**_args)


class ReactionEmoji(TLObject):
    """TL type: reactionEmoji"""
    CONSTRUCTOR_ID = 0x1b2286b8
    SUBCLASS_OF_ID = 0x5da165a1

    def __init__(self, emoticon: str):
        self.emoticon = emoticon

    def to_dict(self):
        return {
            '_': 'ReactionEmoji',
            'emoticon': self.emoticon,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.emoticon))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        return cls(**_args)


class ReactionEmpty(TLObject):
    """TL type: reactionEmpty"""
    CONSTRUCTOR_ID = 0x79f5d419
    SUBCLASS_OF_ID = 0x5da165a1

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ReactionEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ReactionNotificationsFromAll(TLObject):
    """TL type: reactionNotificationsFromAll"""
    CONSTRUCTOR_ID = 0x4b9e22a0
    SUBCLASS_OF_ID = 0x345f7940

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ReactionNotificationsFromAll',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ReactionNotificationsFromContacts(TLObject):
    """TL type: reactionNotificationsFromContacts"""
    CONSTRUCTOR_ID = 0xbac3a61a
    SUBCLASS_OF_ID = 0x345f7940

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ReactionNotificationsFromContacts',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ReactionPaid(TLObject):
    """TL type: reactionPaid"""
    CONSTRUCTOR_ID = 0x523da4eb
    SUBCLASS_OF_ID = 0x5da165a1

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ReactionPaid',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class ReactionsNotifySettings(TLObject):
    """TL type: reactionsNotifySettings"""
    CONSTRUCTOR_ID = 0x56e34970
    SUBCLASS_OF_ID = 0x8dff0851

    def __init__(self, sound: 'TypeNotificationSound', show_previews: bool, messages_notify_from: Optional['TypeReactionNotificationsFrom'] = None, stories_notify_from: Optional['TypeReactionNotificationsFrom'] = None):
        self.sound = sound
        self.show_previews = show_previews
        self.messages_notify_from = messages_notify_from
        self.stories_notify_from = stories_notify_from

    def to_dict(self):
        return {
            '_': 'ReactionsNotifySettings',
            'sound': self.sound,
            'show_previews': self.show_previews,
            'messages_notify_from': self.messages_notify_from,
            'stories_notify_from': self.stories_notify_from,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.messages_notify_from is not None:
            flags |= (1 << 0)
        if self.stories_notify_from is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.sound))
        buf.write(struct.pack('<I', 0x997275b5 if self.show_previews else 0xbc799737))
        if self.messages_notify_from is not None:
            buf.write(bytes(self.messages_notify_from))
        if self.stories_notify_from is not None:
            buf.write(bytes(self.stories_notify_from))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_messages_notify_from = reader.tgread_object()
            _args['messages_notify_from'] = _val_messages_notify_from
        else:
            _args['messages_notify_from'] = None
        if flags & (1 << 1):
            _val_stories_notify_from = reader.tgread_object()
            _args['stories_notify_from'] = _val_stories_notify_from
        else:
            _args['stories_notify_from'] = None
        _val_sound = reader.tgread_object()
        _args['sound'] = _val_sound
        _val_show_previews = reader.tgread_bool()
        _args['show_previews'] = _val_show_previews
        return cls(**_args)


class ReadParticipantDate(TLObject):
    """TL type: readParticipantDate"""
    CONSTRUCTOR_ID = 0x4a4ff172
    SUBCLASS_OF_ID = 0xfd078ce2

    def __init__(self, user_id: int, date: Optional[datetime]):
        self.user_id = user_id
        self.date = date

    def to_dict(self):
        return {
            '_': 'ReadParticipantDate',
            'user_id': self.user_id,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class ReceivedNotifyMessage(TLObject):
    """TL type: receivedNotifyMessage"""
    CONSTRUCTOR_ID = 0xa384b779
    SUBCLASS_OF_ID = 0xa962381e

    def __init__(self, id: int, flags: int):
        self.id = id
        self.flags = flags

    def to_dict(self):
        return {
            '_': 'ReceivedNotifyMessage',
            'id': self.id,
            'flags': self.flags,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<i', self.flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_flags = reader.read_int()
        _args['flags'] = _val_flags
        return cls(**_args)


class RecentMeUrlChat(TLObject):
    """TL type: recentMeUrlChat"""
    CONSTRUCTOR_ID = 0xb2da71d2
    SUBCLASS_OF_ID = 0x55a53079

    def __init__(self, url: str, chat_id: int):
        self.url = url
        self.chat_id = chat_id

    def to_dict(self):
        return {
            '_': 'RecentMeUrlChat',
            'url': self.url,
            'chat_id': self.chat_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<q', self.chat_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        return cls(**_args)


class RecentMeUrlChatInvite(TLObject):
    """TL type: recentMeUrlChatInvite"""
    CONSTRUCTOR_ID = 0xeb49081d
    SUBCLASS_OF_ID = 0x55a53079

    def __init__(self, url: str, chat_invite: 'TypeChatInvite'):
        self.url = url
        self.chat_invite = chat_invite

    def to_dict(self):
        return {
            '_': 'RecentMeUrlChatInvite',
            'url': self.url,
            'chat_invite': self.chat_invite,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(bytes(self.chat_invite))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_chat_invite = reader.tgread_object()
        _args['chat_invite'] = _val_chat_invite
        return cls(**_args)


class RecentMeUrlStickerSet(TLObject):
    """TL type: recentMeUrlStickerSet"""
    CONSTRUCTOR_ID = 0xbc0a57dc
    SUBCLASS_OF_ID = 0x55a53079

    def __init__(self, url: str, set: 'TypeStickerSetCovered'):
        self.url = url
        self.set = set

    def to_dict(self):
        return {
            '_': 'RecentMeUrlStickerSet',
            'url': self.url,
            'set': self.set,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(bytes(self.set))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_set = reader.tgread_object()
        _args['set'] = _val_set
        return cls(**_args)


class RecentMeUrlUnknown(TLObject):
    """TL type: recentMeUrlUnknown"""
    CONSTRUCTOR_ID = 0x46e1d13d
    SUBCLASS_OF_ID = 0x55a53079

    def __init__(self, url: str):
        self.url = url

    def to_dict(self):
        return {
            '_': 'RecentMeUrlUnknown',
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class RecentMeUrlUser(TLObject):
    """TL type: recentMeUrlUser"""
    CONSTRUCTOR_ID = 0xb92c09e2
    SUBCLASS_OF_ID = 0x55a53079

    def __init__(self, url: str, user_id: int):
        self.url = url
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'RecentMeUrlUser',
            'url': self.url,
            'user_id': self.user_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<q', self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class RecentStory(TLObject):
    """TL type: recentStory"""
    CONSTRUCTOR_ID = 0x711d692d
    SUBCLASS_OF_ID = 0x26f1adcd

    def __init__(self, live: Optional[bool] = None, max_id: Optional[int] = None):
        self.live = live
        self.max_id = max_id

    def to_dict(self):
        return {
            '_': 'RecentStory',
            'live': self.live,
            'max_id': self.max_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.live:
            flags |= (1 << 0)
        if self.max_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        if self.max_id is not None:
            buf.write(struct.pack('<i', self.max_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['live'] = bool(flags & (1 << 0))
        if flags & (1 << 1):
            _val_max_id = reader.read_int()
            _args['max_id'] = _val_max_id
        else:
            _args['max_id'] = None
        return cls(**_args)


class ReplyInlineMarkup(TLObject):
    """TL type: replyInlineMarkup"""
    CONSTRUCTOR_ID = 0x48a30254
    SUBCLASS_OF_ID = 0xe2e10ef2

    def __init__(self, rows: List['TypeKeyboardButtonRow']):
        self.rows = rows

    def to_dict(self):
        return {
            '_': 'ReplyInlineMarkup',
            'rows': self.rows,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.rows)))
        for item in self.rows:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_rows = reader.read_int()
        _list_rows = []
        for _ in range(_count_rows):
            _item_rows = reader.tgread_object()
            _list_rows.append(_item_rows)
        _args['rows'] = _list_rows
        return cls(**_args)


class ReplyKeyboardForceReply(TLObject):
    """TL type: replyKeyboardForceReply"""
    CONSTRUCTOR_ID = 0x86b40b08
    SUBCLASS_OF_ID = 0xe2e10ef2

    def __init__(self, single_use: Optional[bool] = None, selective: Optional[bool] = None, placeholder: Optional[str] = None):
        self.single_use = single_use
        self.selective = selective
        self.placeholder = placeholder

    def to_dict(self):
        return {
            '_': 'ReplyKeyboardForceReply',
            'single_use': self.single_use,
            'selective': self.selective,
            'placeholder': self.placeholder,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.single_use:
            flags |= (1 << 1)
        if self.selective:
            flags |= (1 << 2)
        if self.placeholder is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        if self.placeholder is not None:
            buf.write(TLObject.serialize_bytes(self.placeholder))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['single_use'] = bool(flags & (1 << 1))
        _args['selective'] = bool(flags & (1 << 2))
        if flags & (1 << 3):
            _val_placeholder = reader.tgread_string()
            _args['placeholder'] = _val_placeholder
        else:
            _args['placeholder'] = None
        return cls(**_args)


class ReplyKeyboardHide(TLObject):
    """TL type: replyKeyboardHide"""
    CONSTRUCTOR_ID = 0xa03e5b85
    SUBCLASS_OF_ID = 0xe2e10ef2

    def __init__(self, selective: Optional[bool] = None):
        self.selective = selective

    def to_dict(self):
        return {
            '_': 'ReplyKeyboardHide',
            'selective': self.selective,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.selective:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['selective'] = bool(flags & (1 << 2))
        return cls(**_args)


class ReplyKeyboardMarkup(TLObject):
    """TL type: replyKeyboardMarkup"""
    CONSTRUCTOR_ID = 0x85dd99d1
    SUBCLASS_OF_ID = 0xe2e10ef2

    def __init__(self, rows: List['TypeKeyboardButtonRow'], resize: Optional[bool] = None, single_use: Optional[bool] = None, selective: Optional[bool] = None, persistent: Optional[bool] = None, placeholder: Optional[str] = None):
        self.rows = rows
        self.resize = resize
        self.single_use = single_use
        self.selective = selective
        self.persistent = persistent
        self.placeholder = placeholder

    def to_dict(self):
        return {
            '_': 'ReplyKeyboardMarkup',
            'rows': self.rows,
            'resize': self.resize,
            'single_use': self.single_use,
            'selective': self.selective,
            'persistent': self.persistent,
            'placeholder': self.placeholder,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.resize:
            flags |= (1 << 0)
        if self.single_use:
            flags |= (1 << 1)
        if self.selective:
            flags |= (1 << 2)
        if self.persistent:
            flags |= (1 << 4)
        if self.placeholder is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.rows)))
        for item in self.rows:
            buf.write(bytes(self.item))
        if self.placeholder is not None:
            buf.write(TLObject.serialize_bytes(self.placeholder))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['resize'] = bool(flags & (1 << 0))
        _args['single_use'] = bool(flags & (1 << 1))
        _args['selective'] = bool(flags & (1 << 2))
        _args['persistent'] = bool(flags & (1 << 4))
        reader.read_int(signed=False)  # skip vector id
        _count_rows = reader.read_int()
        _list_rows = []
        for _ in range(_count_rows):
            _item_rows = reader.tgread_object()
            _list_rows.append(_item_rows)
        _args['rows'] = _list_rows
        if flags & (1 << 3):
            _val_placeholder = reader.tgread_string()
            _args['placeholder'] = _val_placeholder
        else:
            _args['placeholder'] = None
        return cls(**_args)


class ReportResultAddComment(TLObject):
    """TL type: reportResultAddComment"""
    CONSTRUCTOR_ID = 0x6f09ac31
    SUBCLASS_OF_ID = 0xacd3f438

    def __init__(self, option: bytes, optional: Optional[bool] = None):
        self.option = option
        self.optional = optional

    def to_dict(self):
        return {
            '_': 'ReportResultAddComment',
            'option': self.option,
            'optional': self.optional,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.optional:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.option))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['optional'] = bool(flags & (1 << 0))
        _val_option = reader.tgread_bytes()
        _args['option'] = _val_option
        return cls(**_args)


class ReportResultChooseOption(TLObject):
    """TL type: reportResultChooseOption"""
    CONSTRUCTOR_ID = 0xf0e4e0b6
    SUBCLASS_OF_ID = 0xacd3f438

    def __init__(self, title: str, options: List['TypeMessageReportOption']):
        self.title = title
        self.options = options

    def to_dict(self):
        return {
            '_': 'ReportResultChooseOption',
            'title': self.title,
            'options': self.options,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.options)))
        for item in self.options:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        reader.read_int(signed=False)  # skip vector id
        _count_options = reader.read_int()
        _list_options = []
        for _ in range(_count_options):
            _item_options = reader.tgread_object()
            _list_options.append(_item_options)
        _args['options'] = _list_options
        return cls(**_args)


class ReportResultReported(TLObject):
    """TL type: reportResultReported"""
    CONSTRUCTOR_ID = 0x8db33c4b
    SUBCLASS_OF_ID = 0xacd3f438

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'ReportResultReported',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class RequestPeerTypeBroadcast(TLObject):
    """TL type: requestPeerTypeBroadcast"""
    CONSTRUCTOR_ID = 0x339bef6c
    SUBCLASS_OF_ID = 0xe9a0e814

    def __init__(self, creator: Optional[bool] = None, has_username: Optional[bool] = None, user_admin_rights: Optional['TypeChatAdminRights'] = None, bot_admin_rights: Optional['TypeChatAdminRights'] = None):
        self.creator = creator
        self.has_username = has_username
        self.user_admin_rights = user_admin_rights
        self.bot_admin_rights = bot_admin_rights

    def to_dict(self):
        return {
            '_': 'RequestPeerTypeBroadcast',
            'creator': self.creator,
            'has_username': self.has_username,
            'user_admin_rights': self.user_admin_rights,
            'bot_admin_rights': self.bot_admin_rights,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.creator:
            flags |= (1 << 0)
        if self.has_username is not None:
            flags |= (1 << 3)
        if self.user_admin_rights is not None:
            flags |= (1 << 1)
        if self.bot_admin_rights is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.has_username is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.has_username else 0xbc799737))
        if self.user_admin_rights is not None:
            buf.write(bytes(self.user_admin_rights))
        if self.bot_admin_rights is not None:
            buf.write(bytes(self.bot_admin_rights))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['creator'] = bool(flags & (1 << 0))
        if flags & (1 << 3):
            _val_has_username = reader.tgread_bool()
            _args['has_username'] = _val_has_username
        else:
            _args['has_username'] = None
        if flags & (1 << 1):
            _val_user_admin_rights = reader.tgread_object()
            _args['user_admin_rights'] = _val_user_admin_rights
        else:
            _args['user_admin_rights'] = None
        if flags & (1 << 2):
            _val_bot_admin_rights = reader.tgread_object()
            _args['bot_admin_rights'] = _val_bot_admin_rights
        else:
            _args['bot_admin_rights'] = None
        return cls(**_args)


class RequestPeerTypeChat(TLObject):
    """TL type: requestPeerTypeChat"""
    CONSTRUCTOR_ID = 0xc9f06e1b
    SUBCLASS_OF_ID = 0xe9a0e814

    def __init__(self, creator: Optional[bool] = None, bot_participant: Optional[bool] = None, has_username: Optional[bool] = None, forum: Optional[bool] = None, user_admin_rights: Optional['TypeChatAdminRights'] = None, bot_admin_rights: Optional['TypeChatAdminRights'] = None):
        self.creator = creator
        self.bot_participant = bot_participant
        self.has_username = has_username
        self.forum = forum
        self.user_admin_rights = user_admin_rights
        self.bot_admin_rights = bot_admin_rights

    def to_dict(self):
        return {
            '_': 'RequestPeerTypeChat',
            'creator': self.creator,
            'bot_participant': self.bot_participant,
            'has_username': self.has_username,
            'forum': self.forum,
            'user_admin_rights': self.user_admin_rights,
            'bot_admin_rights': self.bot_admin_rights,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.creator:
            flags |= (1 << 0)
        if self.bot_participant:
            flags |= (1 << 5)
        if self.has_username is not None:
            flags |= (1 << 3)
        if self.forum is not None:
            flags |= (1 << 4)
        if self.user_admin_rights is not None:
            flags |= (1 << 1)
        if self.bot_admin_rights is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.has_username is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.has_username else 0xbc799737))
        if self.forum is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.forum else 0xbc799737))
        if self.user_admin_rights is not None:
            buf.write(bytes(self.user_admin_rights))
        if self.bot_admin_rights is not None:
            buf.write(bytes(self.bot_admin_rights))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['creator'] = bool(flags & (1 << 0))
        _args['bot_participant'] = bool(flags & (1 << 5))
        if flags & (1 << 3):
            _val_has_username = reader.tgread_bool()
            _args['has_username'] = _val_has_username
        else:
            _args['has_username'] = None
        if flags & (1 << 4):
            _val_forum = reader.tgread_bool()
            _args['forum'] = _val_forum
        else:
            _args['forum'] = None
        if flags & (1 << 1):
            _val_user_admin_rights = reader.tgread_object()
            _args['user_admin_rights'] = _val_user_admin_rights
        else:
            _args['user_admin_rights'] = None
        if flags & (1 << 2):
            _val_bot_admin_rights = reader.tgread_object()
            _args['bot_admin_rights'] = _val_bot_admin_rights
        else:
            _args['bot_admin_rights'] = None
        return cls(**_args)


class RequestPeerTypeUser(TLObject):
    """TL type: requestPeerTypeUser"""
    CONSTRUCTOR_ID = 0x5f3b8a00
    SUBCLASS_OF_ID = 0xe9a0e814

    def __init__(self, bot: Optional[bool] = None, premium: Optional[bool] = None):
        self.bot = bot
        self.premium = premium

    def to_dict(self):
        return {
            '_': 'RequestPeerTypeUser',
            'bot': self.bot,
            'premium': self.premium,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.bot is not None:
            flags |= (1 << 0)
        if self.premium is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        if self.bot is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.bot else 0xbc799737))
        if self.premium is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.premium else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_bot = reader.tgread_bool()
            _args['bot'] = _val_bot
        else:
            _args['bot'] = None
        if flags & (1 << 1):
            _val_premium = reader.tgread_bool()
            _args['premium'] = _val_premium
        else:
            _args['premium'] = None
        return cls(**_args)


class RequestedPeerChannel(TLObject):
    """TL type: requestedPeerChannel"""
    CONSTRUCTOR_ID = 0x8ba403e4
    SUBCLASS_OF_ID = 0xc2887c10

    def __init__(self, channel_id: int, title: Optional[str] = None, username: Optional[str] = None, photo: Optional['TypePhoto'] = None):
        self.channel_id = channel_id
        self.title = title
        self.username = username
        self.photo = photo

    def to_dict(self):
        return {
            '_': 'RequestedPeerChannel',
            'channel_id': self.channel_id,
            'title': self.title,
            'username': self.username,
            'photo': self.photo,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.title is not None:
            flags |= (1 << 0)
        if self.username is not None:
            flags |= (1 << 1)
        if self.photo is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.channel_id))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.username is not None:
            buf.write(TLObject.serialize_bytes(self.username))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        if flags & (1 << 0):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 1):
            _val_username = reader.tgread_string()
            _args['username'] = _val_username
        else:
            _args['username'] = None
        if flags & (1 << 2):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        return cls(**_args)


class RequestedPeerChat(TLObject):
    """TL type: requestedPeerChat"""
    CONSTRUCTOR_ID = 0x7307544f
    SUBCLASS_OF_ID = 0xc2887c10

    def __init__(self, chat_id: int, title: Optional[str] = None, photo: Optional['TypePhoto'] = None):
        self.chat_id = chat_id
        self.title = title
        self.photo = photo

    def to_dict(self):
        return {
            '_': 'RequestedPeerChat',
            'chat_id': self.chat_id,
            'title': self.title,
            'photo': self.photo,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.title is not None:
            flags |= (1 << 0)
        if self.photo is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.chat_id))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        if flags & (1 << 0):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 2):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        return cls(**_args)


class RequestedPeerUser(TLObject):
    """TL type: requestedPeerUser"""
    CONSTRUCTOR_ID = 0xd62ff46a
    SUBCLASS_OF_ID = 0xc2887c10

    def __init__(self, user_id: int, first_name: Optional[str] = None, last_name: Optional[str] = None, username: Optional[str] = None, photo: Optional['TypePhoto'] = None):
        self.user_id = user_id
        self.first_name = first_name
        self.last_name = last_name
        self.username = username
        self.photo = photo

    def to_dict(self):
        return {
            '_': 'RequestedPeerUser',
            'user_id': self.user_id,
            'first_name': self.first_name,
            'last_name': self.last_name,
            'username': self.username,
            'photo': self.photo,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.last_name is not None:
            flags |= (1 << 0)
        if self.username is not None:
            flags |= (1 << 1)
        if self.photo is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.user_id))
        if self.first_name is not None:
            buf.write(TLObject.serialize_bytes(self.first_name))
        if self.last_name is not None:
            buf.write(TLObject.serialize_bytes(self.last_name))
        if self.username is not None:
            buf.write(TLObject.serialize_bytes(self.username))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        if flags & (1 << 0):
            _val_first_name = reader.tgread_string()
            _args['first_name'] = _val_first_name
        else:
            _args['first_name'] = None
        if flags & (1 << 0):
            _val_last_name = reader.tgread_string()
            _args['last_name'] = _val_last_name
        else:
            _args['last_name'] = None
        if flags & (1 << 1):
            _val_username = reader.tgread_string()
            _args['username'] = _val_username
        else:
            _args['username'] = None
        if flags & (1 << 2):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        return cls(**_args)


class RequirementToContactEmpty(TLObject):
    """TL type: requirementToContactEmpty"""
    CONSTRUCTOR_ID = 0x050a9839
    SUBCLASS_OF_ID = 0x8d756391

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'RequirementToContactEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class RequirementToContactPaidMessages(TLObject):
    """TL type: requirementToContactPaidMessages"""
    CONSTRUCTOR_ID = 0xb4f67e93
    SUBCLASS_OF_ID = 0x8d756391

    def __init__(self, stars_amount: int):
        self.stars_amount = stars_amount

    def to_dict(self):
        return {
            '_': 'RequirementToContactPaidMessages',
            'stars_amount': self.stars_amount,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.stars_amount))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_stars_amount = reader.read_long()
        _args['stars_amount'] = _val_stars_amount
        return cls(**_args)


class RequirementToContactPremium(TLObject):
    """TL type: requirementToContactPremium"""
    CONSTRUCTOR_ID = 0xe581e4e9
    SUBCLASS_OF_ID = 0x8d756391

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'RequirementToContactPremium',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class RestrictionReason(TLObject):
    """TL type: restrictionReason"""
    CONSTRUCTOR_ID = 0xd072acb4
    SUBCLASS_OF_ID = 0x06ad95ad

    def __init__(self, platform: str, reason: str, text: str):
        self.platform = platform
        self.reason = reason
        self.text = text

    def to_dict(self):
        return {
            '_': 'RestrictionReason',
            'platform': self.platform,
            'reason': self.reason,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.platform))
        buf.write(TLObject.serialize_bytes(self.reason))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_platform = reader.tgread_string()
        _args['platform'] = _val_platform
        _val_reason = reader.tgread_string()
        _args['reason'] = _val_reason
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class SavedDialog(TLObject):
    """TL type: savedDialog"""
    CONSTRUCTOR_ID = 0xbd87cb6c
    SUBCLASS_OF_ID = 0x23ba6506

    def __init__(self, peer: 'TypePeer', top_message: int, pinned: Optional[bool] = None):
        self.peer = peer
        self.top_message = top_message
        self.pinned = pinned

    def to_dict(self):
        return {
            '_': 'SavedDialog',
            'peer': self.peer,
            'top_message': self.top_message,
            'pinned': self.pinned,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.pinned:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.top_message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['pinned'] = bool(flags & (1 << 2))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_top_message = reader.read_int()
        _args['top_message'] = _val_top_message
        return cls(**_args)


class SavedPhoneContact(TLObject):
    """TL type: savedPhoneContact"""
    CONSTRUCTOR_ID = 0x1142bd56
    SUBCLASS_OF_ID = 0x06db98c4

    def __init__(self, phone: str, first_name: str, last_name: str, date: Optional[datetime]):
        self.phone = phone
        self.first_name = first_name
        self.last_name = last_name
        self.date = date

    def to_dict(self):
        return {
            '_': 'SavedPhoneContact',
            'phone': self.phone,
            'first_name': self.first_name,
            'last_name': self.last_name,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.phone))
        buf.write(TLObject.serialize_bytes(self.first_name))
        buf.write(TLObject.serialize_bytes(self.last_name))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone = reader.tgread_string()
        _args['phone'] = _val_phone
        _val_first_name = reader.tgread_string()
        _args['first_name'] = _val_first_name
        _val_last_name = reader.tgread_string()
        _args['last_name'] = _val_last_name
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class SavedReactionTag(TLObject):
    """TL type: savedReactionTag"""
    CONSTRUCTOR_ID = 0xcb6ff828
    SUBCLASS_OF_ID = 0xed681418

    def __init__(self, reaction: 'TypeReaction', count: int, title: Optional[str] = None):
        self.reaction = reaction
        self.count = count
        self.title = title

    def to_dict(self):
        return {
            '_': 'SavedReactionTag',
            'reaction': self.reaction,
            'count': self.count,
            'title': self.title,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.title is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.reaction))
        buf.write(struct.pack('<i', self.count))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_reaction = reader.tgread_object()
        _args['reaction'] = _val_reaction
        if flags & (1 << 0):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        _val_count = reader.read_int()
        _args['count'] = _val_count
        return cls(**_args)


class SavedStarGift(TLObject):
    """TL type: savedStarGift"""
    CONSTRUCTOR_ID = 0x41df43fc
    SUBCLASS_OF_ID = 0x8e2b3c14

    def __init__(self, date: Optional[datetime], gift: 'TypeStarGift', name_hidden: Optional[bool] = None, unsaved: Optional[bool] = None, refunded: Optional[bool] = None, can_upgrade: Optional[bool] = None, pinned_to_top: Optional[bool] = None, upgrade_separate: Optional[bool] = None, from_id: Optional['TypePeer'] = None, message: Optional['TypeTextWithEntities'] = None, msg_id: Optional[int] = None, saved_id: Optional[int] = None, convert_stars: Optional[int] = None, upgrade_stars: Optional[int] = None, can_export_at: Optional[int] = None, transfer_stars: Optional[int] = None, can_transfer_at: Optional[int] = None, can_resell_at: Optional[int] = None, collection_id: Optional[List[int]] = None, prepaid_upgrade_hash: Optional[str] = None, drop_original_details_stars: Optional[int] = None, gift_num: Optional[int] = None, can_craft_at: Optional[int] = None):
        self.date = date
        self.gift = gift
        self.name_hidden = name_hidden
        self.unsaved = unsaved
        self.refunded = refunded
        self.can_upgrade = can_upgrade
        self.pinned_to_top = pinned_to_top
        self.upgrade_separate = upgrade_separate
        self.from_id = from_id
        self.message = message
        self.msg_id = msg_id
        self.saved_id = saved_id
        self.convert_stars = convert_stars
        self.upgrade_stars = upgrade_stars
        self.can_export_at = can_export_at
        self.transfer_stars = transfer_stars
        self.can_transfer_at = can_transfer_at
        self.can_resell_at = can_resell_at
        self.collection_id = collection_id
        self.prepaid_upgrade_hash = prepaid_upgrade_hash
        self.drop_original_details_stars = drop_original_details_stars
        self.gift_num = gift_num
        self.can_craft_at = can_craft_at

    def to_dict(self):
        return {
            '_': 'SavedStarGift',
            'date': self.date,
            'gift': self.gift,
            'name_hidden': self.name_hidden,
            'unsaved': self.unsaved,
            'refunded': self.refunded,
            'can_upgrade': self.can_upgrade,
            'pinned_to_top': self.pinned_to_top,
            'upgrade_separate': self.upgrade_separate,
            'from_id': self.from_id,
            'message': self.message,
            'msg_id': self.msg_id,
            'saved_id': self.saved_id,
            'convert_stars': self.convert_stars,
            'upgrade_stars': self.upgrade_stars,
            'can_export_at': self.can_export_at,
            'transfer_stars': self.transfer_stars,
            'can_transfer_at': self.can_transfer_at,
            'can_resell_at': self.can_resell_at,
            'collection_id': self.collection_id,
            'prepaid_upgrade_hash': self.prepaid_upgrade_hash,
            'drop_original_details_stars': self.drop_original_details_stars,
            'gift_num': self.gift_num,
            'can_craft_at': self.can_craft_at,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.name_hidden:
            flags |= (1 << 0)
        if self.unsaved:
            flags |= (1 << 5)
        if self.refunded:
            flags |= (1 << 9)
        if self.can_upgrade:
            flags |= (1 << 10)
        if self.pinned_to_top:
            flags |= (1 << 12)
        if self.upgrade_separate:
            flags |= (1 << 17)
        if self.from_id is not None:
            flags |= (1 << 1)
        if self.message is not None:
            flags |= (1 << 2)
        if self.msg_id is not None:
            flags |= (1 << 3)
        if self.saved_id is not None:
            flags |= (1 << 11)
        if self.convert_stars is not None:
            flags |= (1 << 4)
        if self.upgrade_stars is not None:
            flags |= (1 << 6)
        if self.can_export_at is not None:
            flags |= (1 << 7)
        if self.transfer_stars is not None:
            flags |= (1 << 8)
        if self.can_transfer_at is not None:
            flags |= (1 << 13)
        if self.can_resell_at is not None:
            flags |= (1 << 14)
        if self.collection_id is not None:
            flags |= (1 << 15)
        if self.prepaid_upgrade_hash is not None:
            flags |= (1 << 16)
        if self.drop_original_details_stars is not None:
            flags |= (1 << 18)
        if self.gift_num is not None:
            flags |= (1 << 19)
        if self.can_craft_at is not None:
            flags |= (1 << 20)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.date))
        buf.write(bytes(self.gift))
        if self.from_id is not None:
            buf.write(bytes(self.from_id))
        if self.message is not None:
            buf.write(bytes(self.message))
        if self.msg_id is not None:
            buf.write(struct.pack('<i', self.msg_id))
        if self.saved_id is not None:
            buf.write(struct.pack('<q', self.saved_id))
        if self.convert_stars is not None:
            buf.write(struct.pack('<q', self.convert_stars))
        if self.upgrade_stars is not None:
            buf.write(struct.pack('<q', self.upgrade_stars))
        if self.can_export_at is not None:
            buf.write(struct.pack('<i', self.can_export_at))
        if self.transfer_stars is not None:
            buf.write(struct.pack('<q', self.transfer_stars))
        if self.can_transfer_at is not None:
            buf.write(struct.pack('<i', self.can_transfer_at))
        if self.can_resell_at is not None:
            buf.write(struct.pack('<i', self.can_resell_at))
        if self.collection_id is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.collection_id)))
            for item in self.collection_id:
                buf.write(struct.pack('<i', self.item))
        if self.prepaid_upgrade_hash is not None:
            buf.write(TLObject.serialize_bytes(self.prepaid_upgrade_hash))
        if self.drop_original_details_stars is not None:
            buf.write(struct.pack('<q', self.drop_original_details_stars))
        if self.gift_num is not None:
            buf.write(struct.pack('<i', self.gift_num))
        if self.can_craft_at is not None:
            buf.write(struct.pack('<i', self.can_craft_at))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['name_hidden'] = bool(flags & (1 << 0))
        _args['unsaved'] = bool(flags & (1 << 5))
        _args['refunded'] = bool(flags & (1 << 9))
        _args['can_upgrade'] = bool(flags & (1 << 10))
        _args['pinned_to_top'] = bool(flags & (1 << 12))
        _args['upgrade_separate'] = bool(flags & (1 << 17))
        if flags & (1 << 1):
            _val_from_id = reader.tgread_object()
            _args['from_id'] = _val_from_id
        else:
            _args['from_id'] = None
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_gift = reader.tgread_object()
        _args['gift'] = _val_gift
        if flags & (1 << 2):
            _val_message = reader.tgread_object()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        if flags & (1 << 3):
            _val_msg_id = reader.read_int()
            _args['msg_id'] = _val_msg_id
        else:
            _args['msg_id'] = None
        if flags & (1 << 11):
            _val_saved_id = reader.read_long()
            _args['saved_id'] = _val_saved_id
        else:
            _args['saved_id'] = None
        if flags & (1 << 4):
            _val_convert_stars = reader.read_long()
            _args['convert_stars'] = _val_convert_stars
        else:
            _args['convert_stars'] = None
        if flags & (1 << 6):
            _val_upgrade_stars = reader.read_long()
            _args['upgrade_stars'] = _val_upgrade_stars
        else:
            _args['upgrade_stars'] = None
        if flags & (1 << 7):
            _val_can_export_at = reader.read_int()
            _args['can_export_at'] = _val_can_export_at
        else:
            _args['can_export_at'] = None
        if flags & (1 << 8):
            _val_transfer_stars = reader.read_long()
            _args['transfer_stars'] = _val_transfer_stars
        else:
            _args['transfer_stars'] = None
        if flags & (1 << 13):
            _val_can_transfer_at = reader.read_int()
            _args['can_transfer_at'] = _val_can_transfer_at
        else:
            _args['can_transfer_at'] = None
        if flags & (1 << 14):
            _val_can_resell_at = reader.read_int()
            _args['can_resell_at'] = _val_can_resell_at
        else:
            _args['can_resell_at'] = None
        if flags & (1 << 15):
            reader.read_int(signed=False)  # skip vector id
            _count_collection_id = reader.read_int()
            _list_collection_id = []
            for _ in range(_count_collection_id):
                _item_collection_id = reader.read_int()
                _list_collection_id.append(_item_collection_id)
            _args['collection_id'] = _list_collection_id
        else:
            _args['collection_id'] = None
        if flags & (1 << 16):
            _val_prepaid_upgrade_hash = reader.tgread_string()
            _args['prepaid_upgrade_hash'] = _val_prepaid_upgrade_hash
        else:
            _args['prepaid_upgrade_hash'] = None
        if flags & (1 << 18):
            _val_drop_original_details_stars = reader.read_long()
            _args['drop_original_details_stars'] = _val_drop_original_details_stars
        else:
            _args['drop_original_details_stars'] = None
        if flags & (1 << 19):
            _val_gift_num = reader.read_int()
            _args['gift_num'] = _val_gift_num
        else:
            _args['gift_num'] = None
        if flags & (1 << 20):
            _val_can_craft_at = reader.read_int()
            _args['can_craft_at'] = _val_can_craft_at
        else:
            _args['can_craft_at'] = None
        return cls(**_args)


class SearchPostsFlood(TLObject):
    """TL type: searchPostsFlood"""
    CONSTRUCTOR_ID = 0x3e0b5b6a
    SUBCLASS_OF_ID = 0xc2c0ccc1

    def __init__(self, total_daily: int, remains: int, stars_amount: int, query_is_free: Optional[bool] = None, wait_till: Optional[int] = None):
        self.total_daily = total_daily
        self.remains = remains
        self.stars_amount = stars_amount
        self.query_is_free = query_is_free
        self.wait_till = wait_till

    def to_dict(self):
        return {
            '_': 'SearchPostsFlood',
            'total_daily': self.total_daily,
            'remains': self.remains,
            'stars_amount': self.stars_amount,
            'query_is_free': self.query_is_free,
            'wait_till': self.wait_till,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.query_is_free:
            flags |= (1 << 0)
        if self.wait_till is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.total_daily))
        buf.write(struct.pack('<i', self.remains))
        buf.write(struct.pack('<q', self.stars_amount))
        if self.wait_till is not None:
            buf.write(struct.pack('<i', self.wait_till))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['query_is_free'] = bool(flags & (1 << 0))
        _val_total_daily = reader.read_int()
        _args['total_daily'] = _val_total_daily
        _val_remains = reader.read_int()
        _args['remains'] = _val_remains
        if flags & (1 << 1):
            _val_wait_till = reader.read_int()
            _args['wait_till'] = _val_wait_till
        else:
            _args['wait_till'] = None
        _val_stars_amount = reader.read_long()
        _args['stars_amount'] = _val_stars_amount
        return cls(**_args)


class SearchResultPosition(TLObject):
    """TL type: searchResultPosition"""
    CONSTRUCTOR_ID = 0x7f648b67
    SUBCLASS_OF_ID = 0xb8e21614

    def __init__(self, msg_id: int, date: Optional[datetime], offset: int):
        self.msg_id = msg_id
        self.date = date
        self.offset = offset

    def to_dict(self):
        return {
            '_': 'SearchResultPosition',
            'msg_id': self.msg_id,
            'date': self.date,
            'offset': self.offset,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.offset))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        return cls(**_args)


class SearchResultsCalendarPeriod(TLObject):
    """TL type: searchResultsCalendarPeriod"""
    CONSTRUCTOR_ID = 0xc9b0539f
    SUBCLASS_OF_ID = 0xe25cf8ff

    def __init__(self, date: Optional[datetime], min_msg_id: int, max_msg_id: int, count: int):
        self.date = date
        self.min_msg_id = min_msg_id
        self.max_msg_id = max_msg_id
        self.count = count

    def to_dict(self):
        return {
            '_': 'SearchResultsCalendarPeriod',
            'date': self.date,
            'min_msg_id': self.min_msg_id,
            'max_msg_id': self.max_msg_id,
            'count': self.count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.min_msg_id))
        buf.write(struct.pack('<i', self.max_msg_id))
        buf.write(struct.pack('<i', self.count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_min_msg_id = reader.read_int()
        _args['min_msg_id'] = _val_min_msg_id
        _val_max_msg_id = reader.read_int()
        _args['max_msg_id'] = _val_max_msg_id
        _val_count = reader.read_int()
        _args['count'] = _val_count
        return cls(**_args)


class SecureCredentialsEncrypted(TLObject):
    """TL type: secureCredentialsEncrypted"""
    CONSTRUCTOR_ID = 0x33f0ea47
    SUBCLASS_OF_ID = 0x94dc7633

    def __init__(self, data: bytes, hash: bytes, secret: bytes):
        self.data = data
        self.hash = hash
        self.secret = secret

    def to_dict(self):
        return {
            '_': 'SecureCredentialsEncrypted',
            'data': self.data,
            'hash': self.hash,
            'secret': self.secret,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.data))
        buf.write(TLObject.serialize_bytes(self.hash))
        buf.write(TLObject.serialize_bytes(self.secret))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_data = reader.tgread_bytes()
        _args['data'] = _val_data
        _val_hash = reader.tgread_bytes()
        _args['hash'] = _val_hash
        _val_secret = reader.tgread_bytes()
        _args['secret'] = _val_secret
        return cls(**_args)


class SecureData(TLObject):
    """TL type: secureData"""
    CONSTRUCTOR_ID = 0x8aeabec3
    SUBCLASS_OF_ID = 0x7cd41eb4

    def __init__(self, data: bytes, data_hash: bytes, secret: bytes):
        self.data = data
        self.data_hash = data_hash
        self.secret = secret

    def to_dict(self):
        return {
            '_': 'SecureData',
            'data': self.data,
            'data_hash': self.data_hash,
            'secret': self.secret,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.data))
        buf.write(TLObject.serialize_bytes(self.data_hash))
        buf.write(TLObject.serialize_bytes(self.secret))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_data = reader.tgread_bytes()
        _args['data'] = _val_data
        _val_data_hash = reader.tgread_bytes()
        _args['data_hash'] = _val_data_hash
        _val_secret = reader.tgread_bytes()
        _args['secret'] = _val_secret
        return cls(**_args)


class SecureFile(TLObject):
    """TL type: secureFile"""
    CONSTRUCTOR_ID = 0x7d09c27e
    SUBCLASS_OF_ID = 0x5db8dbc7

    def __init__(self, id: int, access_hash: int, size: int, dc_id: int, date: Optional[datetime], file_hash: bytes, secret: bytes):
        self.id = id
        self.access_hash = access_hash
        self.size = size
        self.dc_id = dc_id
        self.date = date
        self.file_hash = file_hash
        self.secret = secret

    def to_dict(self):
        return {
            '_': 'SecureFile',
            'id': self.id,
            'access_hash': self.access_hash,
            'size': self.size,
            'dc_id': self.dc_id,
            'date': self.date,
            'file_hash': self.file_hash,
            'secret': self.secret,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<q', self.size))
        buf.write(struct.pack('<i', self.dc_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(TLObject.serialize_bytes(self.file_hash))
        buf.write(TLObject.serialize_bytes(self.secret))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_size = reader.read_long()
        _args['size'] = _val_size
        _val_dc_id = reader.read_int()
        _args['dc_id'] = _val_dc_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_file_hash = reader.tgread_bytes()
        _args['file_hash'] = _val_file_hash
        _val_secret = reader.tgread_bytes()
        _args['secret'] = _val_secret
        return cls(**_args)


class SecureFileEmpty(TLObject):
    """TL type: secureFileEmpty"""
    CONSTRUCTOR_ID = 0x64199744
    SUBCLASS_OF_ID = 0x5db8dbc7

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureFileEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecurePasswordKdfAlgoPbkdf2hmacsha512iter100000(TLObject):
    """TL type: securePasswordKdfAlgoPBKDF2HMACSHA512iter100000"""
    CONSTRUCTOR_ID = 0xbbf2dda0
    SUBCLASS_OF_ID = 0x77262943

    def __init__(self, salt: bytes):
        self.salt = salt

    def to_dict(self):
        return {
            '_': 'SecurePasswordKdfAlgoPbkdf2hmacsha512iter100000',
            'salt': self.salt,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.salt))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_salt = reader.tgread_bytes()
        _args['salt'] = _val_salt
        return cls(**_args)


class SecurePasswordKdfAlgoSha512(TLObject):
    """TL type: securePasswordKdfAlgoSHA512"""
    CONSTRUCTOR_ID = 0x86471d92
    SUBCLASS_OF_ID = 0x77262943

    def __init__(self, salt: bytes):
        self.salt = salt

    def to_dict(self):
        return {
            '_': 'SecurePasswordKdfAlgoSha512',
            'salt': self.salt,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.salt))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_salt = reader.tgread_bytes()
        _args['salt'] = _val_salt
        return cls(**_args)


class SecurePasswordKdfAlgoUnknown(TLObject):
    """TL type: securePasswordKdfAlgoUnknown"""
    CONSTRUCTOR_ID = 0x004a8537
    SUBCLASS_OF_ID = 0x77262943

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecurePasswordKdfAlgoUnknown',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecurePlainEmail(TLObject):
    """TL type: securePlainEmail"""
    CONSTRUCTOR_ID = 0x21ec5a5f
    SUBCLASS_OF_ID = 0x23b2afb6

    def __init__(self, email: str):
        self.email = email

    def to_dict(self):
        return {
            '_': 'SecurePlainEmail',
            'email': self.email,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.email))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_email = reader.tgread_string()
        _args['email'] = _val_email
        return cls(**_args)


class SecurePlainPhone(TLObject):
    """TL type: securePlainPhone"""
    CONSTRUCTOR_ID = 0x7d6099dd
    SUBCLASS_OF_ID = 0x23b2afb6

    def __init__(self, phone: str):
        self.phone = phone

    def to_dict(self):
        return {
            '_': 'SecurePlainPhone',
            'phone': self.phone,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.phone))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone = reader.tgread_string()
        _args['phone'] = _val_phone
        return cls(**_args)


class SecureRequiredType(TLObject):
    """TL type: secureRequiredType"""
    CONSTRUCTOR_ID = 0x829d99da
    SUBCLASS_OF_ID = 0x7c7b420a

    def __init__(self, type: 'TypeSecureValueType', native_names: Optional[bool] = None, selfie_required: Optional[bool] = None, translation_required: Optional[bool] = None):
        self.type = type
        self.native_names = native_names
        self.selfie_required = selfie_required
        self.translation_required = translation_required

    def to_dict(self):
        return {
            '_': 'SecureRequiredType',
            'type': self.type,
            'native_names': self.native_names,
            'selfie_required': self.selfie_required,
            'translation_required': self.translation_required,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.native_names:
            flags |= (1 << 0)
        if self.selfie_required:
            flags |= (1 << 1)
        if self.translation_required:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.type))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['native_names'] = bool(flags & (1 << 0))
        _args['selfie_required'] = bool(flags & (1 << 1))
        _args['translation_required'] = bool(flags & (1 << 2))
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        return cls(**_args)


class SecureRequiredTypeOneOf(TLObject):
    """TL type: secureRequiredTypeOneOf"""
    CONSTRUCTOR_ID = 0x027477b4
    SUBCLASS_OF_ID = 0x7c7b420a

    def __init__(self, types: List['TypeSecureRequiredType']):
        self.types = types

    def to_dict(self):
        return {
            '_': 'SecureRequiredTypeOneOf',
            'types': self.types,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.types)))
        for item in self.types:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_types = reader.read_int()
        _list_types = []
        for _ in range(_count_types):
            _item_types = reader.tgread_object()
            _list_types.append(_item_types)
        _args['types'] = _list_types
        return cls(**_args)


class SecureSecretSettings(TLObject):
    """TL type: secureSecretSettings"""
    CONSTRUCTOR_ID = 0x1527bcac
    SUBCLASS_OF_ID = 0xc6c802fb

    def __init__(self, secure_algo: 'TypeSecurePasswordKdfAlgo', secure_secret: bytes, secure_secret_id: int):
        self.secure_algo = secure_algo
        self.secure_secret = secure_secret
        self.secure_secret_id = secure_secret_id

    def to_dict(self):
        return {
            '_': 'SecureSecretSettings',
            'secure_algo': self.secure_algo,
            'secure_secret': self.secure_secret,
            'secure_secret_id': self.secure_secret_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.secure_algo))
        buf.write(TLObject.serialize_bytes(self.secure_secret))
        buf.write(struct.pack('<q', self.secure_secret_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_secure_algo = reader.tgread_object()
        _args['secure_algo'] = _val_secure_algo
        _val_secure_secret = reader.tgread_bytes()
        _args['secure_secret'] = _val_secure_secret
        _val_secure_secret_id = reader.read_long()
        _args['secure_secret_id'] = _val_secure_secret_id
        return cls(**_args)


class SecureValue(TLObject):
    """TL type: secureValue"""
    CONSTRUCTOR_ID = 0x187fa0ca
    SUBCLASS_OF_ID = 0x051138ae

    def __init__(self, type: 'TypeSecureValueType', hash: bytes, data: Optional['TypeSecureData'] = None, front_side: Optional['TypeSecureFile'] = None, reverse_side: Optional['TypeSecureFile'] = None, selfie: Optional['TypeSecureFile'] = None, translation: Optional[List['TypeSecureFile']] = None, files: Optional[List['TypeSecureFile']] = None, plain_data: Optional['TypeSecurePlainData'] = None):
        self.type = type
        self.hash = hash
        self.data = data
        self.front_side = front_side
        self.reverse_side = reverse_side
        self.selfie = selfie
        self.translation = translation
        self.files = files
        self.plain_data = plain_data

    def to_dict(self):
        return {
            '_': 'SecureValue',
            'type': self.type,
            'hash': self.hash,
            'data': self.data,
            'front_side': self.front_side,
            'reverse_side': self.reverse_side,
            'selfie': self.selfie,
            'translation': self.translation,
            'files': self.files,
            'plain_data': self.plain_data,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.data is not None:
            flags |= (1 << 0)
        if self.front_side is not None:
            flags |= (1 << 1)
        if self.reverse_side is not None:
            flags |= (1 << 2)
        if self.selfie is not None:
            flags |= (1 << 3)
        if self.translation is not None:
            flags |= (1 << 6)
        if self.files is not None:
            flags |= (1 << 4)
        if self.plain_data is not None:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.hash))
        if self.data is not None:
            buf.write(bytes(self.data))
        if self.front_side is not None:
            buf.write(bytes(self.front_side))
        if self.reverse_side is not None:
            buf.write(bytes(self.reverse_side))
        if self.selfie is not None:
            buf.write(bytes(self.selfie))
        if self.translation is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.translation)))
            for item in self.translation:
                buf.write(bytes(self.item))
        if self.files is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.files)))
            for item in self.files:
                buf.write(bytes(self.item))
        if self.plain_data is not None:
            buf.write(bytes(self.plain_data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        if flags & (1 << 0):
            _val_data = reader.tgread_object()
            _args['data'] = _val_data
        else:
            _args['data'] = None
        if flags & (1 << 1):
            _val_front_side = reader.tgread_object()
            _args['front_side'] = _val_front_side
        else:
            _args['front_side'] = None
        if flags & (1 << 2):
            _val_reverse_side = reader.tgread_object()
            _args['reverse_side'] = _val_reverse_side
        else:
            _args['reverse_side'] = None
        if flags & (1 << 3):
            _val_selfie = reader.tgread_object()
            _args['selfie'] = _val_selfie
        else:
            _args['selfie'] = None
        if flags & (1 << 6):
            reader.read_int(signed=False)  # skip vector id
            _count_translation = reader.read_int()
            _list_translation = []
            for _ in range(_count_translation):
                _item_translation = reader.tgread_object()
                _list_translation.append(_item_translation)
            _args['translation'] = _list_translation
        else:
            _args['translation'] = None
        if flags & (1 << 4):
            reader.read_int(signed=False)  # skip vector id
            _count_files = reader.read_int()
            _list_files = []
            for _ in range(_count_files):
                _item_files = reader.tgread_object()
                _list_files.append(_item_files)
            _args['files'] = _list_files
        else:
            _args['files'] = None
        if flags & (1 << 5):
            _val_plain_data = reader.tgread_object()
            _args['plain_data'] = _val_plain_data
        else:
            _args['plain_data'] = None
        _val_hash = reader.tgread_bytes()
        _args['hash'] = _val_hash
        return cls(**_args)


class SecureValueError(TLObject):
    """TL type: secureValueError"""
    CONSTRUCTOR_ID = 0x869d758f
    SUBCLASS_OF_ID = 0x06075fce

    def __init__(self, type: 'TypeSecureValueType', hash: bytes, text: str):
        self.type = type
        self.hash = hash
        self.text = text

    def to_dict(self):
        return {
            '_': 'SecureValueError',
            'type': self.type,
            'hash': self.hash,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.hash))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        _val_hash = reader.tgread_bytes()
        _args['hash'] = _val_hash
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class SecureValueErrorData(TLObject):
    """TL type: secureValueErrorData"""
    CONSTRUCTOR_ID = 0xe8a40bd9
    SUBCLASS_OF_ID = 0x06075fce

    def __init__(self, type: 'TypeSecureValueType', data_hash: bytes, field: str, text: str):
        self.type = type
        self.data_hash = data_hash
        self.field = field
        self.text = text

    def to_dict(self):
        return {
            '_': 'SecureValueErrorData',
            'type': self.type,
            'data_hash': self.data_hash,
            'field': self.field,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.data_hash))
        buf.write(TLObject.serialize_bytes(self.field))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        _val_data_hash = reader.tgread_bytes()
        _args['data_hash'] = _val_data_hash
        _val_field = reader.tgread_string()
        _args['field'] = _val_field
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class SecureValueErrorFile(TLObject):
    """TL type: secureValueErrorFile"""
    CONSTRUCTOR_ID = 0x7a700873
    SUBCLASS_OF_ID = 0x06075fce

    def __init__(self, type: 'TypeSecureValueType', file_hash: bytes, text: str):
        self.type = type
        self.file_hash = file_hash
        self.text = text

    def to_dict(self):
        return {
            '_': 'SecureValueErrorFile',
            'type': self.type,
            'file_hash': self.file_hash,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.file_hash))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        _val_file_hash = reader.tgread_bytes()
        _args['file_hash'] = _val_file_hash
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class SecureValueErrorFiles(TLObject):
    """TL type: secureValueErrorFiles"""
    CONSTRUCTOR_ID = 0x666220e9
    SUBCLASS_OF_ID = 0x06075fce

    def __init__(self, type: 'TypeSecureValueType', file_hash: List[bytes], text: str):
        self.type = type
        self.file_hash = file_hash
        self.text = text

    def to_dict(self):
        return {
            '_': 'SecureValueErrorFiles',
            'type': self.type,
            'file_hash': self.file_hash,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.type))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.file_hash)))
        for item in self.file_hash:
            buf.write(TLObject.serialize_bytes(self.item))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        reader.read_int(signed=False)  # skip vector id
        _count_file_hash = reader.read_int()
        _list_file_hash = []
        for _ in range(_count_file_hash):
            _item_file_hash = reader.tgread_bytes()
            _list_file_hash.append(_item_file_hash)
        _args['file_hash'] = _list_file_hash
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class SecureValueErrorFrontSide(TLObject):
    """TL type: secureValueErrorFrontSide"""
    CONSTRUCTOR_ID = 0x00be3dfa
    SUBCLASS_OF_ID = 0x06075fce

    def __init__(self, type: 'TypeSecureValueType', file_hash: bytes, text: str):
        self.type = type
        self.file_hash = file_hash
        self.text = text

    def to_dict(self):
        return {
            '_': 'SecureValueErrorFrontSide',
            'type': self.type,
            'file_hash': self.file_hash,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.file_hash))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        _val_file_hash = reader.tgread_bytes()
        _args['file_hash'] = _val_file_hash
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class SecureValueErrorReverseSide(TLObject):
    """TL type: secureValueErrorReverseSide"""
    CONSTRUCTOR_ID = 0x868a2aa5
    SUBCLASS_OF_ID = 0x06075fce

    def __init__(self, type: 'TypeSecureValueType', file_hash: bytes, text: str):
        self.type = type
        self.file_hash = file_hash
        self.text = text

    def to_dict(self):
        return {
            '_': 'SecureValueErrorReverseSide',
            'type': self.type,
            'file_hash': self.file_hash,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.file_hash))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        _val_file_hash = reader.tgread_bytes()
        _args['file_hash'] = _val_file_hash
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class SecureValueErrorSelfie(TLObject):
    """TL type: secureValueErrorSelfie"""
    CONSTRUCTOR_ID = 0xe537ced6
    SUBCLASS_OF_ID = 0x06075fce

    def __init__(self, type: 'TypeSecureValueType', file_hash: bytes, text: str):
        self.type = type
        self.file_hash = file_hash
        self.text = text

    def to_dict(self):
        return {
            '_': 'SecureValueErrorSelfie',
            'type': self.type,
            'file_hash': self.file_hash,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.file_hash))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        _val_file_hash = reader.tgread_bytes()
        _args['file_hash'] = _val_file_hash
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class SecureValueErrorTranslationFile(TLObject):
    """TL type: secureValueErrorTranslationFile"""
    CONSTRUCTOR_ID = 0xa1144770
    SUBCLASS_OF_ID = 0x06075fce

    def __init__(self, type: 'TypeSecureValueType', file_hash: bytes, text: str):
        self.type = type
        self.file_hash = file_hash
        self.text = text

    def to_dict(self):
        return {
            '_': 'SecureValueErrorTranslationFile',
            'type': self.type,
            'file_hash': self.file_hash,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.file_hash))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        _val_file_hash = reader.tgread_bytes()
        _args['file_hash'] = _val_file_hash
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class SecureValueErrorTranslationFiles(TLObject):
    """TL type: secureValueErrorTranslationFiles"""
    CONSTRUCTOR_ID = 0x34636dd8
    SUBCLASS_OF_ID = 0x06075fce

    def __init__(self, type: 'TypeSecureValueType', file_hash: List[bytes], text: str):
        self.type = type
        self.file_hash = file_hash
        self.text = text

    def to_dict(self):
        return {
            '_': 'SecureValueErrorTranslationFiles',
            'type': self.type,
            'file_hash': self.file_hash,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.type))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.file_hash)))
        for item in self.file_hash:
            buf.write(TLObject.serialize_bytes(self.item))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        reader.read_int(signed=False)  # skip vector id
        _count_file_hash = reader.read_int()
        _list_file_hash = []
        for _ in range(_count_file_hash):
            _item_file_hash = reader.tgread_bytes()
            _list_file_hash.append(_item_file_hash)
        _args['file_hash'] = _list_file_hash
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class SecureValueHash(TLObject):
    """TL type: secureValueHash"""
    CONSTRUCTOR_ID = 0xed1ecdb0
    SUBCLASS_OF_ID = 0xd5f5c007

    def __init__(self, type: 'TypeSecureValueType', hash: bytes):
        self.type = type
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'SecureValueHash',
            'type': self.type,
            'hash': self.hash,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_type = reader.tgread_object()
        _args['type'] = _val_type
        _val_hash = reader.tgread_bytes()
        _args['hash'] = _val_hash
        return cls(**_args)


class SecureValueTypeAddress(TLObject):
    """TL type: secureValueTypeAddress"""
    CONSTRUCTOR_ID = 0xcbe31e26
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypeAddress',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypeBankStatement(TLObject):
    """TL type: secureValueTypeBankStatement"""
    CONSTRUCTOR_ID = 0x89137c0d
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypeBankStatement',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypeDriverLicense(TLObject):
    """TL type: secureValueTypeDriverLicense"""
    CONSTRUCTOR_ID = 0x06e425c4
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypeDriverLicense',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypeEmail(TLObject):
    """TL type: secureValueTypeEmail"""
    CONSTRUCTOR_ID = 0x8e3ca7ee
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypeEmail',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypeIdentityCard(TLObject):
    """TL type: secureValueTypeIdentityCard"""
    CONSTRUCTOR_ID = 0xa0d0744b
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypeIdentityCard',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypeInternalPassport(TLObject):
    """TL type: secureValueTypeInternalPassport"""
    CONSTRUCTOR_ID = 0x99a48f23
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypeInternalPassport',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypePassport(TLObject):
    """TL type: secureValueTypePassport"""
    CONSTRUCTOR_ID = 0x3dac6a00
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypePassport',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypePassportRegistration(TLObject):
    """TL type: secureValueTypePassportRegistration"""
    CONSTRUCTOR_ID = 0x99e3806a
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypePassportRegistration',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypePersonalDetails(TLObject):
    """TL type: secureValueTypePersonalDetails"""
    CONSTRUCTOR_ID = 0x9d2a81e3
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypePersonalDetails',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypePhone(TLObject):
    """TL type: secureValueTypePhone"""
    CONSTRUCTOR_ID = 0xb320aadb
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypePhone',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypeRentalAgreement(TLObject):
    """TL type: secureValueTypeRentalAgreement"""
    CONSTRUCTOR_ID = 0x8b883488
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypeRentalAgreement',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypeTemporaryRegistration(TLObject):
    """TL type: secureValueTypeTemporaryRegistration"""
    CONSTRUCTOR_ID = 0xea02ec33
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypeTemporaryRegistration',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SecureValueTypeUtilityBill(TLObject):
    """TL type: secureValueTypeUtilityBill"""
    CONSTRUCTOR_ID = 0xfc36954e
    SUBCLASS_OF_ID = 0x8893f596

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SecureValueTypeUtilityBill',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SendAsPeer(TLObject):
    """TL type: sendAsPeer"""
    CONSTRUCTOR_ID = 0xb81c7034
    SUBCLASS_OF_ID = 0x442381e4

    def __init__(self, peer: 'TypePeer', premium_required: Optional[bool] = None):
        self.peer = peer
        self.premium_required = premium_required

    def to_dict(self):
        return {
            '_': 'SendAsPeer',
            'peer': self.peer,
            'premium_required': self.premium_required,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.premium_required:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['premium_required'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class SendMessageCancelAction(TLObject):
    """TL type: sendMessageCancelAction"""
    CONSTRUCTOR_ID = 0xfd5ec8f5
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SendMessageCancelAction',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SendMessageChooseContactAction(TLObject):
    """TL type: sendMessageChooseContactAction"""
    CONSTRUCTOR_ID = 0x628cbc6f
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SendMessageChooseContactAction',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SendMessageChooseStickerAction(TLObject):
    """TL type: sendMessageChooseStickerAction"""
    CONSTRUCTOR_ID = 0xb05ac6b1
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SendMessageChooseStickerAction',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SendMessageEmojiInteraction(TLObject):
    """TL type: sendMessageEmojiInteraction"""
    CONSTRUCTOR_ID = 0x25972bcb
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self, emoticon: str, msg_id: int, interaction: 'TypeDataJSON'):
        self.emoticon = emoticon
        self.msg_id = msg_id
        self.interaction = interaction

    def to_dict(self):
        return {
            '_': 'SendMessageEmojiInteraction',
            'emoticon': self.emoticon,
            'msg_id': self.msg_id,
            'interaction': self.interaction,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.emoticon))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(bytes(self.interaction))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        _val_interaction = reader.tgread_object()
        _args['interaction'] = _val_interaction
        return cls(**_args)


class SendMessageEmojiInteractionSeen(TLObject):
    """TL type: sendMessageEmojiInteractionSeen"""
    CONSTRUCTOR_ID = 0xb665902e
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self, emoticon: str):
        self.emoticon = emoticon

    def to_dict(self):
        return {
            '_': 'SendMessageEmojiInteractionSeen',
            'emoticon': self.emoticon,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.emoticon))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        return cls(**_args)


class SendMessageGamePlayAction(TLObject):
    """TL type: sendMessageGamePlayAction"""
    CONSTRUCTOR_ID = 0xdd6a8f48
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SendMessageGamePlayAction',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SendMessageGeoLocationAction(TLObject):
    """TL type: sendMessageGeoLocationAction"""
    CONSTRUCTOR_ID = 0x176f8ba1
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SendMessageGeoLocationAction',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SendMessageHistoryImportAction(TLObject):
    """TL type: sendMessageHistoryImportAction"""
    CONSTRUCTOR_ID = 0xdbda9246
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self, progress: int):
        self.progress = progress

    def to_dict(self):
        return {
            '_': 'SendMessageHistoryImportAction',
            'progress': self.progress,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.progress))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_progress = reader.read_int()
        _args['progress'] = _val_progress
        return cls(**_args)


class SendMessageRecordAudioAction(TLObject):
    """TL type: sendMessageRecordAudioAction"""
    CONSTRUCTOR_ID = 0xd52f73f7
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SendMessageRecordAudioAction',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SendMessageRecordRoundAction(TLObject):
    """TL type: sendMessageRecordRoundAction"""
    CONSTRUCTOR_ID = 0x88f27fbc
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SendMessageRecordRoundAction',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SendMessageRecordVideoAction(TLObject):
    """TL type: sendMessageRecordVideoAction"""
    CONSTRUCTOR_ID = 0xa187d66f
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SendMessageRecordVideoAction',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SendMessageTextDraftAction(TLObject):
    """TL type: sendMessageTextDraftAction"""
    CONSTRUCTOR_ID = 0x376d975c
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self, text: 'TypeTextWithEntities', random_id: int = None):
        self.text = text
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'SendMessageTextDraftAction',
            'text': self.text,
            'random_id': self.random_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        buf.write(struct.pack('<q', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class SendMessageTypingAction(TLObject):
    """TL type: sendMessageTypingAction"""
    CONSTRUCTOR_ID = 0x16bf744e
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SendMessageTypingAction',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SendMessageUploadAudioAction(TLObject):
    """TL type: sendMessageUploadAudioAction"""
    CONSTRUCTOR_ID = 0xf351d7ab
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self, progress: int):
        self.progress = progress

    def to_dict(self):
        return {
            '_': 'SendMessageUploadAudioAction',
            'progress': self.progress,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.progress))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_progress = reader.read_int()
        _args['progress'] = _val_progress
        return cls(**_args)


class SendMessageUploadDocumentAction(TLObject):
    """TL type: sendMessageUploadDocumentAction"""
    CONSTRUCTOR_ID = 0xaa0cd9e4
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self, progress: int):
        self.progress = progress

    def to_dict(self):
        return {
            '_': 'SendMessageUploadDocumentAction',
            'progress': self.progress,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.progress))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_progress = reader.read_int()
        _args['progress'] = _val_progress
        return cls(**_args)


class SendMessageUploadPhotoAction(TLObject):
    """TL type: sendMessageUploadPhotoAction"""
    CONSTRUCTOR_ID = 0xd1d34a26
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self, progress: int):
        self.progress = progress

    def to_dict(self):
        return {
            '_': 'SendMessageUploadPhotoAction',
            'progress': self.progress,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.progress))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_progress = reader.read_int()
        _args['progress'] = _val_progress
        return cls(**_args)


class SendMessageUploadRoundAction(TLObject):
    """TL type: sendMessageUploadRoundAction"""
    CONSTRUCTOR_ID = 0x243e1c66
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self, progress: int):
        self.progress = progress

    def to_dict(self):
        return {
            '_': 'SendMessageUploadRoundAction',
            'progress': self.progress,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.progress))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_progress = reader.read_int()
        _args['progress'] = _val_progress
        return cls(**_args)


class SendMessageUploadVideoAction(TLObject):
    """TL type: sendMessageUploadVideoAction"""
    CONSTRUCTOR_ID = 0xe9763aec
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self, progress: int):
        self.progress = progress

    def to_dict(self):
        return {
            '_': 'SendMessageUploadVideoAction',
            'progress': self.progress,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.progress))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_progress = reader.read_int()
        _args['progress'] = _val_progress
        return cls(**_args)


class ShippingOption(TLObject):
    """TL type: shippingOption"""
    CONSTRUCTOR_ID = 0xb6213cdf
    SUBCLASS_OF_ID = 0xf4e94c78

    def __init__(self, id: str, title: str, prices: List['TypeLabeledPrice']):
        self.id = id
        self.title = title
        self.prices = prices

    def to_dict(self):
        return {
            '_': 'ShippingOption',
            'id': self.id,
            'title': self.title,
            'prices': self.prices,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.prices)))
        for item in self.prices:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        reader.read_int(signed=False)  # skip vector id
        _count_prices = reader.read_int()
        _list_prices = []
        for _ in range(_count_prices):
            _item_prices = reader.tgread_object()
            _list_prices.append(_item_prices)
        _args['prices'] = _list_prices
        return cls(**_args)


class SmsJob(TLObject):
    """TL type: smsJob"""
    CONSTRUCTOR_ID = 0xe6a1eeb8
    SUBCLASS_OF_ID = 0x1f24187e

    def __init__(self, job_id: str, phone_number: str, text: str):
        self.job_id = job_id
        self.phone_number = phone_number
        self.text = text

    def to_dict(self):
        return {
            '_': 'SmsJob',
            'job_id': self.job_id,
            'phone_number': self.phone_number,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.job_id))
        buf.write(TLObject.serialize_bytes(self.phone_number))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_job_id = reader.tgread_string()
        _args['job_id'] = _val_job_id
        _val_phone_number = reader.tgread_string()
        _args['phone_number'] = _val_phone_number
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class SpeakingInGroupCallAction(TLObject):
    """TL type: speakingInGroupCallAction"""
    CONSTRUCTOR_ID = 0xd92c2285
    SUBCLASS_OF_ID = 0x20b2cc21

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'SpeakingInGroupCallAction',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class SponsoredMessage(TLObject):
    """TL type: sponsoredMessage"""
    CONSTRUCTOR_ID = 0x7dbf8673
    SUBCLASS_OF_ID = 0xe157d836

    def __init__(self, url: str, title: str, message: str, button_text: str, recommended: Optional[bool] = None, can_report: Optional[bool] = None, random_id: bytes = None, entities: Optional[List['TypeMessageEntity']] = None, photo: Optional['TypePhoto'] = None, media: Optional['TypeMessageMedia'] = None, color: Optional['TypePeerColor'] = None, sponsor_info: Optional[str] = None, additional_info: Optional[str] = None, min_display_duration: Optional[int] = None, max_display_duration: Optional[int] = None):
        self.url = url
        self.title = title
        self.message = message
        self.button_text = button_text
        self.recommended = recommended
        self.can_report = can_report
        self.random_id = random_id
        self.entities = entities
        self.photo = photo
        self.media = media
        self.color = color
        self.sponsor_info = sponsor_info
        self.additional_info = additional_info
        self.min_display_duration = min_display_duration
        self.max_display_duration = max_display_duration

    def to_dict(self):
        return {
            '_': 'SponsoredMessage',
            'url': self.url,
            'title': self.title,
            'message': self.message,
            'button_text': self.button_text,
            'recommended': self.recommended,
            'can_report': self.can_report,
            'random_id': self.random_id,
            'entities': self.entities,
            'photo': self.photo,
            'media': self.media,
            'color': self.color,
            'sponsor_info': self.sponsor_info,
            'additional_info': self.additional_info,
            'min_display_duration': self.min_display_duration,
            'max_display_duration': self.max_display_duration,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.recommended:
            flags |= (1 << 5)
        if self.can_report:
            flags |= (1 << 12)
        if self.entities is not None:
            flags |= (1 << 1)
        if self.photo is not None:
            flags |= (1 << 6)
        if self.media is not None:
            flags |= (1 << 14)
        if self.color is not None:
            flags |= (1 << 13)
        if self.sponsor_info is not None:
            flags |= (1 << 7)
        if self.additional_info is not None:
            flags |= (1 << 8)
        if self.max_display_duration is not None:
            flags |= (1 << 15)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.message))
        buf.write(TLObject.serialize_bytes(self.button_text))
        buf.write(TLObject.serialize_bytes(self.random_id))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        if self.media is not None:
            buf.write(bytes(self.media))
        if self.color is not None:
            buf.write(bytes(self.color))
        if self.sponsor_info is not None:
            buf.write(TLObject.serialize_bytes(self.sponsor_info))
        if self.additional_info is not None:
            buf.write(TLObject.serialize_bytes(self.additional_info))
        if self.min_display_duration is not None:
            buf.write(struct.pack('<i', self.min_display_duration))
        if self.max_display_duration is not None:
            buf.write(struct.pack('<i', self.max_display_duration))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['recommended'] = bool(flags & (1 << 5))
        _args['can_report'] = bool(flags & (1 << 12))
        _val_random_id = reader.tgread_bytes()
        _args['random_id'] = _val_random_id
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 6):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        if flags & (1 << 14):
            _val_media = reader.tgread_object()
            _args['media'] = _val_media
        else:
            _args['media'] = None
        if flags & (1 << 13):
            _val_color = reader.tgread_object()
            _args['color'] = _val_color
        else:
            _args['color'] = None
        _val_button_text = reader.tgread_string()
        _args['button_text'] = _val_button_text
        if flags & (1 << 7):
            _val_sponsor_info = reader.tgread_string()
            _args['sponsor_info'] = _val_sponsor_info
        else:
            _args['sponsor_info'] = None
        if flags & (1 << 8):
            _val_additional_info = reader.tgread_string()
            _args['additional_info'] = _val_additional_info
        else:
            _args['additional_info'] = None
        if flags & (1 << 15):
            _val_min_display_duration = reader.read_int()
            _args['min_display_duration'] = _val_min_display_duration
        else:
            _args['min_display_duration'] = None
        if flags & (1 << 15):
            _val_max_display_duration = reader.read_int()
            _args['max_display_duration'] = _val_max_display_duration
        else:
            _args['max_display_duration'] = None
        return cls(**_args)


class SponsoredMessageReportOption(TLObject):
    """TL type: sponsoredMessageReportOption"""
    CONSTRUCTOR_ID = 0x430d3150
    SUBCLASS_OF_ID = 0xdd32a718

    def __init__(self, text: str, option: bytes):
        self.text = text
        self.option = option

    def to_dict(self):
        return {
            '_': 'SponsoredMessageReportOption',
            'text': self.text,
            'option': self.option,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.option))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        _val_option = reader.tgread_bytes()
        _args['option'] = _val_option
        return cls(**_args)


class SponsoredPeer(TLObject):
    """TL type: sponsoredPeer"""
    CONSTRUCTOR_ID = 0xc69708d3
    SUBCLASS_OF_ID = 0x3f75800e

    def __init__(self, peer: 'TypePeer', random_id: bytes = None, sponsor_info: Optional[str] = None, additional_info: Optional[str] = None):
        self.peer = peer
        self.random_id = random_id
        self.sponsor_info = sponsor_info
        self.additional_info = additional_info

    def to_dict(self):
        return {
            '_': 'SponsoredPeer',
            'peer': self.peer,
            'random_id': self.random_id,
            'sponsor_info': self.sponsor_info,
            'additional_info': self.additional_info,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.sponsor_info is not None:
            flags |= (1 << 0)
        if self.additional_info is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.random_id))
        if self.sponsor_info is not None:
            buf.write(TLObject.serialize_bytes(self.sponsor_info))
        if self.additional_info is not None:
            buf.write(TLObject.serialize_bytes(self.additional_info))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_random_id = reader.tgread_bytes()
        _args['random_id'] = _val_random_id
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _val_sponsor_info = reader.tgread_string()
            _args['sponsor_info'] = _val_sponsor_info
        else:
            _args['sponsor_info'] = None
        if flags & (1 << 1):
            _val_additional_info = reader.tgread_string()
            _args['additional_info'] = _val_additional_info
        else:
            _args['additional_info'] = None
        return cls(**_args)


class StarGift(TLObject):
    """TL type: starGift"""
    CONSTRUCTOR_ID = 0x313a9547
    SUBCLASS_OF_ID = 0xc31c590b

    def __init__(self, id: int, sticker: 'TypeDocument', stars: int, convert_stars: int, limited: Optional[bool] = None, sold_out: Optional[bool] = None, birthday: Optional[bool] = None, require_premium: Optional[bool] = None, limited_per_user: Optional[bool] = None, peer_color_available: Optional[bool] = None, auction: Optional[bool] = None, availability_remains: Optional[int] = None, availability_total: Optional[int] = None, availability_resale: Optional[int] = None, first_sale_date: Optional[datetime] = None, last_sale_date: Optional[datetime] = None, upgrade_stars: Optional[int] = None, resell_min_stars: Optional[int] = None, title: Optional[str] = None, released_by: Optional['TypePeer'] = None, per_user_total: Optional[int] = None, per_user_remains: Optional[int] = None, locked_until_date: Optional[datetime] = None, auction_slug: Optional[str] = None, gifts_per_round: Optional[int] = None, auction_start_date: Optional[datetime] = None, upgrade_variants: Optional[int] = None, background: Optional['TypeStarGiftBackground'] = None):
        self.id = id
        self.sticker = sticker
        self.stars = stars
        self.convert_stars = convert_stars
        self.limited = limited
        self.sold_out = sold_out
        self.birthday = birthday
        self.require_premium = require_premium
        self.limited_per_user = limited_per_user
        self.peer_color_available = peer_color_available
        self.auction = auction
        self.availability_remains = availability_remains
        self.availability_total = availability_total
        self.availability_resale = availability_resale
        self.first_sale_date = first_sale_date
        self.last_sale_date = last_sale_date
        self.upgrade_stars = upgrade_stars
        self.resell_min_stars = resell_min_stars
        self.title = title
        self.released_by = released_by
        self.per_user_total = per_user_total
        self.per_user_remains = per_user_remains
        self.locked_until_date = locked_until_date
        self.auction_slug = auction_slug
        self.gifts_per_round = gifts_per_round
        self.auction_start_date = auction_start_date
        self.upgrade_variants = upgrade_variants
        self.background = background

    def to_dict(self):
        return {
            '_': 'StarGift',
            'id': self.id,
            'sticker': self.sticker,
            'stars': self.stars,
            'convert_stars': self.convert_stars,
            'limited': self.limited,
            'sold_out': self.sold_out,
            'birthday': self.birthday,
            'require_premium': self.require_premium,
            'limited_per_user': self.limited_per_user,
            'peer_color_available': self.peer_color_available,
            'auction': self.auction,
            'availability_remains': self.availability_remains,
            'availability_total': self.availability_total,
            'availability_resale': self.availability_resale,
            'first_sale_date': self.first_sale_date,
            'last_sale_date': self.last_sale_date,
            'upgrade_stars': self.upgrade_stars,
            'resell_min_stars': self.resell_min_stars,
            'title': self.title,
            'released_by': self.released_by,
            'per_user_total': self.per_user_total,
            'per_user_remains': self.per_user_remains,
            'locked_until_date': self.locked_until_date,
            'auction_slug': self.auction_slug,
            'gifts_per_round': self.gifts_per_round,
            'auction_start_date': self.auction_start_date,
            'upgrade_variants': self.upgrade_variants,
            'background': self.background,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.availability_total is not None:
            flags |= (1 << 0)
        if self.last_sale_date is not None:
            flags |= (1 << 1)
        if self.birthday:
            flags |= (1 << 2)
        if self.require_premium:
            flags |= (1 << 7)
        if self.per_user_remains is not None:
            flags |= (1 << 8)
        if self.peer_color_available:
            flags |= (1 << 10)
        if self.auction_start_date is not None:
            flags |= (1 << 11)
        if self.resell_min_stars is not None:
            flags |= (1 << 4)
        if self.upgrade_stars is not None:
            flags |= (1 << 3)
        if self.title is not None:
            flags |= (1 << 5)
        if self.released_by is not None:
            flags |= (1 << 6)
        if self.locked_until_date is not None:
            flags |= (1 << 9)
        if self.upgrade_variants is not None:
            flags |= (1 << 12)
        if self.background is not None:
            flags |= (1 << 13)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(bytes(self.sticker))
        buf.write(struct.pack('<q', self.stars))
        buf.write(struct.pack('<q', self.convert_stars))
        if self.availability_remains is not None:
            buf.write(struct.pack('<i', self.availability_remains))
        if self.availability_total is not None:
            buf.write(struct.pack('<i', self.availability_total))
        if self.availability_resale is not None:
            buf.write(struct.pack('<q', self.availability_resale))
        if self.first_sale_date is not None:
            buf.write(struct.pack('<i', self.first_sale_date))
        if self.last_sale_date is not None:
            buf.write(struct.pack('<i', self.last_sale_date))
        if self.upgrade_stars is not None:
            buf.write(struct.pack('<q', self.upgrade_stars))
        if self.resell_min_stars is not None:
            buf.write(struct.pack('<q', self.resell_min_stars))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.released_by is not None:
            buf.write(bytes(self.released_by))
        if self.per_user_total is not None:
            buf.write(struct.pack('<i', self.per_user_total))
        if self.per_user_remains is not None:
            buf.write(struct.pack('<i', self.per_user_remains))
        if self.locked_until_date is not None:
            buf.write(struct.pack('<i', self.locked_until_date))
        if self.auction_slug is not None:
            buf.write(TLObject.serialize_bytes(self.auction_slug))
        if self.gifts_per_round is not None:
            buf.write(struct.pack('<i', self.gifts_per_round))
        if self.auction_start_date is not None:
            buf.write(struct.pack('<i', self.auction_start_date))
        if self.upgrade_variants is not None:
            buf.write(struct.pack('<i', self.upgrade_variants))
        if self.background is not None:
            buf.write(bytes(self.background))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['limited'] = bool(flags & (1 << 0))
        _args['sold_out'] = bool(flags & (1 << 1))
        _args['birthday'] = bool(flags & (1 << 2))
        _args['require_premium'] = bool(flags & (1 << 7))
        _args['limited_per_user'] = bool(flags & (1 << 8))
        _args['peer_color_available'] = bool(flags & (1 << 10))
        _args['auction'] = bool(flags & (1 << 11))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_sticker = reader.tgread_object()
        _args['sticker'] = _val_sticker
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        if flags & (1 << 0):
            _val_availability_remains = reader.read_int()
            _args['availability_remains'] = _val_availability_remains
        else:
            _args['availability_remains'] = None
        if flags & (1 << 0):
            _val_availability_total = reader.read_int()
            _args['availability_total'] = _val_availability_total
        else:
            _args['availability_total'] = None
        if flags & (1 << 4):
            _val_availability_resale = reader.read_long()
            _args['availability_resale'] = _val_availability_resale
        else:
            _args['availability_resale'] = None
        _val_convert_stars = reader.read_long()
        _args['convert_stars'] = _val_convert_stars
        if flags & (1 << 1):
            _val_first_sale_date = reader.read_int()
            _args['first_sale_date'] = _val_first_sale_date
        else:
            _args['first_sale_date'] = None
        if flags & (1 << 1):
            _val_last_sale_date = reader.read_int()
            _args['last_sale_date'] = _val_last_sale_date
        else:
            _args['last_sale_date'] = None
        if flags & (1 << 3):
            _val_upgrade_stars = reader.read_long()
            _args['upgrade_stars'] = _val_upgrade_stars
        else:
            _args['upgrade_stars'] = None
        if flags & (1 << 4):
            _val_resell_min_stars = reader.read_long()
            _args['resell_min_stars'] = _val_resell_min_stars
        else:
            _args['resell_min_stars'] = None
        if flags & (1 << 5):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 6):
            _val_released_by = reader.tgread_object()
            _args['released_by'] = _val_released_by
        else:
            _args['released_by'] = None
        if flags & (1 << 8):
            _val_per_user_total = reader.read_int()
            _args['per_user_total'] = _val_per_user_total
        else:
            _args['per_user_total'] = None
        if flags & (1 << 8):
            _val_per_user_remains = reader.read_int()
            _args['per_user_remains'] = _val_per_user_remains
        else:
            _args['per_user_remains'] = None
        if flags & (1 << 9):
            _val_locked_until_date = reader.read_int()
            _args['locked_until_date'] = _val_locked_until_date
        else:
            _args['locked_until_date'] = None
        if flags & (1 << 11):
            _val_auction_slug = reader.tgread_string()
            _args['auction_slug'] = _val_auction_slug
        else:
            _args['auction_slug'] = None
        if flags & (1 << 11):
            _val_gifts_per_round = reader.read_int()
            _args['gifts_per_round'] = _val_gifts_per_round
        else:
            _args['gifts_per_round'] = None
        if flags & (1 << 11):
            _val_auction_start_date = reader.read_int()
            _args['auction_start_date'] = _val_auction_start_date
        else:
            _args['auction_start_date'] = None
        if flags & (1 << 12):
            _val_upgrade_variants = reader.read_int()
            _args['upgrade_variants'] = _val_upgrade_variants
        else:
            _args['upgrade_variants'] = None
        if flags & (1 << 13):
            _val_background = reader.tgread_object()
            _args['background'] = _val_background
        else:
            _args['background'] = None
        return cls(**_args)


class StarGiftActiveAuctionState(TLObject):
    """TL type: starGiftActiveAuctionState"""
    CONSTRUCTOR_ID = 0xd31bc45d
    SUBCLASS_OF_ID = 0xb95bf5e9

    def __init__(self, gift: 'TypeStarGift', state: 'TypeStarGiftAuctionState', user_state: 'TypeStarGiftAuctionUserState'):
        self.gift = gift
        self.state = state
        self.user_state = user_state

    def to_dict(self):
        return {
            '_': 'StarGiftActiveAuctionState',
            'gift': self.gift,
            'state': self.state,
            'user_state': self.user_state,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.gift))
        buf.write(bytes(self.state))
        buf.write(bytes(self.user_state))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_gift = reader.tgread_object()
        _args['gift'] = _val_gift
        _val_state = reader.tgread_object()
        _args['state'] = _val_state
        _val_user_state = reader.tgread_object()
        _args['user_state'] = _val_user_state
        return cls(**_args)


class StarGiftAttributeBackdrop(TLObject):
    """TL type: starGiftAttributeBackdrop"""
    CONSTRUCTOR_ID = 0x9f2504e4
    SUBCLASS_OF_ID = 0x87b581c8

    def __init__(self, name: str, backdrop_id: int, center_color: int, edge_color: int, pattern_color: int, text_color: int, rarity: 'TypeStarGiftAttributeRarity'):
        self.name = name
        self.backdrop_id = backdrop_id
        self.center_color = center_color
        self.edge_color = edge_color
        self.pattern_color = pattern_color
        self.text_color = text_color
        self.rarity = rarity

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeBackdrop',
            'name': self.name,
            'backdrop_id': self.backdrop_id,
            'center_color': self.center_color,
            'edge_color': self.edge_color,
            'pattern_color': self.pattern_color,
            'text_color': self.text_color,
            'rarity': self.rarity,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.name))
        buf.write(struct.pack('<i', self.backdrop_id))
        buf.write(struct.pack('<i', self.center_color))
        buf.write(struct.pack('<i', self.edge_color))
        buf.write(struct.pack('<i', self.pattern_color))
        buf.write(struct.pack('<i', self.text_color))
        buf.write(bytes(self.rarity))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        _val_backdrop_id = reader.read_int()
        _args['backdrop_id'] = _val_backdrop_id
        _val_center_color = reader.read_int()
        _args['center_color'] = _val_center_color
        _val_edge_color = reader.read_int()
        _args['edge_color'] = _val_edge_color
        _val_pattern_color = reader.read_int()
        _args['pattern_color'] = _val_pattern_color
        _val_text_color = reader.read_int()
        _args['text_color'] = _val_text_color
        _val_rarity = reader.tgread_object()
        _args['rarity'] = _val_rarity
        return cls(**_args)


class StarGiftAttributeCounter(TLObject):
    """TL type: starGiftAttributeCounter"""
    CONSTRUCTOR_ID = 0x2eb1b658
    SUBCLASS_OF_ID = 0x8c28b293

    def __init__(self, attribute: 'TypeStarGiftAttributeId', count: int):
        self.attribute = attribute
        self.count = count

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeCounter',
            'attribute': self.attribute,
            'count': self.count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.attribute))
        buf.write(struct.pack('<i', self.count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_attribute = reader.tgread_object()
        _args['attribute'] = _val_attribute
        _val_count = reader.read_int()
        _args['count'] = _val_count
        return cls(**_args)


class StarGiftAttributeIdBackdrop(TLObject):
    """TL type: starGiftAttributeIdBackdrop"""
    CONSTRUCTOR_ID = 0x1f01c757
    SUBCLASS_OF_ID = 0xb3212ab7

    def __init__(self, backdrop_id: int):
        self.backdrop_id = backdrop_id

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeIdBackdrop',
            'backdrop_id': self.backdrop_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.backdrop_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_backdrop_id = reader.read_int()
        _args['backdrop_id'] = _val_backdrop_id
        return cls(**_args)


class StarGiftAttributeIdModel(TLObject):
    """TL type: starGiftAttributeIdModel"""
    CONSTRUCTOR_ID = 0x48aaae3c
    SUBCLASS_OF_ID = 0xb3212ab7

    def __init__(self, document_id: int):
        self.document_id = document_id

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeIdModel',
            'document_id': self.document_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.document_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_document_id = reader.read_long()
        _args['document_id'] = _val_document_id
        return cls(**_args)


class StarGiftAttributeIdPattern(TLObject):
    """TL type: starGiftAttributeIdPattern"""
    CONSTRUCTOR_ID = 0x4a162433
    SUBCLASS_OF_ID = 0xb3212ab7

    def __init__(self, document_id: int):
        self.document_id = document_id

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeIdPattern',
            'document_id': self.document_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.document_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_document_id = reader.read_long()
        _args['document_id'] = _val_document_id
        return cls(**_args)


class StarGiftAttributeModel(TLObject):
    """TL type: starGiftAttributeModel"""
    CONSTRUCTOR_ID = 0x565251e2
    SUBCLASS_OF_ID = 0x87b581c8

    def __init__(self, name: str, document: 'TypeDocument', rarity: 'TypeStarGiftAttributeRarity', crafted: Optional[bool] = None):
        self.name = name
        self.document = document
        self.rarity = rarity
        self.crafted = crafted

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeModel',
            'name': self.name,
            'document': self.document,
            'rarity': self.rarity,
            'crafted': self.crafted,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.crafted:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.name))
        buf.write(bytes(self.document))
        buf.write(bytes(self.rarity))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['crafted'] = bool(flags & (1 << 0))
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        _val_document = reader.tgread_object()
        _args['document'] = _val_document
        _val_rarity = reader.tgread_object()
        _args['rarity'] = _val_rarity
        return cls(**_args)


class StarGiftAttributeOriginalDetails(TLObject):
    """TL type: starGiftAttributeOriginalDetails"""
    CONSTRUCTOR_ID = 0xe0bff26c
    SUBCLASS_OF_ID = 0x87b581c8

    def __init__(self, recipient_id: 'TypePeer', date: Optional[datetime], sender_id: Optional['TypePeer'] = None, message: Optional['TypeTextWithEntities'] = None):
        self.recipient_id = recipient_id
        self.date = date
        self.sender_id = sender_id
        self.message = message

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeOriginalDetails',
            'recipient_id': self.recipient_id,
            'date': self.date,
            'sender_id': self.sender_id,
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.sender_id is not None:
            flags |= (1 << 0)
        if self.message is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.recipient_id))
        buf.write(struct.pack('<i', self.date))
        if self.sender_id is not None:
            buf.write(bytes(self.sender_id))
        if self.message is not None:
            buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_sender_id = reader.tgread_object()
            _args['sender_id'] = _val_sender_id
        else:
            _args['sender_id'] = None
        _val_recipient_id = reader.tgread_object()
        _args['recipient_id'] = _val_recipient_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 1):
            _val_message = reader.tgread_object()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        return cls(**_args)


class StarGiftAttributePattern(TLObject):
    """TL type: starGiftAttributePattern"""
    CONSTRUCTOR_ID = 0x4e7085ea
    SUBCLASS_OF_ID = 0x87b581c8

    def __init__(self, name: str, document: 'TypeDocument', rarity: 'TypeStarGiftAttributeRarity'):
        self.name = name
        self.document = document
        self.rarity = rarity

    def to_dict(self):
        return {
            '_': 'StarGiftAttributePattern',
            'name': self.name,
            'document': self.document,
            'rarity': self.rarity,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.name))
        buf.write(bytes(self.document))
        buf.write(bytes(self.rarity))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        _val_document = reader.tgread_object()
        _args['document'] = _val_document
        _val_rarity = reader.tgread_object()
        _args['rarity'] = _val_rarity
        return cls(**_args)


class StarGiftAttributeRarity(TLObject):
    """TL type: starGiftAttributeRarity"""
    CONSTRUCTOR_ID = 0x36437737
    SUBCLASS_OF_ID = 0x0f870d26

    def __init__(self, permille: int):
        self.permille = permille

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeRarity',
            'permille': self.permille,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.permille))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_permille = reader.read_int()
        _args['permille'] = _val_permille
        return cls(**_args)


class StarGiftAttributeRarityEpic(TLObject):
    """TL type: starGiftAttributeRarityEpic"""
    CONSTRUCTOR_ID = 0x78fbf3a8
    SUBCLASS_OF_ID = 0x0f870d26

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeRarityEpic',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StarGiftAttributeRarityLegendary(TLObject):
    """TL type: starGiftAttributeRarityLegendary"""
    CONSTRUCTOR_ID = 0xcef7e7a8
    SUBCLASS_OF_ID = 0x0f870d26

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeRarityLegendary',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StarGiftAttributeRarityRare(TLObject):
    """TL type: starGiftAttributeRarityRare"""
    CONSTRUCTOR_ID = 0xf08d516b
    SUBCLASS_OF_ID = 0x0f870d26

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeRarityRare',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StarGiftAttributeRarityUncommon(TLObject):
    """TL type: starGiftAttributeRarityUncommon"""
    CONSTRUCTOR_ID = 0xdbce6389
    SUBCLASS_OF_ID = 0x0f870d26

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarGiftAttributeRarityUncommon',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StarGiftAuctionAcquiredGift(TLObject):
    """TL type: starGiftAuctionAcquiredGift"""
    CONSTRUCTOR_ID = 0x42b00348
    SUBCLASS_OF_ID = 0x270d5233

    def __init__(self, peer: 'TypePeer', date: Optional[datetime], bid_amount: int, round: int, pos: int, name_hidden: Optional[bool] = None, message: Optional['TypeTextWithEntities'] = None, gift_num: Optional[int] = None):
        self.peer = peer
        self.date = date
        self.bid_amount = bid_amount
        self.round = round
        self.pos = pos
        self.name_hidden = name_hidden
        self.message = message
        self.gift_num = gift_num

    def to_dict(self):
        return {
            '_': 'StarGiftAuctionAcquiredGift',
            'peer': self.peer,
            'date': self.date,
            'bid_amount': self.bid_amount,
            'round': self.round,
            'pos': self.pos,
            'name_hidden': self.name_hidden,
            'message': self.message,
            'gift_num': self.gift_num,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.name_hidden:
            flags |= (1 << 0)
        if self.message is not None:
            flags |= (1 << 1)
        if self.gift_num is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.bid_amount))
        buf.write(struct.pack('<i', self.round))
        buf.write(struct.pack('<i', self.pos))
        if self.message is not None:
            buf.write(bytes(self.message))
        if self.gift_num is not None:
            buf.write(struct.pack('<i', self.gift_num))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['name_hidden'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_bid_amount = reader.read_long()
        _args['bid_amount'] = _val_bid_amount
        _val_round = reader.read_int()
        _args['round'] = _val_round
        _val_pos = reader.read_int()
        _args['pos'] = _val_pos
        if flags & (1 << 1):
            _val_message = reader.tgread_object()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        if flags & (1 << 2):
            _val_gift_num = reader.read_int()
            _args['gift_num'] = _val_gift_num
        else:
            _args['gift_num'] = None
        return cls(**_args)


class StarGiftAuctionRound(TLObject):
    """TL type: starGiftAuctionRound"""
    CONSTRUCTOR_ID = 0x3aae0528
    SUBCLASS_OF_ID = 0x44e92c34

    def __init__(self, num: int, duration: int):
        self.num = num
        self.duration = duration

    def to_dict(self):
        return {
            '_': 'StarGiftAuctionRound',
            'num': self.num,
            'duration': self.duration,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.num))
        buf.write(struct.pack('<i', self.duration))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_num = reader.read_int()
        _args['num'] = _val_num
        _val_duration = reader.read_int()
        _args['duration'] = _val_duration
        return cls(**_args)


class StarGiftAuctionRoundExtendable(TLObject):
    """TL type: starGiftAuctionRoundExtendable"""
    CONSTRUCTOR_ID = 0x0aa021e5
    SUBCLASS_OF_ID = 0x44e92c34

    def __init__(self, num: int, duration: int, extend_top: int, extend_window: int):
        self.num = num
        self.duration = duration
        self.extend_top = extend_top
        self.extend_window = extend_window

    def to_dict(self):
        return {
            '_': 'StarGiftAuctionRoundExtendable',
            'num': self.num,
            'duration': self.duration,
            'extend_top': self.extend_top,
            'extend_window': self.extend_window,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.num))
        buf.write(struct.pack('<i', self.duration))
        buf.write(struct.pack('<i', self.extend_top))
        buf.write(struct.pack('<i', self.extend_window))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_num = reader.read_int()
        _args['num'] = _val_num
        _val_duration = reader.read_int()
        _args['duration'] = _val_duration
        _val_extend_top = reader.read_int()
        _args['extend_top'] = _val_extend_top
        _val_extend_window = reader.read_int()
        _args['extend_window'] = _val_extend_window
        return cls(**_args)


class StarGiftAuctionState(TLObject):
    """TL type: starGiftAuctionState"""
    CONSTRUCTOR_ID = 0x771a4e66
    SUBCLASS_OF_ID = 0x229414fb

    def __init__(self, version: int, start_date: Optional[datetime], end_date: Optional[datetime], min_bid_amount: int, bid_levels: List['TypeAuctionBidLevel'], top_bidders: List[int], next_round_at: int, last_gift_num: int, gifts_left: int, current_round: int, total_rounds: int, rounds: List['TypeStarGiftAuctionRound']):
        self.version = version
        self.start_date = start_date
        self.end_date = end_date
        self.min_bid_amount = min_bid_amount
        self.bid_levels = bid_levels
        self.top_bidders = top_bidders
        self.next_round_at = next_round_at
        self.last_gift_num = last_gift_num
        self.gifts_left = gifts_left
        self.current_round = current_round
        self.total_rounds = total_rounds
        self.rounds = rounds

    def to_dict(self):
        return {
            '_': 'StarGiftAuctionState',
            'version': self.version,
            'start_date': self.start_date,
            'end_date': self.end_date,
            'min_bid_amount': self.min_bid_amount,
            'bid_levels': self.bid_levels,
            'top_bidders': self.top_bidders,
            'next_round_at': self.next_round_at,
            'last_gift_num': self.last_gift_num,
            'gifts_left': self.gifts_left,
            'current_round': self.current_round,
            'total_rounds': self.total_rounds,
            'rounds': self.rounds,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.version))
        buf.write(struct.pack('<i', self.start_date))
        buf.write(struct.pack('<i', self.end_date))
        buf.write(struct.pack('<q', self.min_bid_amount))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.bid_levels)))
        for item in self.bid_levels:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.top_bidders)))
        for item in self.top_bidders:
            buf.write(struct.pack('<q', self.item))
        buf.write(struct.pack('<i', self.next_round_at))
        buf.write(struct.pack('<i', self.last_gift_num))
        buf.write(struct.pack('<i', self.gifts_left))
        buf.write(struct.pack('<i', self.current_round))
        buf.write(struct.pack('<i', self.total_rounds))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.rounds)))
        for item in self.rounds:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_version = reader.read_int()
        _args['version'] = _val_version
        _val_start_date = reader.read_int()
        _args['start_date'] = _val_start_date
        _val_end_date = reader.read_int()
        _args['end_date'] = _val_end_date
        _val_min_bid_amount = reader.read_long()
        _args['min_bid_amount'] = _val_min_bid_amount
        reader.read_int(signed=False)  # skip vector id
        _count_bid_levels = reader.read_int()
        _list_bid_levels = []
        for _ in range(_count_bid_levels):
            _item_bid_levels = reader.tgread_object()
            _list_bid_levels.append(_item_bid_levels)
        _args['bid_levels'] = _list_bid_levels
        reader.read_int(signed=False)  # skip vector id
        _count_top_bidders = reader.read_int()
        _list_top_bidders = []
        for _ in range(_count_top_bidders):
            _item_top_bidders = reader.read_long()
            _list_top_bidders.append(_item_top_bidders)
        _args['top_bidders'] = _list_top_bidders
        _val_next_round_at = reader.read_int()
        _args['next_round_at'] = _val_next_round_at
        _val_last_gift_num = reader.read_int()
        _args['last_gift_num'] = _val_last_gift_num
        _val_gifts_left = reader.read_int()
        _args['gifts_left'] = _val_gifts_left
        _val_current_round = reader.read_int()
        _args['current_round'] = _val_current_round
        _val_total_rounds = reader.read_int()
        _args['total_rounds'] = _val_total_rounds
        reader.read_int(signed=False)  # skip vector id
        _count_rounds = reader.read_int()
        _list_rounds = []
        for _ in range(_count_rounds):
            _item_rounds = reader.tgread_object()
            _list_rounds.append(_item_rounds)
        _args['rounds'] = _list_rounds
        return cls(**_args)


class StarGiftAuctionStateFinished(TLObject):
    """TL type: starGiftAuctionStateFinished"""
    CONSTRUCTOR_ID = 0x972dabbf
    SUBCLASS_OF_ID = 0x229414fb

    def __init__(self, start_date: Optional[datetime], end_date: Optional[datetime], average_price: int, listed_count: Optional[int] = None, fragment_listed_count: Optional[int] = None, fragment_listed_url: Optional[str] = None):
        self.start_date = start_date
        self.end_date = end_date
        self.average_price = average_price
        self.listed_count = listed_count
        self.fragment_listed_count = fragment_listed_count
        self.fragment_listed_url = fragment_listed_url

    def to_dict(self):
        return {
            '_': 'StarGiftAuctionStateFinished',
            'start_date': self.start_date,
            'end_date': self.end_date,
            'average_price': self.average_price,
            'listed_count': self.listed_count,
            'fragment_listed_count': self.fragment_listed_count,
            'fragment_listed_url': self.fragment_listed_url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.listed_count is not None:
            flags |= (1 << 0)
        if self.fragment_listed_url is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.start_date))
        buf.write(struct.pack('<i', self.end_date))
        buf.write(struct.pack('<q', self.average_price))
        if self.listed_count is not None:
            buf.write(struct.pack('<i', self.listed_count))
        if self.fragment_listed_count is not None:
            buf.write(struct.pack('<i', self.fragment_listed_count))
        if self.fragment_listed_url is not None:
            buf.write(TLObject.serialize_bytes(self.fragment_listed_url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_start_date = reader.read_int()
        _args['start_date'] = _val_start_date
        _val_end_date = reader.read_int()
        _args['end_date'] = _val_end_date
        _val_average_price = reader.read_long()
        _args['average_price'] = _val_average_price
        if flags & (1 << 0):
            _val_listed_count = reader.read_int()
            _args['listed_count'] = _val_listed_count
        else:
            _args['listed_count'] = None
        if flags & (1 << 1):
            _val_fragment_listed_count = reader.read_int()
            _args['fragment_listed_count'] = _val_fragment_listed_count
        else:
            _args['fragment_listed_count'] = None
        if flags & (1 << 1):
            _val_fragment_listed_url = reader.tgread_string()
            _args['fragment_listed_url'] = _val_fragment_listed_url
        else:
            _args['fragment_listed_url'] = None
        return cls(**_args)


class StarGiftAuctionStateNotModified(TLObject):
    """TL type: starGiftAuctionStateNotModified"""
    CONSTRUCTOR_ID = 0xfe333952
    SUBCLASS_OF_ID = 0x229414fb

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarGiftAuctionStateNotModified',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StarGiftAuctionUserState(TLObject):
    """TL type: starGiftAuctionUserState"""
    CONSTRUCTOR_ID = 0x2eeed1c4
    SUBCLASS_OF_ID = 0x052a0eae

    def __init__(self, acquired_count: int, returned: Optional[bool] = None, bid_amount: Optional[int] = None, bid_date: Optional[datetime] = None, min_bid_amount: Optional[int] = None, bid_peer: Optional['TypePeer'] = None):
        self.acquired_count = acquired_count
        self.returned = returned
        self.bid_amount = bid_amount
        self.bid_date = bid_date
        self.min_bid_amount = min_bid_amount
        self.bid_peer = bid_peer

    def to_dict(self):
        return {
            '_': 'StarGiftAuctionUserState',
            'acquired_count': self.acquired_count,
            'returned': self.returned,
            'bid_amount': self.bid_amount,
            'bid_date': self.bid_date,
            'min_bid_amount': self.min_bid_amount,
            'bid_peer': self.bid_peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.returned:
            flags |= (1 << 1)
        if self.bid_peer is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.acquired_count))
        if self.bid_amount is not None:
            buf.write(struct.pack('<q', self.bid_amount))
        if self.bid_date is not None:
            buf.write(struct.pack('<i', self.bid_date))
        if self.min_bid_amount is not None:
            buf.write(struct.pack('<q', self.min_bid_amount))
        if self.bid_peer is not None:
            buf.write(bytes(self.bid_peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['returned'] = bool(flags & (1 << 1))
        if flags & (1 << 0):
            _val_bid_amount = reader.read_long()
            _args['bid_amount'] = _val_bid_amount
        else:
            _args['bid_amount'] = None
        if flags & (1 << 0):
            _val_bid_date = reader.read_int()
            _args['bid_date'] = _val_bid_date
        else:
            _args['bid_date'] = None
        if flags & (1 << 0):
            _val_min_bid_amount = reader.read_long()
            _args['min_bid_amount'] = _val_min_bid_amount
        else:
            _args['min_bid_amount'] = None
        if flags & (1 << 0):
            _val_bid_peer = reader.tgread_object()
            _args['bid_peer'] = _val_bid_peer
        else:
            _args['bid_peer'] = None
        _val_acquired_count = reader.read_int()
        _args['acquired_count'] = _val_acquired_count
        return cls(**_args)


class StarGiftBackground(TLObject):
    """TL type: starGiftBackground"""
    CONSTRUCTOR_ID = 0xaff56398
    SUBCLASS_OF_ID = 0x03c51a28

    def __init__(self, center_color: int, edge_color: int, text_color: int):
        self.center_color = center_color
        self.edge_color = edge_color
        self.text_color = text_color

    def to_dict(self):
        return {
            '_': 'StarGiftBackground',
            'center_color': self.center_color,
            'edge_color': self.edge_color,
            'text_color': self.text_color,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.center_color))
        buf.write(struct.pack('<i', self.edge_color))
        buf.write(struct.pack('<i', self.text_color))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_center_color = reader.read_int()
        _args['center_color'] = _val_center_color
        _val_edge_color = reader.read_int()
        _args['edge_color'] = _val_edge_color
        _val_text_color = reader.read_int()
        _args['text_color'] = _val_text_color
        return cls(**_args)


class StarGiftCollection(TLObject):
    """TL type: starGiftCollection"""
    CONSTRUCTOR_ID = 0x9d6b13b0
    SUBCLASS_OF_ID = 0x43e0cb4a

    def __init__(self, collection_id: int, title: str, gifts_count: int, hash: int, icon: Optional['TypeDocument'] = None):
        self.collection_id = collection_id
        self.title = title
        self.gifts_count = gifts_count
        self.hash = hash
        self.icon = icon

    def to_dict(self):
        return {
            '_': 'StarGiftCollection',
            'collection_id': self.collection_id,
            'title': self.title,
            'gifts_count': self.gifts_count,
            'hash': self.hash,
            'icon': self.icon,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.icon is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.collection_id))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(struct.pack('<i', self.gifts_count))
        buf.write(struct.pack('<q', self.hash))
        if self.icon is not None:
            buf.write(bytes(self.icon))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_collection_id = reader.read_int()
        _args['collection_id'] = _val_collection_id
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        if flags & (1 << 0):
            _val_icon = reader.tgread_object()
            _args['icon'] = _val_icon
        else:
            _args['icon'] = None
        _val_gifts_count = reader.read_int()
        _args['gifts_count'] = _val_gifts_count
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class StarGiftUnique(TLObject):
    """TL type: starGiftUnique"""
    CONSTRUCTOR_ID = 0x85f0a9cd
    SUBCLASS_OF_ID = 0xc31c590b

    def __init__(self, id: int, gift_id: int, title: str, slug: str, num: int, attributes: List['TypeStarGiftAttribute'], availability_issued: int, availability_total: int, require_premium: Optional[bool] = None, resale_ton_only: Optional[bool] = None, theme_available: Optional[bool] = None, burned: Optional[bool] = None, crafted: Optional[bool] = None, owner_id: Optional['TypePeer'] = None, owner_name: Optional[str] = None, owner_address: Optional[str] = None, gift_address: Optional[str] = None, resell_amount: Optional[List['TypeStarsAmount']] = None, released_by: Optional['TypePeer'] = None, value_amount: Optional[int] = None, value_currency: Optional[str] = None, value_usd_amount: Optional[int] = None, theme_peer: Optional['TypePeer'] = None, peer_color: Optional['TypePeerColor'] = None, host_id: Optional['TypePeer'] = None, offer_min_stars: Optional[int] = None, craft_chance_permille: Optional[int] = None):
        self.id = id
        self.gift_id = gift_id
        self.title = title
        self.slug = slug
        self.num = num
        self.attributes = attributes
        self.availability_issued = availability_issued
        self.availability_total = availability_total
        self.require_premium = require_premium
        self.resale_ton_only = resale_ton_only
        self.theme_available = theme_available
        self.burned = burned
        self.crafted = crafted
        self.owner_id = owner_id
        self.owner_name = owner_name
        self.owner_address = owner_address
        self.gift_address = gift_address
        self.resell_amount = resell_amount
        self.released_by = released_by
        self.value_amount = value_amount
        self.value_currency = value_currency
        self.value_usd_amount = value_usd_amount
        self.theme_peer = theme_peer
        self.peer_color = peer_color
        self.host_id = host_id
        self.offer_min_stars = offer_min_stars
        self.craft_chance_permille = craft_chance_permille

    def to_dict(self):
        return {
            '_': 'StarGiftUnique',
            'id': self.id,
            'gift_id': self.gift_id,
            'title': self.title,
            'slug': self.slug,
            'num': self.num,
            'attributes': self.attributes,
            'availability_issued': self.availability_issued,
            'availability_total': self.availability_total,
            'require_premium': self.require_premium,
            'resale_ton_only': self.resale_ton_only,
            'theme_available': self.theme_available,
            'burned': self.burned,
            'crafted': self.crafted,
            'owner_id': self.owner_id,
            'owner_name': self.owner_name,
            'owner_address': self.owner_address,
            'gift_address': self.gift_address,
            'resell_amount': self.resell_amount,
            'released_by': self.released_by,
            'value_amount': self.value_amount,
            'value_currency': self.value_currency,
            'value_usd_amount': self.value_usd_amount,
            'theme_peer': self.theme_peer,
            'peer_color': self.peer_color,
            'host_id': self.host_id,
            'offer_min_stars': self.offer_min_stars,
            'craft_chance_permille': self.craft_chance_permille,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.require_premium:
            flags |= (1 << 6)
        if self.resale_ton_only:
            flags |= (1 << 7)
        if self.theme_available:
            flags |= (1 << 9)
        if self.burned:
            flags |= (1 << 14)
        if self.crafted:
            flags |= (1 << 15)
        if self.owner_id is not None:
            flags |= (1 << 0)
        if self.owner_name is not None:
            flags |= (1 << 1)
        if self.owner_address is not None:
            flags |= (1 << 2)
        if self.gift_address is not None:
            flags |= (1 << 3)
        if self.resell_amount is not None:
            flags |= (1 << 4)
        if self.released_by is not None:
            flags |= (1 << 5)
        if self.value_usd_amount is not None:
            flags |= (1 << 8)
        if self.theme_peer is not None:
            flags |= (1 << 10)
        if self.peer_color is not None:
            flags |= (1 << 11)
        if self.host_id is not None:
            flags |= (1 << 12)
        if self.offer_min_stars is not None:
            flags |= (1 << 13)
        if self.craft_chance_permille is not None:
            flags |= (1 << 16)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.gift_id))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.slug))
        buf.write(struct.pack('<i', self.num))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.attributes)))
        for item in self.attributes:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', self.availability_issued))
        buf.write(struct.pack('<i', self.availability_total))
        if self.owner_id is not None:
            buf.write(bytes(self.owner_id))
        if self.owner_name is not None:
            buf.write(TLObject.serialize_bytes(self.owner_name))
        if self.owner_address is not None:
            buf.write(TLObject.serialize_bytes(self.owner_address))
        if self.gift_address is not None:
            buf.write(TLObject.serialize_bytes(self.gift_address))
        if self.resell_amount is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.resell_amount)))
            for item in self.resell_amount:
                buf.write(bytes(self.item))
        if self.released_by is not None:
            buf.write(bytes(self.released_by))
        if self.value_amount is not None:
            buf.write(struct.pack('<q', self.value_amount))
        if self.value_currency is not None:
            buf.write(TLObject.serialize_bytes(self.value_currency))
        if self.value_usd_amount is not None:
            buf.write(struct.pack('<q', self.value_usd_amount))
        if self.theme_peer is not None:
            buf.write(bytes(self.theme_peer))
        if self.peer_color is not None:
            buf.write(bytes(self.peer_color))
        if self.host_id is not None:
            buf.write(bytes(self.host_id))
        if self.offer_min_stars is not None:
            buf.write(struct.pack('<i', self.offer_min_stars))
        if self.craft_chance_permille is not None:
            buf.write(struct.pack('<i', self.craft_chance_permille))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['require_premium'] = bool(flags & (1 << 6))
        _args['resale_ton_only'] = bool(flags & (1 << 7))
        _args['theme_available'] = bool(flags & (1 << 9))
        _args['burned'] = bool(flags & (1 << 14))
        _args['crafted'] = bool(flags & (1 << 15))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_gift_id = reader.read_long()
        _args['gift_id'] = _val_gift_id
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        _val_num = reader.read_int()
        _args['num'] = _val_num
        if flags & (1 << 0):
            _val_owner_id = reader.tgread_object()
            _args['owner_id'] = _val_owner_id
        else:
            _args['owner_id'] = None
        if flags & (1 << 1):
            _val_owner_name = reader.tgread_string()
            _args['owner_name'] = _val_owner_name
        else:
            _args['owner_name'] = None
        if flags & (1 << 2):
            _val_owner_address = reader.tgread_string()
            _args['owner_address'] = _val_owner_address
        else:
            _args['owner_address'] = None
        reader.read_int(signed=False)  # skip vector id
        _count_attributes = reader.read_int()
        _list_attributes = []
        for _ in range(_count_attributes):
            _item_attributes = reader.tgread_object()
            _list_attributes.append(_item_attributes)
        _args['attributes'] = _list_attributes
        _val_availability_issued = reader.read_int()
        _args['availability_issued'] = _val_availability_issued
        _val_availability_total = reader.read_int()
        _args['availability_total'] = _val_availability_total
        if flags & (1 << 3):
            _val_gift_address = reader.tgread_string()
            _args['gift_address'] = _val_gift_address
        else:
            _args['gift_address'] = None
        if flags & (1 << 4):
            reader.read_int(signed=False)  # skip vector id
            _count_resell_amount = reader.read_int()
            _list_resell_amount = []
            for _ in range(_count_resell_amount):
                _item_resell_amount = reader.tgread_object()
                _list_resell_amount.append(_item_resell_amount)
            _args['resell_amount'] = _list_resell_amount
        else:
            _args['resell_amount'] = None
        if flags & (1 << 5):
            _val_released_by = reader.tgread_object()
            _args['released_by'] = _val_released_by
        else:
            _args['released_by'] = None
        if flags & (1 << 8):
            _val_value_amount = reader.read_long()
            _args['value_amount'] = _val_value_amount
        else:
            _args['value_amount'] = None
        if flags & (1 << 8):
            _val_value_currency = reader.tgread_string()
            _args['value_currency'] = _val_value_currency
        else:
            _args['value_currency'] = None
        if flags & (1 << 8):
            _val_value_usd_amount = reader.read_long()
            _args['value_usd_amount'] = _val_value_usd_amount
        else:
            _args['value_usd_amount'] = None
        if flags & (1 << 10):
            _val_theme_peer = reader.tgread_object()
            _args['theme_peer'] = _val_theme_peer
        else:
            _args['theme_peer'] = None
        if flags & (1 << 11):
            _val_peer_color = reader.tgread_object()
            _args['peer_color'] = _val_peer_color
        else:
            _args['peer_color'] = None
        if flags & (1 << 12):
            _val_host_id = reader.tgread_object()
            _args['host_id'] = _val_host_id
        else:
            _args['host_id'] = None
        if flags & (1 << 13):
            _val_offer_min_stars = reader.read_int()
            _args['offer_min_stars'] = _val_offer_min_stars
        else:
            _args['offer_min_stars'] = None
        if flags & (1 << 16):
            _val_craft_chance_permille = reader.read_int()
            _args['craft_chance_permille'] = _val_craft_chance_permille
        else:
            _args['craft_chance_permille'] = None
        return cls(**_args)


class StarGiftUpgradePrice(TLObject):
    """TL type: starGiftUpgradePrice"""
    CONSTRUCTOR_ID = 0x99ea331d
    SUBCLASS_OF_ID = 0xf452f864

    def __init__(self, date: Optional[datetime], upgrade_stars: int):
        self.date = date
        self.upgrade_stars = upgrade_stars

    def to_dict(self):
        return {
            '_': 'StarGiftUpgradePrice',
            'date': self.date,
            'upgrade_stars': self.upgrade_stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.upgrade_stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_upgrade_stars = reader.read_long()
        _args['upgrade_stars'] = _val_upgrade_stars
        return cls(**_args)


class StarRefProgram(TLObject):
    """TL type: starRefProgram"""
    CONSTRUCTOR_ID = 0xdd0c66f2
    SUBCLASS_OF_ID = 0x9888e002

    def __init__(self, bot_id: int, commission_permille: int, duration_months: Optional[int] = None, end_date: Optional[datetime] = None, daily_revenue_per_user: Optional['TypeStarsAmount'] = None):
        self.bot_id = bot_id
        self.commission_permille = commission_permille
        self.duration_months = duration_months
        self.end_date = end_date
        self.daily_revenue_per_user = daily_revenue_per_user

    def to_dict(self):
        return {
            '_': 'StarRefProgram',
            'bot_id': self.bot_id,
            'commission_permille': self.commission_permille,
            'duration_months': self.duration_months,
            'end_date': self.end_date,
            'daily_revenue_per_user': self.daily_revenue_per_user,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.duration_months is not None:
            flags |= (1 << 0)
        if self.end_date is not None:
            flags |= (1 << 1)
        if self.daily_revenue_per_user is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.bot_id))
        buf.write(struct.pack('<i', self.commission_permille))
        if self.duration_months is not None:
            buf.write(struct.pack('<i', self.duration_months))
        if self.end_date is not None:
            buf.write(struct.pack('<i', self.end_date))
        if self.daily_revenue_per_user is not None:
            buf.write(bytes(self.daily_revenue_per_user))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_bot_id = reader.read_long()
        _args['bot_id'] = _val_bot_id
        _val_commission_permille = reader.read_int()
        _args['commission_permille'] = _val_commission_permille
        if flags & (1 << 0):
            _val_duration_months = reader.read_int()
            _args['duration_months'] = _val_duration_months
        else:
            _args['duration_months'] = None
        if flags & (1 << 1):
            _val_end_date = reader.read_int()
            _args['end_date'] = _val_end_date
        else:
            _args['end_date'] = None
        if flags & (1 << 2):
            _val_daily_revenue_per_user = reader.tgread_object()
            _args['daily_revenue_per_user'] = _val_daily_revenue_per_user
        else:
            _args['daily_revenue_per_user'] = None
        return cls(**_args)


class StarsAmount(TLObject):
    """TL type: starsAmount"""
    CONSTRUCTOR_ID = 0xbbb6b4a3
    SUBCLASS_OF_ID = 0x355b3240

    def __init__(self, amount: int, nanos: int):
        self.amount = amount
        self.nanos = nanos

    def to_dict(self):
        return {
            '_': 'StarsAmount',
            'amount': self.amount,
            'nanos': self.nanos,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.amount))
        buf.write(struct.pack('<i', self.nanos))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        _val_nanos = reader.read_int()
        _args['nanos'] = _val_nanos
        return cls(**_args)


class StarsGiftOption(TLObject):
    """TL type: starsGiftOption"""
    CONSTRUCTOR_ID = 0x5e0589f1
    SUBCLASS_OF_ID = 0xa9cd4bb7

    def __init__(self, stars: int, currency: str, amount: int, extended: Optional[bool] = None, store_product: Optional[str] = None):
        self.stars = stars
        self.currency = currency
        self.amount = amount
        self.extended = extended
        self.store_product = store_product

    def to_dict(self):
        return {
            '_': 'StarsGiftOption',
            'stars': self.stars,
            'currency': self.currency,
            'amount': self.amount,
            'extended': self.extended,
            'store_product': self.store_product,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.extended:
            flags |= (1 << 1)
        if self.store_product is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.stars))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        if self.store_product is not None:
            buf.write(TLObject.serialize_bytes(self.store_product))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['extended'] = bool(flags & (1 << 1))
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        if flags & (1 << 0):
            _val_store_product = reader.tgread_string()
            _args['store_product'] = _val_store_product
        else:
            _args['store_product'] = None
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        return cls(**_args)


class StarsGiveawayOption(TLObject):
    """TL type: starsGiveawayOption"""
    CONSTRUCTOR_ID = 0x94ce852a
    SUBCLASS_OF_ID = 0x3a28a20b

    def __init__(self, stars: int, yearly_boosts: int, currency: str, amount: int, winners: List['TypeStarsGiveawayWinnersOption'], extended: Optional[bool] = None, default: Optional[bool] = None, store_product: Optional[str] = None):
        self.stars = stars
        self.yearly_boosts = yearly_boosts
        self.currency = currency
        self.amount = amount
        self.winners = winners
        self.extended = extended
        self.default = default
        self.store_product = store_product

    def to_dict(self):
        return {
            '_': 'StarsGiveawayOption',
            'stars': self.stars,
            'yearly_boosts': self.yearly_boosts,
            'currency': self.currency,
            'amount': self.amount,
            'winners': self.winners,
            'extended': self.extended,
            'default': self.default,
            'store_product': self.store_product,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.extended:
            flags |= (1 << 0)
        if self.default:
            flags |= (1 << 1)
        if self.store_product is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.stars))
        buf.write(struct.pack('<i', self.yearly_boosts))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.winners)))
        for item in self.winners:
            buf.write(bytes(self.item))
        if self.store_product is not None:
            buf.write(TLObject.serialize_bytes(self.store_product))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['extended'] = bool(flags & (1 << 0))
        _args['default'] = bool(flags & (1 << 1))
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        _val_yearly_boosts = reader.read_int()
        _args['yearly_boosts'] = _val_yearly_boosts
        if flags & (1 << 2):
            _val_store_product = reader.tgread_string()
            _args['store_product'] = _val_store_product
        else:
            _args['store_product'] = None
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        reader.read_int(signed=False)  # skip vector id
        _count_winners = reader.read_int()
        _list_winners = []
        for _ in range(_count_winners):
            _item_winners = reader.tgread_object()
            _list_winners.append(_item_winners)
        _args['winners'] = _list_winners
        return cls(**_args)


class StarsGiveawayWinnersOption(TLObject):
    """TL type: starsGiveawayWinnersOption"""
    CONSTRUCTOR_ID = 0x54236209
    SUBCLASS_OF_ID = 0xfbfaa2e4

    def __init__(self, users: int, per_user_stars: int, default: Optional[bool] = None):
        self.users = users
        self.per_user_stars = per_user_stars
        self.default = default

    def to_dict(self):
        return {
            '_': 'StarsGiveawayWinnersOption',
            'users': self.users,
            'per_user_stars': self.per_user_stars,
            'default': self.default,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.default:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.users))
        buf.write(struct.pack('<q', self.per_user_stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['default'] = bool(flags & (1 << 0))
        _val_users = reader.read_int()
        _args['users'] = _val_users
        _val_per_user_stars = reader.read_long()
        _args['per_user_stars'] = _val_per_user_stars
        return cls(**_args)


class StarsRating(TLObject):
    """TL type: starsRating"""
    CONSTRUCTOR_ID = 0x1b0e4f07
    SUBCLASS_OF_ID = 0x63736420

    def __init__(self, level: int, current_level_stars: int, stars: int, next_level_stars: Optional[int] = None):
        self.level = level
        self.current_level_stars = current_level_stars
        self.stars = stars
        self.next_level_stars = next_level_stars

    def to_dict(self):
        return {
            '_': 'StarsRating',
            'level': self.level,
            'current_level_stars': self.current_level_stars,
            'stars': self.stars,
            'next_level_stars': self.next_level_stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.next_level_stars is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.level))
        buf.write(struct.pack('<q', self.current_level_stars))
        buf.write(struct.pack('<q', self.stars))
        if self.next_level_stars is not None:
            buf.write(struct.pack('<q', self.next_level_stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_level = reader.read_int()
        _args['level'] = _val_level
        _val_current_level_stars = reader.read_long()
        _args['current_level_stars'] = _val_current_level_stars
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        if flags & (1 << 0):
            _val_next_level_stars = reader.read_long()
            _args['next_level_stars'] = _val_next_level_stars
        else:
            _args['next_level_stars'] = None
        return cls(**_args)


class StarsRevenueStatus(TLObject):
    """TL type: starsRevenueStatus"""
    CONSTRUCTOR_ID = 0xfebe5491
    SUBCLASS_OF_ID = 0x3d7d9ff1

    def __init__(self, current_balance: 'TypeStarsAmount', available_balance: 'TypeStarsAmount', overall_revenue: 'TypeStarsAmount', withdrawal_enabled: Optional[bool] = None, next_withdrawal_at: Optional[int] = None):
        self.current_balance = current_balance
        self.available_balance = available_balance
        self.overall_revenue = overall_revenue
        self.withdrawal_enabled = withdrawal_enabled
        self.next_withdrawal_at = next_withdrawal_at

    def to_dict(self):
        return {
            '_': 'StarsRevenueStatus',
            'current_balance': self.current_balance,
            'available_balance': self.available_balance,
            'overall_revenue': self.overall_revenue,
            'withdrawal_enabled': self.withdrawal_enabled,
            'next_withdrawal_at': self.next_withdrawal_at,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.withdrawal_enabled:
            flags |= (1 << 0)
        if self.next_withdrawal_at is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.current_balance))
        buf.write(bytes(self.available_balance))
        buf.write(bytes(self.overall_revenue))
        if self.next_withdrawal_at is not None:
            buf.write(struct.pack('<i', self.next_withdrawal_at))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['withdrawal_enabled'] = bool(flags & (1 << 0))
        _val_current_balance = reader.tgread_object()
        _args['current_balance'] = _val_current_balance
        _val_available_balance = reader.tgread_object()
        _args['available_balance'] = _val_available_balance
        _val_overall_revenue = reader.tgread_object()
        _args['overall_revenue'] = _val_overall_revenue
        if flags & (1 << 1):
            _val_next_withdrawal_at = reader.read_int()
            _args['next_withdrawal_at'] = _val_next_withdrawal_at
        else:
            _args['next_withdrawal_at'] = None
        return cls(**_args)


class StarsSubscription(TLObject):
    """TL type: starsSubscription"""
    CONSTRUCTOR_ID = 0x2e6eab1a
    SUBCLASS_OF_ID = 0xeced29c3

    def __init__(self, id: str, peer: 'TypePeer', until_date: Optional[datetime], pricing: 'TypeStarsSubscriptionPricing', canceled: Optional[bool] = None, can_refulfill: Optional[bool] = None, missing_balance: Optional[bool] = None, bot_canceled: Optional[bool] = None, chat_invite_hash: Optional[str] = None, title: Optional[str] = None, photo: Optional['TypeWebDocument'] = None, invoice_slug: Optional[str] = None):
        self.id = id
        self.peer = peer
        self.until_date = until_date
        self.pricing = pricing
        self.canceled = canceled
        self.can_refulfill = can_refulfill
        self.missing_balance = missing_balance
        self.bot_canceled = bot_canceled
        self.chat_invite_hash = chat_invite_hash
        self.title = title
        self.photo = photo
        self.invoice_slug = invoice_slug

    def to_dict(self):
        return {
            '_': 'StarsSubscription',
            'id': self.id,
            'peer': self.peer,
            'until_date': self.until_date,
            'pricing': self.pricing,
            'canceled': self.canceled,
            'can_refulfill': self.can_refulfill,
            'missing_balance': self.missing_balance,
            'bot_canceled': self.bot_canceled,
            'chat_invite_hash': self.chat_invite_hash,
            'title': self.title,
            'photo': self.photo,
            'invoice_slug': self.invoice_slug,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.canceled:
            flags |= (1 << 0)
        if self.can_refulfill:
            flags |= (1 << 1)
        if self.missing_balance:
            flags |= (1 << 2)
        if self.bot_canceled:
            flags |= (1 << 7)
        if self.chat_invite_hash is not None:
            flags |= (1 << 3)
        if self.title is not None:
            flags |= (1 << 4)
        if self.photo is not None:
            flags |= (1 << 5)
        if self.invoice_slug is not None:
            flags |= (1 << 6)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.until_date))
        buf.write(bytes(self.pricing))
        if self.chat_invite_hash is not None:
            buf.write(TLObject.serialize_bytes(self.chat_invite_hash))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        if self.invoice_slug is not None:
            buf.write(TLObject.serialize_bytes(self.invoice_slug))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['canceled'] = bool(flags & (1 << 0))
        _args['can_refulfill'] = bool(flags & (1 << 1))
        _args['missing_balance'] = bool(flags & (1 << 2))
        _args['bot_canceled'] = bool(flags & (1 << 7))
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_until_date = reader.read_int()
        _args['until_date'] = _val_until_date
        _val_pricing = reader.tgread_object()
        _args['pricing'] = _val_pricing
        if flags & (1 << 3):
            _val_chat_invite_hash = reader.tgread_string()
            _args['chat_invite_hash'] = _val_chat_invite_hash
        else:
            _args['chat_invite_hash'] = None
        if flags & (1 << 4):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 5):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        if flags & (1 << 6):
            _val_invoice_slug = reader.tgread_string()
            _args['invoice_slug'] = _val_invoice_slug
        else:
            _args['invoice_slug'] = None
        return cls(**_args)


class StarsSubscriptionPricing(TLObject):
    """TL type: starsSubscriptionPricing"""
    CONSTRUCTOR_ID = 0x05416d58
    SUBCLASS_OF_ID = 0xbbf7b9a9

    def __init__(self, period: int, amount: int):
        self.period = period
        self.amount = amount

    def to_dict(self):
        return {
            '_': 'StarsSubscriptionPricing',
            'period': self.period,
            'amount': self.amount,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.period))
        buf.write(struct.pack('<q', self.amount))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_period = reader.read_int()
        _args['period'] = _val_period
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        return cls(**_args)


class StarsTonAmount(TLObject):
    """TL type: starsTonAmount"""
    CONSTRUCTOR_ID = 0x74aee3e0
    SUBCLASS_OF_ID = 0x355b3240

    def __init__(self, amount: int):
        self.amount = amount

    def to_dict(self):
        return {
            '_': 'StarsTonAmount',
            'amount': self.amount,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.amount))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        return cls(**_args)


class StarsTopupOption(TLObject):
    """TL type: starsTopupOption"""
    CONSTRUCTOR_ID = 0x0bd915c0
    SUBCLASS_OF_ID = 0xe5bca5ec

    def __init__(self, stars: int, currency: str, amount: int, extended: Optional[bool] = None, store_product: Optional[str] = None):
        self.stars = stars
        self.currency = currency
        self.amount = amount
        self.extended = extended
        self.store_product = store_product

    def to_dict(self):
        return {
            '_': 'StarsTopupOption',
            'stars': self.stars,
            'currency': self.currency,
            'amount': self.amount,
            'extended': self.extended,
            'store_product': self.store_product,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.extended:
            flags |= (1 << 1)
        if self.store_product is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.stars))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.amount))
        if self.store_product is not None:
            buf.write(TLObject.serialize_bytes(self.store_product))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['extended'] = bool(flags & (1 << 1))
        _val_stars = reader.read_long()
        _args['stars'] = _val_stars
        if flags & (1 << 0):
            _val_store_product = reader.tgread_string()
            _args['store_product'] = _val_store_product
        else:
            _args['store_product'] = None
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_amount = reader.read_long()
        _args['amount'] = _val_amount
        return cls(**_args)


class StarsTransaction(TLObject):
    """TL type: starsTransaction"""
    CONSTRUCTOR_ID = 0x13659eb0
    SUBCLASS_OF_ID = 0x86884772

    def __init__(self, id: str, amount: 'TypeStarsAmount', date: Optional[datetime], peer: 'TypeStarsTransactionPeer', refund: Optional[bool] = None, pending: Optional[bool] = None, failed: Optional[bool] = None, gift: Optional[bool] = None, reaction: Optional[bool] = None, stargift_upgrade: Optional[bool] = None, business_transfer: Optional[bool] = None, stargift_resale: Optional[bool] = None, posts_search: Optional[bool] = None, stargift_prepaid_upgrade: Optional[bool] = None, stargift_drop_original_details: Optional[bool] = None, phonegroup_message: Optional[bool] = None, stargift_auction_bid: Optional[bool] = None, offer: Optional[bool] = None, title: Optional[str] = None, description: Optional[str] = None, photo: Optional['TypeWebDocument'] = None, transaction_date: Optional[datetime] = None, transaction_url: Optional[str] = None, bot_payload: Optional[bytes] = None, msg_id: Optional[int] = None, extended_media: Optional[List['TypeMessageMedia']] = None, subscription_period: Optional[int] = None, giveaway_post_id: Optional[int] = None, stargift: Optional['TypeStarGift'] = None, floodskip_number: Optional[int] = None, starref_commission_permille: Optional[int] = None, starref_peer: Optional['TypePeer'] = None, starref_amount: Optional['TypeStarsAmount'] = None, paid_messages: Optional[int] = None, premium_gift_months: Optional[int] = None, ads_proceeds_from_date: Optional[datetime] = None, ads_proceeds_to_date: Optional[datetime] = None):
        self.id = id
        self.amount = amount
        self.date = date
        self.peer = peer
        self.refund = refund
        self.pending = pending
        self.failed = failed
        self.gift = gift
        self.reaction = reaction
        self.stargift_upgrade = stargift_upgrade
        self.business_transfer = business_transfer
        self.stargift_resale = stargift_resale
        self.posts_search = posts_search
        self.stargift_prepaid_upgrade = stargift_prepaid_upgrade
        self.stargift_drop_original_details = stargift_drop_original_details
        self.phonegroup_message = phonegroup_message
        self.stargift_auction_bid = stargift_auction_bid
        self.offer = offer
        self.title = title
        self.description = description
        self.photo = photo
        self.transaction_date = transaction_date
        self.transaction_url = transaction_url
        self.bot_payload = bot_payload
        self.msg_id = msg_id
        self.extended_media = extended_media
        self.subscription_period = subscription_period
        self.giveaway_post_id = giveaway_post_id
        self.stargift = stargift
        self.floodskip_number = floodskip_number
        self.starref_commission_permille = starref_commission_permille
        self.starref_peer = starref_peer
        self.starref_amount = starref_amount
        self.paid_messages = paid_messages
        self.premium_gift_months = premium_gift_months
        self.ads_proceeds_from_date = ads_proceeds_from_date
        self.ads_proceeds_to_date = ads_proceeds_to_date

    def to_dict(self):
        return {
            '_': 'StarsTransaction',
            'id': self.id,
            'amount': self.amount,
            'date': self.date,
            'peer': self.peer,
            'refund': self.refund,
            'pending': self.pending,
            'failed': self.failed,
            'gift': self.gift,
            'reaction': self.reaction,
            'stargift_upgrade': self.stargift_upgrade,
            'business_transfer': self.business_transfer,
            'stargift_resale': self.stargift_resale,
            'posts_search': self.posts_search,
            'stargift_prepaid_upgrade': self.stargift_prepaid_upgrade,
            'stargift_drop_original_details': self.stargift_drop_original_details,
            'phonegroup_message': self.phonegroup_message,
            'stargift_auction_bid': self.stargift_auction_bid,
            'offer': self.offer,
            'title': self.title,
            'description': self.description,
            'photo': self.photo,
            'transaction_date': self.transaction_date,
            'transaction_url': self.transaction_url,
            'bot_payload': self.bot_payload,
            'msg_id': self.msg_id,
            'extended_media': self.extended_media,
            'subscription_period': self.subscription_period,
            'giveaway_post_id': self.giveaway_post_id,
            'stargift': self.stargift,
            'floodskip_number': self.floodskip_number,
            'starref_commission_permille': self.starref_commission_permille,
            'starref_peer': self.starref_peer,
            'starref_amount': self.starref_amount,
            'paid_messages': self.paid_messages,
            'premium_gift_months': self.premium_gift_months,
            'ads_proceeds_from_date': self.ads_proceeds_from_date,
            'ads_proceeds_to_date': self.ads_proceeds_to_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.refund:
            flags |= (1 << 3)
        if self.pending:
            flags |= (1 << 4)
        if self.failed:
            flags |= (1 << 6)
        if self.gift:
            flags |= (1 << 10)
        if self.reaction:
            flags |= (1 << 11)
        if self.stargift_upgrade:
            flags |= (1 << 18)
        if self.business_transfer:
            flags |= (1 << 21)
        if self.stargift_resale:
            flags |= (1 << 22)
        if self.posts_search:
            flags |= (1 << 24)
        if self.stargift_prepaid_upgrade:
            flags |= (1 << 25)
        if self.stargift_drop_original_details:
            flags |= (1 << 26)
        if self.phonegroup_message:
            flags |= (1 << 27)
        if self.stargift_auction_bid:
            flags |= (1 << 28)
        if self.offer:
            flags |= (1 << 29)
        if self.title is not None:
            flags |= (1 << 0)
        if self.description is not None:
            flags |= (1 << 1)
        if self.photo is not None:
            flags |= (1 << 2)
        if self.transaction_url is not None:
            flags |= (1 << 5)
        if self.bot_payload is not None:
            flags |= (1 << 7)
        if self.msg_id is not None:
            flags |= (1 << 8)
        if self.extended_media is not None:
            flags |= (1 << 9)
        if self.subscription_period is not None:
            flags |= (1 << 12)
        if self.giveaway_post_id is not None:
            flags |= (1 << 13)
        if self.stargift is not None:
            flags |= (1 << 14)
        if self.floodskip_number is not None:
            flags |= (1 << 15)
        if self.starref_commission_permille is not None:
            flags |= (1 << 16)
        if self.starref_amount is not None:
            flags |= (1 << 17)
        if self.paid_messages is not None:
            flags |= (1 << 19)
        if self.premium_gift_months is not None:
            flags |= (1 << 20)
        if self.ads_proceeds_to_date is not None:
            flags |= (1 << 23)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(bytes(self.amount))
        buf.write(struct.pack('<i', self.date))
        buf.write(bytes(self.peer))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.description is not None:
            buf.write(TLObject.serialize_bytes(self.description))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        if self.transaction_date is not None:
            buf.write(struct.pack('<i', self.transaction_date))
        if self.transaction_url is not None:
            buf.write(TLObject.serialize_bytes(self.transaction_url))
        if self.bot_payload is not None:
            buf.write(TLObject.serialize_bytes(self.bot_payload))
        if self.msg_id is not None:
            buf.write(struct.pack('<i', self.msg_id))
        if self.extended_media is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.extended_media)))
            for item in self.extended_media:
                buf.write(bytes(self.item))
        if self.subscription_period is not None:
            buf.write(struct.pack('<i', self.subscription_period))
        if self.giveaway_post_id is not None:
            buf.write(struct.pack('<i', self.giveaway_post_id))
        if self.stargift is not None:
            buf.write(bytes(self.stargift))
        if self.floodskip_number is not None:
            buf.write(struct.pack('<i', self.floodskip_number))
        if self.starref_commission_permille is not None:
            buf.write(struct.pack('<i', self.starref_commission_permille))
        if self.starref_peer is not None:
            buf.write(bytes(self.starref_peer))
        if self.starref_amount is not None:
            buf.write(bytes(self.starref_amount))
        if self.paid_messages is not None:
            buf.write(struct.pack('<i', self.paid_messages))
        if self.premium_gift_months is not None:
            buf.write(struct.pack('<i', self.premium_gift_months))
        if self.ads_proceeds_from_date is not None:
            buf.write(struct.pack('<i', self.ads_proceeds_from_date))
        if self.ads_proceeds_to_date is not None:
            buf.write(struct.pack('<i', self.ads_proceeds_to_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['refund'] = bool(flags & (1 << 3))
        _args['pending'] = bool(flags & (1 << 4))
        _args['failed'] = bool(flags & (1 << 6))
        _args['gift'] = bool(flags & (1 << 10))
        _args['reaction'] = bool(flags & (1 << 11))
        _args['stargift_upgrade'] = bool(flags & (1 << 18))
        _args['business_transfer'] = bool(flags & (1 << 21))
        _args['stargift_resale'] = bool(flags & (1 << 22))
        _args['posts_search'] = bool(flags & (1 << 24))
        _args['stargift_prepaid_upgrade'] = bool(flags & (1 << 25))
        _args['stargift_drop_original_details'] = bool(flags & (1 << 26))
        _args['phonegroup_message'] = bool(flags & (1 << 27))
        _args['stargift_auction_bid'] = bool(flags & (1 << 28))
        _args['offer'] = bool(flags & (1 << 29))
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_amount = reader.tgread_object()
        _args['amount'] = _val_amount
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 1):
            _val_description = reader.tgread_string()
            _args['description'] = _val_description
        else:
            _args['description'] = None
        if flags & (1 << 2):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        if flags & (1 << 5):
            _val_transaction_date = reader.read_int()
            _args['transaction_date'] = _val_transaction_date
        else:
            _args['transaction_date'] = None
        if flags & (1 << 5):
            _val_transaction_url = reader.tgread_string()
            _args['transaction_url'] = _val_transaction_url
        else:
            _args['transaction_url'] = None
        if flags & (1 << 7):
            _val_bot_payload = reader.tgread_bytes()
            _args['bot_payload'] = _val_bot_payload
        else:
            _args['bot_payload'] = None
        if flags & (1 << 8):
            _val_msg_id = reader.read_int()
            _args['msg_id'] = _val_msg_id
        else:
            _args['msg_id'] = None
        if flags & (1 << 9):
            reader.read_int(signed=False)  # skip vector id
            _count_extended_media = reader.read_int()
            _list_extended_media = []
            for _ in range(_count_extended_media):
                _item_extended_media = reader.tgread_object()
                _list_extended_media.append(_item_extended_media)
            _args['extended_media'] = _list_extended_media
        else:
            _args['extended_media'] = None
        if flags & (1 << 12):
            _val_subscription_period = reader.read_int()
            _args['subscription_period'] = _val_subscription_period
        else:
            _args['subscription_period'] = None
        if flags & (1 << 13):
            _val_giveaway_post_id = reader.read_int()
            _args['giveaway_post_id'] = _val_giveaway_post_id
        else:
            _args['giveaway_post_id'] = None
        if flags & (1 << 14):
            _val_stargift = reader.tgread_object()
            _args['stargift'] = _val_stargift
        else:
            _args['stargift'] = None
        if flags & (1 << 15):
            _val_floodskip_number = reader.read_int()
            _args['floodskip_number'] = _val_floodskip_number
        else:
            _args['floodskip_number'] = None
        if flags & (1 << 16):
            _val_starref_commission_permille = reader.read_int()
            _args['starref_commission_permille'] = _val_starref_commission_permille
        else:
            _args['starref_commission_permille'] = None
        if flags & (1 << 17):
            _val_starref_peer = reader.tgread_object()
            _args['starref_peer'] = _val_starref_peer
        else:
            _args['starref_peer'] = None
        if flags & (1 << 17):
            _val_starref_amount = reader.tgread_object()
            _args['starref_amount'] = _val_starref_amount
        else:
            _args['starref_amount'] = None
        if flags & (1 << 19):
            _val_paid_messages = reader.read_int()
            _args['paid_messages'] = _val_paid_messages
        else:
            _args['paid_messages'] = None
        if flags & (1 << 20):
            _val_premium_gift_months = reader.read_int()
            _args['premium_gift_months'] = _val_premium_gift_months
        else:
            _args['premium_gift_months'] = None
        if flags & (1 << 23):
            _val_ads_proceeds_from_date = reader.read_int()
            _args['ads_proceeds_from_date'] = _val_ads_proceeds_from_date
        else:
            _args['ads_proceeds_from_date'] = None
        if flags & (1 << 23):
            _val_ads_proceeds_to_date = reader.read_int()
            _args['ads_proceeds_to_date'] = _val_ads_proceeds_to_date
        else:
            _args['ads_proceeds_to_date'] = None
        return cls(**_args)


class StarsTransactionPeer(TLObject):
    """TL type: starsTransactionPeer"""
    CONSTRUCTOR_ID = 0xd80da15d
    SUBCLASS_OF_ID = 0x41b69183

    def __init__(self, peer: 'TypePeer'):
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'StarsTransactionPeer',
            'peer': self.peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class StarsTransactionPeerApi(TLObject):
    """TL type: starsTransactionPeerAPI"""
    CONSTRUCTOR_ID = 0xf9677aad
    SUBCLASS_OF_ID = 0x41b69183

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarsTransactionPeerApi',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StarsTransactionPeerAds(TLObject):
    """TL type: starsTransactionPeerAds"""
    CONSTRUCTOR_ID = 0x60682812
    SUBCLASS_OF_ID = 0x41b69183

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarsTransactionPeerAds',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StarsTransactionPeerAppStore(TLObject):
    """TL type: starsTransactionPeerAppStore"""
    CONSTRUCTOR_ID = 0xb457b375
    SUBCLASS_OF_ID = 0x41b69183

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarsTransactionPeerAppStore',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StarsTransactionPeerFragment(TLObject):
    """TL type: starsTransactionPeerFragment"""
    CONSTRUCTOR_ID = 0xe92fd902
    SUBCLASS_OF_ID = 0x41b69183

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarsTransactionPeerFragment',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StarsTransactionPeerPlayMarket(TLObject):
    """TL type: starsTransactionPeerPlayMarket"""
    CONSTRUCTOR_ID = 0x7b560a0b
    SUBCLASS_OF_ID = 0x41b69183

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarsTransactionPeerPlayMarket',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StarsTransactionPeerPremiumBot(TLObject):
    """TL type: starsTransactionPeerPremiumBot"""
    CONSTRUCTOR_ID = 0x250dbaf8
    SUBCLASS_OF_ID = 0x41b69183

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarsTransactionPeerPremiumBot',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StarsTransactionPeerUnsupported(TLObject):
    """TL type: starsTransactionPeerUnsupported"""
    CONSTRUCTOR_ID = 0x95f2bfe4
    SUBCLASS_OF_ID = 0x41b69183

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'StarsTransactionPeerUnsupported',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class StatsAbsValueAndPrev(TLObject):
    """TL type: statsAbsValueAndPrev"""
    CONSTRUCTOR_ID = 0xcb43acde
    SUBCLASS_OF_ID = 0x3ebe59af

    def __init__(self, current: float, previous: float):
        self.current = current
        self.previous = previous

    def to_dict(self):
        return {
            '_': 'StatsAbsValueAndPrev',
            'current': self.current,
            'previous': self.previous,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<d', self.current))
        buf.write(struct.pack('<d', self.previous))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_current = reader.read_double()
        _args['current'] = _val_current
        _val_previous = reader.read_double()
        _args['previous'] = _val_previous
        return cls(**_args)


class StatsDateRangeDays(TLObject):
    """TL type: statsDateRangeDays"""
    CONSTRUCTOR_ID = 0xb637edaf
    SUBCLASS_OF_ID = 0x81236245

    def __init__(self, min_date: Optional[datetime], max_date: Optional[datetime]):
        self.min_date = min_date
        self.max_date = max_date

    def to_dict(self):
        return {
            '_': 'StatsDateRangeDays',
            'min_date': self.min_date,
            'max_date': self.max_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.min_date))
        buf.write(struct.pack('<i', self.max_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_min_date = reader.read_int()
        _args['min_date'] = _val_min_date
        _val_max_date = reader.read_int()
        _args['max_date'] = _val_max_date
        return cls(**_args)


class StatsGraph(TLObject):
    """TL type: statsGraph"""
    CONSTRUCTOR_ID = 0x8ea464b6
    SUBCLASS_OF_ID = 0x9b903153

    def __init__(self, json: 'TypeDataJSON', zoom_token: Optional[str] = None):
        self.json = json
        self.zoom_token = zoom_token

    def to_dict(self):
        return {
            '_': 'StatsGraph',
            'json': self.json,
            'zoom_token': self.zoom_token,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.zoom_token is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.json))
        if self.zoom_token is not None:
            buf.write(TLObject.serialize_bytes(self.zoom_token))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_json = reader.tgread_object()
        _args['json'] = _val_json
        if flags & (1 << 0):
            _val_zoom_token = reader.tgread_string()
            _args['zoom_token'] = _val_zoom_token
        else:
            _args['zoom_token'] = None
        return cls(**_args)


class StatsGraphAsync(TLObject):
    """TL type: statsGraphAsync"""
    CONSTRUCTOR_ID = 0x4a27eb2d
    SUBCLASS_OF_ID = 0x9b903153

    def __init__(self, token: str):
        self.token = token

    def to_dict(self):
        return {
            '_': 'StatsGraphAsync',
            'token': self.token,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.token))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_token = reader.tgread_string()
        _args['token'] = _val_token
        return cls(**_args)


class StatsGraphError(TLObject):
    """TL type: statsGraphError"""
    CONSTRUCTOR_ID = 0xbedc9822
    SUBCLASS_OF_ID = 0x9b903153

    def __init__(self, error: str):
        self.error = error

    def to_dict(self):
        return {
            '_': 'StatsGraphError',
            'error': self.error,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.error))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_error = reader.tgread_string()
        _args['error'] = _val_error
        return cls(**_args)


class StatsGroupTopAdmin(TLObject):
    """TL type: statsGroupTopAdmin"""
    CONSTRUCTOR_ID = 0xd7584c87
    SUBCLASS_OF_ID = 0x80359c5d

    def __init__(self, user_id: int, deleted: int, kicked: int, banned: int):
        self.user_id = user_id
        self.deleted = deleted
        self.kicked = kicked
        self.banned = banned

    def to_dict(self):
        return {
            '_': 'StatsGroupTopAdmin',
            'user_id': self.user_id,
            'deleted': self.deleted,
            'kicked': self.kicked,
            'banned': self.banned,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.deleted))
        buf.write(struct.pack('<i', self.kicked))
        buf.write(struct.pack('<i', self.banned))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_deleted = reader.read_int()
        _args['deleted'] = _val_deleted
        _val_kicked = reader.read_int()
        _args['kicked'] = _val_kicked
        _val_banned = reader.read_int()
        _args['banned'] = _val_banned
        return cls(**_args)


class StatsGroupTopInviter(TLObject):
    """TL type: statsGroupTopInviter"""
    CONSTRUCTOR_ID = 0x535f779d
    SUBCLASS_OF_ID = 0x85010c7a

    def __init__(self, user_id: int, invitations: int):
        self.user_id = user_id
        self.invitations = invitations

    def to_dict(self):
        return {
            '_': 'StatsGroupTopInviter',
            'user_id': self.user_id,
            'invitations': self.invitations,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.invitations))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_invitations = reader.read_int()
        _args['invitations'] = _val_invitations
        return cls(**_args)


class StatsGroupTopPoster(TLObject):
    """TL type: statsGroupTopPoster"""
    CONSTRUCTOR_ID = 0x9d04af9b
    SUBCLASS_OF_ID = 0x81c5ce23

    def __init__(self, user_id: int, messages: int, avg_chars: int):
        self.user_id = user_id
        self.messages = messages
        self.avg_chars = avg_chars

    def to_dict(self):
        return {
            '_': 'StatsGroupTopPoster',
            'user_id': self.user_id,
            'messages': self.messages,
            'avg_chars': self.avg_chars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.messages))
        buf.write(struct.pack('<i', self.avg_chars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_messages = reader.read_int()
        _args['messages'] = _val_messages
        _val_avg_chars = reader.read_int()
        _args['avg_chars'] = _val_avg_chars
        return cls(**_args)


class StatsPercentValue(TLObject):
    """TL type: statsPercentValue"""
    CONSTRUCTOR_ID = 0xcbce2fe0
    SUBCLASS_OF_ID = 0x9702c51e

    def __init__(self, part: float, total: float):
        self.part = part
        self.total = total

    def to_dict(self):
        return {
            '_': 'StatsPercentValue',
            'part': self.part,
            'total': self.total,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<d', self.part))
        buf.write(struct.pack('<d', self.total))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_part = reader.read_double()
        _args['part'] = _val_part
        _val_total = reader.read_double()
        _args['total'] = _val_total
        return cls(**_args)


class StatsUrl(TLObject):
    """TL type: statsURL"""
    CONSTRUCTOR_ID = 0x47a971e0
    SUBCLASS_OF_ID = 0x8d4c94c0

    def __init__(self, url: str):
        self.url = url

    def to_dict(self):
        return {
            '_': 'StatsUrl',
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class StickerKeyword(TLObject):
    """TL type: stickerKeyword"""
    CONSTRUCTOR_ID = 0xfcfeb29c
    SUBCLASS_OF_ID = 0x55951d6b

    def __init__(self, document_id: int, keyword: List[str]):
        self.document_id = document_id
        self.keyword = keyword

    def to_dict(self):
        return {
            '_': 'StickerKeyword',
            'document_id': self.document_id,
            'keyword': self.keyword,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.document_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.keyword)))
        for item in self.keyword:
            buf.write(TLObject.serialize_bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_document_id = reader.read_long()
        _args['document_id'] = _val_document_id
        reader.read_int(signed=False)  # skip vector id
        _count_keyword = reader.read_int()
        _list_keyword = []
        for _ in range(_count_keyword):
            _item_keyword = reader.tgread_string()
            _list_keyword.append(_item_keyword)
        _args['keyword'] = _list_keyword
        return cls(**_args)


class StickerPack(TLObject):
    """TL type: stickerPack"""
    CONSTRUCTOR_ID = 0x12b299d4
    SUBCLASS_OF_ID = 0x9fefa4d4

    def __init__(self, emoticon: str, documents: List[int]):
        self.emoticon = emoticon
        self.documents = documents

    def to_dict(self):
        return {
            '_': 'StickerPack',
            'emoticon': self.emoticon,
            'documents': self.documents,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.emoticon))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.documents)))
        for item in self.documents:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        reader.read_int(signed=False)  # skip vector id
        _count_documents = reader.read_int()
        _list_documents = []
        for _ in range(_count_documents):
            _item_documents = reader.read_long()
            _list_documents.append(_item_documents)
        _args['documents'] = _list_documents
        return cls(**_args)


class StickerSet(TLObject):
    """TL type: stickerSet"""
    CONSTRUCTOR_ID = 0x2dd14edc
    SUBCLASS_OF_ID = 0xbad3ff91

    def __init__(self, id: int, access_hash: int, title: str, short_name: str, count: int, hash: int, archived: Optional[bool] = None, official: Optional[bool] = None, masks: Optional[bool] = None, emojis: Optional[bool] = None, text_color: Optional[bool] = None, channel_emoji_status: Optional[bool] = None, creator: Optional[bool] = None, installed_date: Optional[datetime] = None, thumbs: Optional[List['TypePhotoSize']] = None, thumb_dc_id: Optional[int] = None, thumb_version: Optional[int] = None, thumb_document_id: Optional[int] = None):
        self.id = id
        self.access_hash = access_hash
        self.title = title
        self.short_name = short_name
        self.count = count
        self.hash = hash
        self.archived = archived
        self.official = official
        self.masks = masks
        self.emojis = emojis
        self.text_color = text_color
        self.channel_emoji_status = channel_emoji_status
        self.creator = creator
        self.installed_date = installed_date
        self.thumbs = thumbs
        self.thumb_dc_id = thumb_dc_id
        self.thumb_version = thumb_version
        self.thumb_document_id = thumb_document_id

    def to_dict(self):
        return {
            '_': 'StickerSet',
            'id': self.id,
            'access_hash': self.access_hash,
            'title': self.title,
            'short_name': self.short_name,
            'count': self.count,
            'hash': self.hash,
            'archived': self.archived,
            'official': self.official,
            'masks': self.masks,
            'emojis': self.emojis,
            'text_color': self.text_color,
            'channel_emoji_status': self.channel_emoji_status,
            'creator': self.creator,
            'installed_date': self.installed_date,
            'thumbs': self.thumbs,
            'thumb_dc_id': self.thumb_dc_id,
            'thumb_version': self.thumb_version,
            'thumb_document_id': self.thumb_document_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.archived:
            flags |= (1 << 1)
        if self.official:
            flags |= (1 << 2)
        if self.masks:
            flags |= (1 << 3)
        if self.emojis:
            flags |= (1 << 7)
        if self.text_color:
            flags |= (1 << 9)
        if self.channel_emoji_status:
            flags |= (1 << 10)
        if self.creator:
            flags |= (1 << 11)
        if self.installed_date is not None:
            flags |= (1 << 0)
        if self.thumb_version is not None:
            flags |= (1 << 4)
        if self.thumb_document_id is not None:
            flags |= (1 << 8)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.short_name))
        buf.write(struct.pack('<i', self.count))
        buf.write(struct.pack('<i', self.hash))
        if self.installed_date is not None:
            buf.write(struct.pack('<i', self.installed_date))
        if self.thumbs is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.thumbs)))
            for item in self.thumbs:
                buf.write(bytes(self.item))
        if self.thumb_dc_id is not None:
            buf.write(struct.pack('<i', self.thumb_dc_id))
        if self.thumb_version is not None:
            buf.write(struct.pack('<i', self.thumb_version))
        if self.thumb_document_id is not None:
            buf.write(struct.pack('<q', self.thumb_document_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['archived'] = bool(flags & (1 << 1))
        _args['official'] = bool(flags & (1 << 2))
        _args['masks'] = bool(flags & (1 << 3))
        _args['emojis'] = bool(flags & (1 << 7))
        _args['text_color'] = bool(flags & (1 << 9))
        _args['channel_emoji_status'] = bool(flags & (1 << 10))
        _args['creator'] = bool(flags & (1 << 11))
        if flags & (1 << 0):
            _val_installed_date = reader.read_int()
            _args['installed_date'] = _val_installed_date
        else:
            _args['installed_date'] = None
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_short_name = reader.tgread_string()
        _args['short_name'] = _val_short_name
        if flags & (1 << 4):
            reader.read_int(signed=False)  # skip vector id
            _count_thumbs = reader.read_int()
            _list_thumbs = []
            for _ in range(_count_thumbs):
                _item_thumbs = reader.tgread_object()
                _list_thumbs.append(_item_thumbs)
            _args['thumbs'] = _list_thumbs
        else:
            _args['thumbs'] = None
        if flags & (1 << 4):
            _val_thumb_dc_id = reader.read_int()
            _args['thumb_dc_id'] = _val_thumb_dc_id
        else:
            _args['thumb_dc_id'] = None
        if flags & (1 << 4):
            _val_thumb_version = reader.read_int()
            _args['thumb_version'] = _val_thumb_version
        else:
            _args['thumb_version'] = None
        if flags & (1 << 8):
            _val_thumb_document_id = reader.read_long()
            _args['thumb_document_id'] = _val_thumb_document_id
        else:
            _args['thumb_document_id'] = None
        _val_count = reader.read_int()
        _args['count'] = _val_count
        _val_hash = reader.read_int()
        _args['hash'] = _val_hash
        return cls(**_args)


class StickerSetCovered(TLObject):
    """TL type: stickerSetCovered"""
    CONSTRUCTOR_ID = 0x6410a5d2
    SUBCLASS_OF_ID = 0x7f86e4e5

    def __init__(self, set: 'TypeStickerSet', cover: 'TypeDocument'):
        self.set = set
        self.cover = cover

    def to_dict(self):
        return {
            '_': 'StickerSetCovered',
            'set': self.set,
            'cover': self.cover,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.set))
        buf.write(bytes(self.cover))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_set = reader.tgread_object()
        _args['set'] = _val_set
        _val_cover = reader.tgread_object()
        _args['cover'] = _val_cover
        return cls(**_args)


class StickerSetFullCovered(TLObject):
    """TL type: stickerSetFullCovered"""
    CONSTRUCTOR_ID = 0x40d13c0e
    SUBCLASS_OF_ID = 0x7f86e4e5

    def __init__(self, set: 'TypeStickerSet', packs: List['TypeStickerPack'], keywords: List['TypeStickerKeyword'], documents: List['TypeDocument']):
        self.set = set
        self.packs = packs
        self.keywords = keywords
        self.documents = documents

    def to_dict(self):
        return {
            '_': 'StickerSetFullCovered',
            'set': self.set,
            'packs': self.packs,
            'keywords': self.keywords,
            'documents': self.documents,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.set))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.packs)))
        for item in self.packs:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.keywords)))
        for item in self.keywords:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.documents)))
        for item in self.documents:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_set = reader.tgread_object()
        _args['set'] = _val_set
        reader.read_int(signed=False)  # skip vector id
        _count_packs = reader.read_int()
        _list_packs = []
        for _ in range(_count_packs):
            _item_packs = reader.tgread_object()
            _list_packs.append(_item_packs)
        _args['packs'] = _list_packs
        reader.read_int(signed=False)  # skip vector id
        _count_keywords = reader.read_int()
        _list_keywords = []
        for _ in range(_count_keywords):
            _item_keywords = reader.tgread_object()
            _list_keywords.append(_item_keywords)
        _args['keywords'] = _list_keywords
        reader.read_int(signed=False)  # skip vector id
        _count_documents = reader.read_int()
        _list_documents = []
        for _ in range(_count_documents):
            _item_documents = reader.tgread_object()
            _list_documents.append(_item_documents)
        _args['documents'] = _list_documents
        return cls(**_args)


class StickerSetMultiCovered(TLObject):
    """TL type: stickerSetMultiCovered"""
    CONSTRUCTOR_ID = 0x3407e51b
    SUBCLASS_OF_ID = 0x7f86e4e5

    def __init__(self, set: 'TypeStickerSet', covers: List['TypeDocument']):
        self.set = set
        self.covers = covers

    def to_dict(self):
        return {
            '_': 'StickerSetMultiCovered',
            'set': self.set,
            'covers': self.covers,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.set))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.covers)))
        for item in self.covers:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_set = reader.tgread_object()
        _args['set'] = _val_set
        reader.read_int(signed=False)  # skip vector id
        _count_covers = reader.read_int()
        _list_covers = []
        for _ in range(_count_covers):
            _item_covers = reader.tgread_object()
            _list_covers.append(_item_covers)
        _args['covers'] = _list_covers
        return cls(**_args)


class StickerSetNoCovered(TLObject):
    """TL type: stickerSetNoCovered"""
    CONSTRUCTOR_ID = 0x77b15d1c
    SUBCLASS_OF_ID = 0x7f86e4e5

    def __init__(self, set: 'TypeStickerSet'):
        self.set = set

    def to_dict(self):
        return {
            '_': 'StickerSetNoCovered',
            'set': self.set,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.set))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_set = reader.tgread_object()
        _args['set'] = _val_set
        return cls(**_args)


class StoriesStealthMode(TLObject):
    """TL type: storiesStealthMode"""
    CONSTRUCTOR_ID = 0x712e27fd
    SUBCLASS_OF_ID = 0x02ed8401

    def __init__(self, active_until_date: Optional[datetime] = None, cooldown_until_date: Optional[datetime] = None):
        self.active_until_date = active_until_date
        self.cooldown_until_date = cooldown_until_date

    def to_dict(self):
        return {
            '_': 'StoriesStealthMode',
            'active_until_date': self.active_until_date,
            'cooldown_until_date': self.cooldown_until_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.active_until_date is not None:
            flags |= (1 << 0)
        if self.cooldown_until_date is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        if self.active_until_date is not None:
            buf.write(struct.pack('<i', self.active_until_date))
        if self.cooldown_until_date is not None:
            buf.write(struct.pack('<i', self.cooldown_until_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_active_until_date = reader.read_int()
            _args['active_until_date'] = _val_active_until_date
        else:
            _args['active_until_date'] = None
        if flags & (1 << 1):
            _val_cooldown_until_date = reader.read_int()
            _args['cooldown_until_date'] = _val_cooldown_until_date
        else:
            _args['cooldown_until_date'] = None
        return cls(**_args)


class StoryAlbum(TLObject):
    """TL type: storyAlbum"""
    CONSTRUCTOR_ID = 0x9325705a
    SUBCLASS_OF_ID = 0x7c8c5ea2

    def __init__(self, album_id: int, title: str, icon_photo: Optional['TypePhoto'] = None, icon_video: Optional['TypeDocument'] = None):
        self.album_id = album_id
        self.title = title
        self.icon_photo = icon_photo
        self.icon_video = icon_video

    def to_dict(self):
        return {
            '_': 'StoryAlbum',
            'album_id': self.album_id,
            'title': self.title,
            'icon_photo': self.icon_photo,
            'icon_video': self.icon_video,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.icon_photo is not None:
            flags |= (1 << 0)
        if self.icon_video is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.album_id))
        buf.write(TLObject.serialize_bytes(self.title))
        if self.icon_photo is not None:
            buf.write(bytes(self.icon_photo))
        if self.icon_video is not None:
            buf.write(bytes(self.icon_video))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_album_id = reader.read_int()
        _args['album_id'] = _val_album_id
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        if flags & (1 << 0):
            _val_icon_photo = reader.tgread_object()
            _args['icon_photo'] = _val_icon_photo
        else:
            _args['icon_photo'] = None
        if flags & (1 << 1):
            _val_icon_video = reader.tgread_object()
            _args['icon_video'] = _val_icon_video
        else:
            _args['icon_video'] = None
        return cls(**_args)


class StoryFwdHeader(TLObject):
    """TL type: storyFwdHeader"""
    CONSTRUCTOR_ID = 0xb826e150
    SUBCLASS_OF_ID = 0xaab0b12c

    def __init__(self, modified: Optional[bool] = None, from_: Optional['TypePeer'] = None, from_name: Optional[str] = None, story_id: Optional[int] = None):
        self.modified = modified
        self.from_ = from_
        self.from_name = from_name
        self.story_id = story_id

    def to_dict(self):
        return {
            '_': 'StoryFwdHeader',
            'modified': self.modified,
            'from_': self.from_,
            'from_name': self.from_name,
            'story_id': self.story_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.modified:
            flags |= (1 << 3)
        if self.from_ is not None:
            flags |= (1 << 0)
        if self.from_name is not None:
            flags |= (1 << 1)
        if self.story_id is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.from_ is not None:
            buf.write(bytes(self.from_))
        if self.from_name is not None:
            buf.write(TLObject.serialize_bytes(self.from_name))
        if self.story_id is not None:
            buf.write(struct.pack('<i', self.story_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['modified'] = bool(flags & (1 << 3))
        if flags & (1 << 0):
            _val_from_ = reader.tgread_object()
            _args['from_'] = _val_from_
        else:
            _args['from_'] = None
        if flags & (1 << 1):
            _val_from_name = reader.tgread_string()
            _args['from_name'] = _val_from_name
        else:
            _args['from_name'] = None
        if flags & (1 << 2):
            _val_story_id = reader.read_int()
            _args['story_id'] = _val_story_id
        else:
            _args['story_id'] = None
        return cls(**_args)


class StoryItem(TLObject):
    """TL type: storyItem"""
    CONSTRUCTOR_ID = 0xedf164f1
    SUBCLASS_OF_ID = 0xd477b133

    def __init__(self, id: int, date: Optional[datetime], expire_date: Optional[datetime], media: 'TypeMessageMedia', pinned: Optional[bool] = None, public: Optional[bool] = None, close_friends: Optional[bool] = None, min: Optional[bool] = None, noforwards: Optional[bool] = None, edited: Optional[bool] = None, contacts: Optional[bool] = None, selected_contacts: Optional[bool] = None, out: Optional[bool] = None, from_id: Optional['TypePeer'] = None, fwd_from: Optional['TypeStoryFwdHeader'] = None, caption: Optional[str] = None, entities: Optional[List['TypeMessageEntity']] = None, media_areas: Optional[List['TypeMediaArea']] = None, privacy: Optional[List['TypePrivacyRule']] = None, views: Optional['TypeStoryViews'] = None, sent_reaction: Optional['TypeReaction'] = None, albums: Optional[List[int]] = None):
        self.id = id
        self.date = date
        self.expire_date = expire_date
        self.media = media
        self.pinned = pinned
        self.public = public
        self.close_friends = close_friends
        self.min = min
        self.noforwards = noforwards
        self.edited = edited
        self.contacts = contacts
        self.selected_contacts = selected_contacts
        self.out = out
        self.from_id = from_id
        self.fwd_from = fwd_from
        self.caption = caption
        self.entities = entities
        self.media_areas = media_areas
        self.privacy = privacy
        self.views = views
        self.sent_reaction = sent_reaction
        self.albums = albums

    def to_dict(self):
        return {
            '_': 'StoryItem',
            'id': self.id,
            'date': self.date,
            'expire_date': self.expire_date,
            'media': self.media,
            'pinned': self.pinned,
            'public': self.public,
            'close_friends': self.close_friends,
            'min': self.min,
            'noforwards': self.noforwards,
            'edited': self.edited,
            'contacts': self.contacts,
            'selected_contacts': self.selected_contacts,
            'out': self.out,
            'from_id': self.from_id,
            'fwd_from': self.fwd_from,
            'caption': self.caption,
            'entities': self.entities,
            'media_areas': self.media_areas,
            'privacy': self.privacy,
            'views': self.views,
            'sent_reaction': self.sent_reaction,
            'albums': self.albums,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.pinned:
            flags |= (1 << 5)
        if self.public:
            flags |= (1 << 7)
        if self.close_friends:
            flags |= (1 << 8)
        if self.min:
            flags |= (1 << 9)
        if self.noforwards:
            flags |= (1 << 10)
        if self.edited:
            flags |= (1 << 11)
        if self.contacts:
            flags |= (1 << 12)
        if self.selected_contacts:
            flags |= (1 << 13)
        if self.out:
            flags |= (1 << 16)
        if self.from_id is not None:
            flags |= (1 << 18)
        if self.fwd_from is not None:
            flags |= (1 << 17)
        if self.caption is not None:
            flags |= (1 << 0)
        if self.entities is not None:
            flags |= (1 << 1)
        if self.media_areas is not None:
            flags |= (1 << 14)
        if self.privacy is not None:
            flags |= (1 << 2)
        if self.views is not None:
            flags |= (1 << 3)
        if self.sent_reaction is not None:
            flags |= (1 << 15)
        if self.albums is not None:
            flags |= (1 << 19)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.expire_date))
        buf.write(bytes(self.media))
        if self.from_id is not None:
            buf.write(bytes(self.from_id))
        if self.fwd_from is not None:
            buf.write(bytes(self.fwd_from))
        if self.caption is not None:
            buf.write(TLObject.serialize_bytes(self.caption))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.media_areas is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.media_areas)))
            for item in self.media_areas:
                buf.write(bytes(self.item))
        if self.privacy is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.privacy)))
            for item in self.privacy:
                buf.write(bytes(self.item))
        if self.views is not None:
            buf.write(bytes(self.views))
        if self.sent_reaction is not None:
            buf.write(bytes(self.sent_reaction))
        if self.albums is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.albums)))
            for item in self.albums:
                buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['pinned'] = bool(flags & (1 << 5))
        _args['public'] = bool(flags & (1 << 7))
        _args['close_friends'] = bool(flags & (1 << 8))
        _args['min'] = bool(flags & (1 << 9))
        _args['noforwards'] = bool(flags & (1 << 10))
        _args['edited'] = bool(flags & (1 << 11))
        _args['contacts'] = bool(flags & (1 << 12))
        _args['selected_contacts'] = bool(flags & (1 << 13))
        _args['out'] = bool(flags & (1 << 16))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 18):
            _val_from_id = reader.tgread_object()
            _args['from_id'] = _val_from_id
        else:
            _args['from_id'] = None
        if flags & (1 << 17):
            _val_fwd_from = reader.tgread_object()
            _args['fwd_from'] = _val_fwd_from
        else:
            _args['fwd_from'] = None
        _val_expire_date = reader.read_int()
        _args['expire_date'] = _val_expire_date
        if flags & (1 << 0):
            _val_caption = reader.tgread_string()
            _args['caption'] = _val_caption
        else:
            _args['caption'] = None
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        _val_media = reader.tgread_object()
        _args['media'] = _val_media
        if flags & (1 << 14):
            reader.read_int(signed=False)  # skip vector id
            _count_media_areas = reader.read_int()
            _list_media_areas = []
            for _ in range(_count_media_areas):
                _item_media_areas = reader.tgread_object()
                _list_media_areas.append(_item_media_areas)
            _args['media_areas'] = _list_media_areas
        else:
            _args['media_areas'] = None
        if flags & (1 << 2):
            reader.read_int(signed=False)  # skip vector id
            _count_privacy = reader.read_int()
            _list_privacy = []
            for _ in range(_count_privacy):
                _item_privacy = reader.tgread_object()
                _list_privacy.append(_item_privacy)
            _args['privacy'] = _list_privacy
        else:
            _args['privacy'] = None
        if flags & (1 << 3):
            _val_views = reader.tgread_object()
            _args['views'] = _val_views
        else:
            _args['views'] = None
        if flags & (1 << 15):
            _val_sent_reaction = reader.tgread_object()
            _args['sent_reaction'] = _val_sent_reaction
        else:
            _args['sent_reaction'] = None
        if flags & (1 << 19):
            reader.read_int(signed=False)  # skip vector id
            _count_albums = reader.read_int()
            _list_albums = []
            for _ in range(_count_albums):
                _item_albums = reader.read_int()
                _list_albums.append(_item_albums)
            _args['albums'] = _list_albums
        else:
            _args['albums'] = None
        return cls(**_args)


class StoryItemDeleted(TLObject):
    """TL type: storyItemDeleted"""
    CONSTRUCTOR_ID = 0x51e6ee4f
    SUBCLASS_OF_ID = 0xd477b133

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'StoryItemDeleted',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        return cls(**_args)


class StoryItemSkipped(TLObject):
    """TL type: storyItemSkipped"""
    CONSTRUCTOR_ID = 0xffadc913
    SUBCLASS_OF_ID = 0xd477b133

    def __init__(self, id: int, date: Optional[datetime], expire_date: Optional[datetime], close_friends: Optional[bool] = None, live: Optional[bool] = None):
        self.id = id
        self.date = date
        self.expire_date = expire_date
        self.close_friends = close_friends
        self.live = live

    def to_dict(self):
        return {
            '_': 'StoryItemSkipped',
            'id': self.id,
            'date': self.date,
            'expire_date': self.expire_date,
            'close_friends': self.close_friends,
            'live': self.live,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.close_friends:
            flags |= (1 << 8)
        if self.live:
            flags |= (1 << 9)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.expire_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['close_friends'] = bool(flags & (1 << 8))
        _args['live'] = bool(flags & (1 << 9))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_expire_date = reader.read_int()
        _args['expire_date'] = _val_expire_date
        return cls(**_args)


class StoryReaction(TLObject):
    """TL type: storyReaction"""
    CONSTRUCTOR_ID = 0x6090d6d5
    SUBCLASS_OF_ID = 0xc96b5fab

    def __init__(self, peer_id: 'TypePeer', date: Optional[datetime], reaction: 'TypeReaction'):
        self.peer_id = peer_id
        self.date = date
        self.reaction = reaction

    def to_dict(self):
        return {
            '_': 'StoryReaction',
            'peer_id': self.peer_id,
            'date': self.date,
            'reaction': self.reaction,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(bytes(self.reaction))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer_id = reader.tgread_object()
        _args['peer_id'] = _val_peer_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_reaction = reader.tgread_object()
        _args['reaction'] = _val_reaction
        return cls(**_args)


class StoryReactionPublicForward(TLObject):
    """TL type: storyReactionPublicForward"""
    CONSTRUCTOR_ID = 0xbbab2643
    SUBCLASS_OF_ID = 0xc96b5fab

    def __init__(self, message: 'TypeMessage'):
        self.message = message

    def to_dict(self):
        return {
            '_': 'StoryReactionPublicForward',
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        return cls(**_args)


class StoryReactionPublicRepost(TLObject):
    """TL type: storyReactionPublicRepost"""
    CONSTRUCTOR_ID = 0xcfcd0f13
    SUBCLASS_OF_ID = 0xc96b5fab

    def __init__(self, peer_id: 'TypePeer', story: 'TypeStoryItem'):
        self.peer_id = peer_id
        self.story = story

    def to_dict(self):
        return {
            '_': 'StoryReactionPublicRepost',
            'peer_id': self.peer_id,
            'story': self.story,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer_id))
        buf.write(bytes(self.story))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer_id = reader.tgread_object()
        _args['peer_id'] = _val_peer_id
        _val_story = reader.tgread_object()
        _args['story'] = _val_story
        return cls(**_args)


class StoryView(TLObject):
    """TL type: storyView"""
    CONSTRUCTOR_ID = 0xb0bdeac5
    SUBCLASS_OF_ID = 0x35913fa3

    def __init__(self, user_id: int, date: Optional[datetime], blocked: Optional[bool] = None, blocked_my_stories_from: Optional[bool] = None, reaction: Optional['TypeReaction'] = None):
        self.user_id = user_id
        self.date = date
        self.blocked = blocked
        self.blocked_my_stories_from = blocked_my_stories_from
        self.reaction = reaction

    def to_dict(self):
        return {
            '_': 'StoryView',
            'user_id': self.user_id,
            'date': self.date,
            'blocked': self.blocked,
            'blocked_my_stories_from': self.blocked_my_stories_from,
            'reaction': self.reaction,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.blocked:
            flags |= (1 << 0)
        if self.blocked_my_stories_from:
            flags |= (1 << 1)
        if self.reaction is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.date))
        if self.reaction is not None:
            buf.write(bytes(self.reaction))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['blocked'] = bool(flags & (1 << 0))
        _args['blocked_my_stories_from'] = bool(flags & (1 << 1))
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 2):
            _val_reaction = reader.tgread_object()
            _args['reaction'] = _val_reaction
        else:
            _args['reaction'] = None
        return cls(**_args)


class StoryViewPublicForward(TLObject):
    """TL type: storyViewPublicForward"""
    CONSTRUCTOR_ID = 0x9083670b
    SUBCLASS_OF_ID = 0x35913fa3

    def __init__(self, message: 'TypeMessage', blocked: Optional[bool] = None, blocked_my_stories_from: Optional[bool] = None):
        self.message = message
        self.blocked = blocked
        self.blocked_my_stories_from = blocked_my_stories_from

    def to_dict(self):
        return {
            '_': 'StoryViewPublicForward',
            'message': self.message,
            'blocked': self.blocked,
            'blocked_my_stories_from': self.blocked_my_stories_from,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.blocked:
            flags |= (1 << 0)
        if self.blocked_my_stories_from:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['blocked'] = bool(flags & (1 << 0))
        _args['blocked_my_stories_from'] = bool(flags & (1 << 1))
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        return cls(**_args)


class StoryViewPublicRepost(TLObject):
    """TL type: storyViewPublicRepost"""
    CONSTRUCTOR_ID = 0xbd74cf49
    SUBCLASS_OF_ID = 0x35913fa3

    def __init__(self, peer_id: 'TypePeer', story: 'TypeStoryItem', blocked: Optional[bool] = None, blocked_my_stories_from: Optional[bool] = None):
        self.peer_id = peer_id
        self.story = story
        self.blocked = blocked
        self.blocked_my_stories_from = blocked_my_stories_from

    def to_dict(self):
        return {
            '_': 'StoryViewPublicRepost',
            'peer_id': self.peer_id,
            'story': self.story,
            'blocked': self.blocked,
            'blocked_my_stories_from': self.blocked_my_stories_from,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.blocked:
            flags |= (1 << 0)
        if self.blocked_my_stories_from:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer_id))
        buf.write(bytes(self.story))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['blocked'] = bool(flags & (1 << 0))
        _args['blocked_my_stories_from'] = bool(flags & (1 << 1))
        _val_peer_id = reader.tgread_object()
        _args['peer_id'] = _val_peer_id
        _val_story = reader.tgread_object()
        _args['story'] = _val_story
        return cls(**_args)


class StoryViews(TLObject):
    """TL type: storyViews"""
    CONSTRUCTOR_ID = 0x8d595cd6
    SUBCLASS_OF_ID = 0x54e4ac66

    def __init__(self, views_count: int, has_viewers: Optional[bool] = None, forwards_count: Optional[int] = None, reactions: Optional[List['TypeReactionCount']] = None, reactions_count: Optional[int] = None, recent_viewers: Optional[List[int]] = None):
        self.views_count = views_count
        self.has_viewers = has_viewers
        self.forwards_count = forwards_count
        self.reactions = reactions
        self.reactions_count = reactions_count
        self.recent_viewers = recent_viewers

    def to_dict(self):
        return {
            '_': 'StoryViews',
            'views_count': self.views_count,
            'has_viewers': self.has_viewers,
            'forwards_count': self.forwards_count,
            'reactions': self.reactions,
            'reactions_count': self.reactions_count,
            'recent_viewers': self.recent_viewers,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.has_viewers:
            flags |= (1 << 1)
        if self.forwards_count is not None:
            flags |= (1 << 2)
        if self.reactions is not None:
            flags |= (1 << 3)
        if self.reactions_count is not None:
            flags |= (1 << 4)
        if self.recent_viewers is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.views_count))
        if self.forwards_count is not None:
            buf.write(struct.pack('<i', self.forwards_count))
        if self.reactions is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.reactions)))
            for item in self.reactions:
                buf.write(bytes(self.item))
        if self.reactions_count is not None:
            buf.write(struct.pack('<i', self.reactions_count))
        if self.recent_viewers is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.recent_viewers)))
            for item in self.recent_viewers:
                buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['has_viewers'] = bool(flags & (1 << 1))
        _val_views_count = reader.read_int()
        _args['views_count'] = _val_views_count
        if flags & (1 << 2):
            _val_forwards_count = reader.read_int()
            _args['forwards_count'] = _val_forwards_count
        else:
            _args['forwards_count'] = None
        if flags & (1 << 3):
            reader.read_int(signed=False)  # skip vector id
            _count_reactions = reader.read_int()
            _list_reactions = []
            for _ in range(_count_reactions):
                _item_reactions = reader.tgread_object()
                _list_reactions.append(_item_reactions)
            _args['reactions'] = _list_reactions
        else:
            _args['reactions'] = None
        if flags & (1 << 4):
            _val_reactions_count = reader.read_int()
            _args['reactions_count'] = _val_reactions_count
        else:
            _args['reactions_count'] = None
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_recent_viewers = reader.read_int()
            _list_recent_viewers = []
            for _ in range(_count_recent_viewers):
                _item_recent_viewers = reader.read_long()
                _list_recent_viewers.append(_item_recent_viewers)
            _args['recent_viewers'] = _list_recent_viewers
        else:
            _args['recent_viewers'] = None
        return cls(**_args)


class SuggestedPost(TLObject):
    """TL type: suggestedPost"""
    CONSTRUCTOR_ID = 0x0e8e37e5
    SUBCLASS_OF_ID = 0x8e728200

    def __init__(self, accepted: Optional[bool] = None, rejected: Optional[bool] = None, price: Optional['TypeStarsAmount'] = None, schedule_date: Optional[datetime] = None):
        self.accepted = accepted
        self.rejected = rejected
        self.price = price
        self.schedule_date = schedule_date

    def to_dict(self):
        return {
            '_': 'SuggestedPost',
            'accepted': self.accepted,
            'rejected': self.rejected,
            'price': self.price,
            'schedule_date': self.schedule_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.accepted:
            flags |= (1 << 1)
        if self.rejected:
            flags |= (1 << 2)
        if self.price is not None:
            flags |= (1 << 3)
        if self.schedule_date is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        if self.price is not None:
            buf.write(bytes(self.price))
        if self.schedule_date is not None:
            buf.write(struct.pack('<i', self.schedule_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['accepted'] = bool(flags & (1 << 1))
        _args['rejected'] = bool(flags & (1 << 2))
        if flags & (1 << 3):
            _val_price = reader.tgread_object()
            _args['price'] = _val_price
        else:
            _args['price'] = None
        if flags & (1 << 0):
            _val_schedule_date = reader.read_int()
            _args['schedule_date'] = _val_schedule_date
        else:
            _args['schedule_date'] = None
        return cls(**_args)


class TextAnchor(TLObject):
    """TL type: textAnchor"""
    CONSTRUCTOR_ID = 0x35553762
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText', name: str):
        self.text = text
        self.name = name

    def to_dict(self):
        return {
            '_': 'TextAnchor',
            'text': self.text,
            'name': self.name,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.name))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        return cls(**_args)


class TextBold(TLObject):
    """TL type: textBold"""
    CONSTRUCTOR_ID = 0x6724abc4
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'TextBold',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class TextConcat(TLObject):
    """TL type: textConcat"""
    CONSTRUCTOR_ID = 0x7e6260d7
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, texts: List['TypeRichText']):
        self.texts = texts

    def to_dict(self):
        return {
            '_': 'TextConcat',
            'texts': self.texts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.texts)))
        for item in self.texts:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_texts = reader.read_int()
        _list_texts = []
        for _ in range(_count_texts):
            _item_texts = reader.tgread_object()
            _list_texts.append(_item_texts)
        _args['texts'] = _list_texts
        return cls(**_args)


class TextEmail(TLObject):
    """TL type: textEmail"""
    CONSTRUCTOR_ID = 0xde5a0dd6
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText', email: str):
        self.text = text
        self.email = email

    def to_dict(self):
        return {
            '_': 'TextEmail',
            'text': self.text,
            'email': self.email,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.email))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        _val_email = reader.tgread_string()
        _args['email'] = _val_email
        return cls(**_args)


class TextEmpty(TLObject):
    """TL type: textEmpty"""
    CONSTRUCTOR_ID = 0xdc3d824f
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'TextEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class TextFixed(TLObject):
    """TL type: textFixed"""
    CONSTRUCTOR_ID = 0x6c3f19b9
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'TextFixed',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class TextImage(TLObject):
    """TL type: textImage"""
    CONSTRUCTOR_ID = 0x081ccf4f
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, document_id: int, w: int, h: int):
        self.document_id = document_id
        self.w = w
        self.h = h

    def to_dict(self):
        return {
            '_': 'TextImage',
            'document_id': self.document_id,
            'w': self.w,
            'h': self.h,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.document_id))
        buf.write(struct.pack('<i', self.w))
        buf.write(struct.pack('<i', self.h))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_document_id = reader.read_long()
        _args['document_id'] = _val_document_id
        _val_w = reader.read_int()
        _args['w'] = _val_w
        _val_h = reader.read_int()
        _args['h'] = _val_h
        return cls(**_args)


class TextItalic(TLObject):
    """TL type: textItalic"""
    CONSTRUCTOR_ID = 0xd912a59c
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'TextItalic',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class TextMarked(TLObject):
    """TL type: textMarked"""
    CONSTRUCTOR_ID = 0x034b8621
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'TextMarked',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class TextPhone(TLObject):
    """TL type: textPhone"""
    CONSTRUCTOR_ID = 0x1ccb966a
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText', phone: str):
        self.text = text
        self.phone = phone

    def to_dict(self):
        return {
            '_': 'TextPhone',
            'text': self.text,
            'phone': self.phone,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.phone))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        _val_phone = reader.tgread_string()
        _args['phone'] = _val_phone
        return cls(**_args)


class TextPlain(TLObject):
    """TL type: textPlain"""
    CONSTRUCTOR_ID = 0x744694e0
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: str):
        self.text = text

    def to_dict(self):
        return {
            '_': 'TextPlain',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class TextStrike(TLObject):
    """TL type: textStrike"""
    CONSTRUCTOR_ID = 0x9bf8bb95
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'TextStrike',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class TextSubscript(TLObject):
    """TL type: textSubscript"""
    CONSTRUCTOR_ID = 0xed6a8504
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'TextSubscript',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class TextSuperscript(TLObject):
    """TL type: textSuperscript"""
    CONSTRUCTOR_ID = 0xc7fb5e01
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'TextSuperscript',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class TextUnderline(TLObject):
    """TL type: textUnderline"""
    CONSTRUCTOR_ID = 0xc12622c4
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText'):
        self.text = text

    def to_dict(self):
        return {
            '_': 'TextUnderline',
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class TextUrl(TLObject):
    """TL type: textUrl"""
    CONSTRUCTOR_ID = 0x3c2884c1
    SUBCLASS_OF_ID = 0xf1d0b479

    def __init__(self, text: 'TypeRichText', url: str, webpage_id: int):
        self.text = text
        self.url = url
        self.webpage_id = webpage_id

    def to_dict(self):
        return {
            '_': 'TextUrl',
            'text': self.text,
            'url': self.url,
            'webpage_id': self.webpage_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.text))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<q', self.webpage_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_object()
        _args['text'] = _val_text
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_webpage_id = reader.read_long()
        _args['webpage_id'] = _val_webpage_id
        return cls(**_args)


class TextWithEntities(TLObject):
    """TL type: textWithEntities"""
    CONSTRUCTOR_ID = 0x751f3146
    SUBCLASS_OF_ID = 0x95ca4b05

    def __init__(self, text: str, entities: List['TypeMessageEntity']):
        self.text = text
        self.entities = entities

    def to_dict(self):
        return {
            '_': 'TextWithEntities',
            'text': self.text,
            'entities': self.entities,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.text))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.entities)))
        for item in self.entities:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        reader.read_int(signed=False)  # skip vector id
        _count_entities = reader.read_int()
        _list_entities = []
        for _ in range(_count_entities):
            _item_entities = reader.tgread_object()
            _list_entities.append(_item_entities)
        _args['entities'] = _list_entities
        return cls(**_args)


class Theme(TLObject):
    """TL type: theme"""
    CONSTRUCTOR_ID = 0xa00e67d6
    SUBCLASS_OF_ID = 0x56b4c80c

    def __init__(self, id: int, access_hash: int, slug: str, title: str, creator: Optional[bool] = None, default: Optional[bool] = None, for_chat: Optional[bool] = None, document: Optional['TypeDocument'] = None, settings: Optional[List['TypeThemeSettings']] = None, emoticon: Optional[str] = None, installs_count: Optional[int] = None):
        self.id = id
        self.access_hash = access_hash
        self.slug = slug
        self.title = title
        self.creator = creator
        self.default = default
        self.for_chat = for_chat
        self.document = document
        self.settings = settings
        self.emoticon = emoticon
        self.installs_count = installs_count

    def to_dict(self):
        return {
            '_': 'Theme',
            'id': self.id,
            'access_hash': self.access_hash,
            'slug': self.slug,
            'title': self.title,
            'creator': self.creator,
            'default': self.default,
            'for_chat': self.for_chat,
            'document': self.document,
            'settings': self.settings,
            'emoticon': self.emoticon,
            'installs_count': self.installs_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.creator:
            flags |= (1 << 0)
        if self.default:
            flags |= (1 << 1)
        if self.for_chat:
            flags |= (1 << 5)
        if self.document is not None:
            flags |= (1 << 2)
        if self.settings is not None:
            flags |= (1 << 3)
        if self.emoticon is not None:
            flags |= (1 << 6)
        if self.installs_count is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.slug))
        buf.write(TLObject.serialize_bytes(self.title))
        if self.document is not None:
            buf.write(bytes(self.document))
        if self.settings is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.settings)))
            for item in self.settings:
                buf.write(bytes(self.item))
        if self.emoticon is not None:
            buf.write(TLObject.serialize_bytes(self.emoticon))
        if self.installs_count is not None:
            buf.write(struct.pack('<i', self.installs_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['creator'] = bool(flags & (1 << 0))
        _args['default'] = bool(flags & (1 << 1))
        _args['for_chat'] = bool(flags & (1 << 5))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        if flags & (1 << 2):
            _val_document = reader.tgread_object()
            _args['document'] = _val_document
        else:
            _args['document'] = None
        if flags & (1 << 3):
            reader.read_int(signed=False)  # skip vector id
            _count_settings = reader.read_int()
            _list_settings = []
            for _ in range(_count_settings):
                _item_settings = reader.tgread_object()
                _list_settings.append(_item_settings)
            _args['settings'] = _list_settings
        else:
            _args['settings'] = None
        if flags & (1 << 6):
            _val_emoticon = reader.tgread_string()
            _args['emoticon'] = _val_emoticon
        else:
            _args['emoticon'] = None
        if flags & (1 << 4):
            _val_installs_count = reader.read_int()
            _args['installs_count'] = _val_installs_count
        else:
            _args['installs_count'] = None
        return cls(**_args)


class ThemeSettings(TLObject):
    """TL type: themeSettings"""
    CONSTRUCTOR_ID = 0xfa58b6d4
    SUBCLASS_OF_ID = 0x82666d38

    def __init__(self, base_theme: 'TypeBaseTheme', accent_color: int, message_colors_animated: Optional[bool] = None, outbox_accent_color: Optional[int] = None, message_colors: Optional[List[int]] = None, wallpaper: Optional['TypeWallPaper'] = None):
        self.base_theme = base_theme
        self.accent_color = accent_color
        self.message_colors_animated = message_colors_animated
        self.outbox_accent_color = outbox_accent_color
        self.message_colors = message_colors
        self.wallpaper = wallpaper

    def to_dict(self):
        return {
            '_': 'ThemeSettings',
            'base_theme': self.base_theme,
            'accent_color': self.accent_color,
            'message_colors_animated': self.message_colors_animated,
            'outbox_accent_color': self.outbox_accent_color,
            'message_colors': self.message_colors,
            'wallpaper': self.wallpaper,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.message_colors_animated:
            flags |= (1 << 2)
        if self.outbox_accent_color is not None:
            flags |= (1 << 3)
        if self.message_colors is not None:
            flags |= (1 << 0)
        if self.wallpaper is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.base_theme))
        buf.write(struct.pack('<i', self.accent_color))
        if self.outbox_accent_color is not None:
            buf.write(struct.pack('<i', self.outbox_accent_color))
        if self.message_colors is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.message_colors)))
            for item in self.message_colors:
                buf.write(struct.pack('<i', self.item))
        if self.wallpaper is not None:
            buf.write(bytes(self.wallpaper))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['message_colors_animated'] = bool(flags & (1 << 2))
        _val_base_theme = reader.tgread_object()
        _args['base_theme'] = _val_base_theme
        _val_accent_color = reader.read_int()
        _args['accent_color'] = _val_accent_color
        if flags & (1 << 3):
            _val_outbox_accent_color = reader.read_int()
            _args['outbox_accent_color'] = _val_outbox_accent_color
        else:
            _args['outbox_accent_color'] = None
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_message_colors = reader.read_int()
            _list_message_colors = []
            for _ in range(_count_message_colors):
                _item_message_colors = reader.read_int()
                _list_message_colors.append(_item_message_colors)
            _args['message_colors'] = _list_message_colors
        else:
            _args['message_colors'] = None
        if flags & (1 << 1):
            _val_wallpaper = reader.tgread_object()
            _args['wallpaper'] = _val_wallpaper
        else:
            _args['wallpaper'] = None
        return cls(**_args)


class Timezone(TLObject):
    """TL type: timezone"""
    CONSTRUCTOR_ID = 0xff9289f5
    SUBCLASS_OF_ID = 0xce77d0c1

    def __init__(self, id: str, name: str, utc_offset: int):
        self.id = id
        self.name = name
        self.utc_offset = utc_offset

    def to_dict(self):
        return {
            '_': 'Timezone',
            'id': self.id,
            'name': self.name,
            'utc_offset': self.utc_offset,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.id))
        buf.write(TLObject.serialize_bytes(self.name))
        buf.write(struct.pack('<i', self.utc_offset))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        _val_name = reader.tgread_string()
        _args['name'] = _val_name
        _val_utc_offset = reader.read_int()
        _args['utc_offset'] = _val_utc_offset
        return cls(**_args)


class TodoCompletion(TLObject):
    """TL type: todoCompletion"""
    CONSTRUCTOR_ID = 0x221bb5e4
    SUBCLASS_OF_ID = 0xbae65b7b

    def __init__(self, id: int, completed_by: 'TypePeer', date: Optional[datetime]):
        self.id = id
        self.completed_by = completed_by
        self.date = date

    def to_dict(self):
        return {
            '_': 'TodoCompletion',
            'id': self.id,
            'completed_by': self.completed_by,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        buf.write(bytes(self.completed_by))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_completed_by = reader.tgread_object()
        _args['completed_by'] = _val_completed_by
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class TodoItem(TLObject):
    """TL type: todoItem"""
    CONSTRUCTOR_ID = 0xcba9a52f
    SUBCLASS_OF_ID = 0xdfdae6b5

    def __init__(self, id: int, title: 'TypeTextWithEntities'):
        self.id = id
        self.title = title

    def to_dict(self):
        return {
            '_': 'TodoItem',
            'id': self.id,
            'title': self.title,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        buf.write(bytes(self.title))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_title = reader.tgread_object()
        _args['title'] = _val_title
        return cls(**_args)


class TodoList(TLObject):
    """TL type: todoList"""
    CONSTRUCTOR_ID = 0x49b92a26
    SUBCLASS_OF_ID = 0x84093bb3

    def __init__(self, title: 'TypeTextWithEntities', list: List['TypeTodoItem'], others_can_append: Optional[bool] = None, others_can_complete: Optional[bool] = None):
        self.title = title
        self.list = list
        self.others_can_append = others_can_append
        self.others_can_complete = others_can_complete

    def to_dict(self):
        return {
            '_': 'TodoList',
            'title': self.title,
            'list': self.list,
            'others_can_append': self.others_can_append,
            'others_can_complete': self.others_can_complete,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.others_can_append:
            flags |= (1 << 0)
        if self.others_can_complete:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.title))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.list)))
        for item in self.list:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['others_can_append'] = bool(flags & (1 << 0))
        _args['others_can_complete'] = bool(flags & (1 << 1))
        _val_title = reader.tgread_object()
        _args['title'] = _val_title
        reader.read_int(signed=False)  # skip vector id
        _count_list = reader.read_int()
        _list_list = []
        for _ in range(_count_list):
            _item_list = reader.tgread_object()
            _list_list.append(_item_list)
        _args['list'] = _list_list
        return cls(**_args)


class TopPeer(TLObject):
    """TL type: topPeer"""
    CONSTRUCTOR_ID = 0xedcdc05b
    SUBCLASS_OF_ID = 0x6916c601

    def __init__(self, peer: 'TypePeer', rating: float):
        self.peer = peer
        self.rating = rating

    def to_dict(self):
        return {
            '_': 'TopPeer',
            'peer': self.peer,
            'rating': self.rating,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<d', self.rating))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_rating = reader.read_double()
        _args['rating'] = _val_rating
        return cls(**_args)


class TopPeerCategoryBotsApp(TLObject):
    """TL type: topPeerCategoryBotsApp"""
    CONSTRUCTOR_ID = 0xfd9e7bec
    SUBCLASS_OF_ID = 0xddf02502

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'TopPeerCategoryBotsApp',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class TopPeerCategoryBotsInline(TLObject):
    """TL type: topPeerCategoryBotsInline"""
    CONSTRUCTOR_ID = 0x148677e2
    SUBCLASS_OF_ID = 0xddf02502

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'TopPeerCategoryBotsInline',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class TopPeerCategoryBotsPm(TLObject):
    """TL type: topPeerCategoryBotsPM"""
    CONSTRUCTOR_ID = 0xab661b5b
    SUBCLASS_OF_ID = 0xddf02502

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'TopPeerCategoryBotsPm',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class TopPeerCategoryChannels(TLObject):
    """TL type: topPeerCategoryChannels"""
    CONSTRUCTOR_ID = 0x161d9628
    SUBCLASS_OF_ID = 0xddf02502

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'TopPeerCategoryChannels',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class TopPeerCategoryCorrespondents(TLObject):
    """TL type: topPeerCategoryCorrespondents"""
    CONSTRUCTOR_ID = 0x0637b7ed
    SUBCLASS_OF_ID = 0xddf02502

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'TopPeerCategoryCorrespondents',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class TopPeerCategoryForwardChats(TLObject):
    """TL type: topPeerCategoryForwardChats"""
    CONSTRUCTOR_ID = 0xfbeec0f0
    SUBCLASS_OF_ID = 0xddf02502

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'TopPeerCategoryForwardChats',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class TopPeerCategoryForwardUsers(TLObject):
    """TL type: topPeerCategoryForwardUsers"""
    CONSTRUCTOR_ID = 0xa8406ca9
    SUBCLASS_OF_ID = 0xddf02502

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'TopPeerCategoryForwardUsers',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class TopPeerCategoryGroups(TLObject):
    """TL type: topPeerCategoryGroups"""
    CONSTRUCTOR_ID = 0xbd17a14a
    SUBCLASS_OF_ID = 0xddf02502

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'TopPeerCategoryGroups',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class TopPeerCategoryPeers(TLObject):
    """TL type: topPeerCategoryPeers"""
    CONSTRUCTOR_ID = 0xfb834291
    SUBCLASS_OF_ID = 0x04aec930

    def __init__(self, category: 'TypeTopPeerCategory', count: int, peers: List['TypeTopPeer']):
        self.category = category
        self.count = count
        self.peers = peers

    def to_dict(self):
        return {
            '_': 'TopPeerCategoryPeers',
            'category': self.category,
            'count': self.count,
            'peers': self.peers,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.category))
        buf.write(struct.pack('<i', self.count))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.peers)))
        for item in self.peers:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_category = reader.tgread_object()
        _args['category'] = _val_category
        _val_count = reader.read_int()
        _args['count'] = _val_count
        reader.read_int(signed=False)  # skip vector id
        _count_peers = reader.read_int()
        _list_peers = []
        for _ in range(_count_peers):
            _item_peers = reader.tgread_object()
            _list_peers.append(_item_peers)
        _args['peers'] = _list_peers
        return cls(**_args)


class TopPeerCategoryPhoneCalls(TLObject):
    """TL type: topPeerCategoryPhoneCalls"""
    CONSTRUCTOR_ID = 0x1e76a78c
    SUBCLASS_OF_ID = 0xddf02502

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'TopPeerCategoryPhoneCalls',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateAttachMenuBots(TLObject):
    """TL type: updateAttachMenuBots"""
    CONSTRUCTOR_ID = 0x17b7a20b
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateAttachMenuBots',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateAutoSaveSettings(TLObject):
    """TL type: updateAutoSaveSettings"""
    CONSTRUCTOR_ID = 0xec05b097
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateAutoSaveSettings',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateBotBusinessConnect(TLObject):
    """TL type: updateBotBusinessConnect"""
    CONSTRUCTOR_ID = 0x8ae5c97a
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, connection: 'TypeBotBusinessConnection', qts: int):
        self.connection = connection
        self.qts = qts

    def to_dict(self):
        return {
            '_': 'UpdateBotBusinessConnect',
            'connection': self.connection,
            'qts': self.qts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.connection))
        buf.write(struct.pack('<i', self.qts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_connection = reader.tgread_object()
        _args['connection'] = _val_connection
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateBotCallbackQuery(TLObject):
    """TL type: updateBotCallbackQuery"""
    CONSTRUCTOR_ID = 0xb9cfc48d
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, query_id: int, user_id: int, peer: 'TypePeer', msg_id: int, chat_instance: int, data: Optional[bytes] = None, game_short_name: Optional[str] = None):
        self.query_id = query_id
        self.user_id = user_id
        self.peer = peer
        self.msg_id = msg_id
        self.chat_instance = chat_instance
        self.data = data
        self.game_short_name = game_short_name

    def to_dict(self):
        return {
            '_': 'UpdateBotCallbackQuery',
            'query_id': self.query_id,
            'user_id': self.user_id,
            'peer': self.peer,
            'msg_id': self.msg_id,
            'chat_instance': self.chat_instance,
            'data': self.data,
            'game_short_name': self.game_short_name,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.data is not None:
            flags |= (1 << 0)
        if self.game_short_name is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.query_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<q', self.chat_instance))
        if self.data is not None:
            buf.write(TLObject.serialize_bytes(self.data))
        if self.game_short_name is not None:
            buf.write(TLObject.serialize_bytes(self.game_short_name))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        _val_chat_instance = reader.read_long()
        _args['chat_instance'] = _val_chat_instance
        if flags & (1 << 0):
            _val_data = reader.tgread_bytes()
            _args['data'] = _val_data
        else:
            _args['data'] = None
        if flags & (1 << 1):
            _val_game_short_name = reader.tgread_string()
            _args['game_short_name'] = _val_game_short_name
        else:
            _args['game_short_name'] = None
        return cls(**_args)


class UpdateBotChatBoost(TLObject):
    """TL type: updateBotChatBoost"""
    CONSTRUCTOR_ID = 0x904dd49c
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', boost: 'TypeBoost', qts: int):
        self.peer = peer
        self.boost = boost
        self.qts = qts

    def to_dict(self):
        return {
            '_': 'UpdateBotChatBoost',
            'peer': self.peer,
            'boost': self.boost,
            'qts': self.qts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.boost))
        buf.write(struct.pack('<i', self.qts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_boost = reader.tgread_object()
        _args['boost'] = _val_boost
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateBotChatInviteRequester(TLObject):
    """TL type: updateBotChatInviteRequester"""
    CONSTRUCTOR_ID = 0x11dfa986
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', date: Optional[datetime], user_id: int, about: str, invite: 'TypeExportedChatInvite', qts: int):
        self.peer = peer
        self.date = date
        self.user_id = user_id
        self.about = about
        self.invite = invite
        self.qts = qts

    def to_dict(self):
        return {
            '_': 'UpdateBotChatInviteRequester',
            'peer': self.peer,
            'date': self.date,
            'user_id': self.user_id,
            'about': self.about,
            'invite': self.invite,
            'qts': self.qts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(TLObject.serialize_bytes(self.about))
        buf.write(bytes(self.invite))
        buf.write(struct.pack('<i', self.qts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_about = reader.tgread_string()
        _args['about'] = _val_about
        _val_invite = reader.tgread_object()
        _args['invite'] = _val_invite
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateBotCommands(TLObject):
    """TL type: updateBotCommands"""
    CONSTRUCTOR_ID = 0x4d712f2e
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', bot_id: int, commands: List['TypeBotCommand']):
        self.peer = peer
        self.bot_id = bot_id
        self.commands = commands

    def to_dict(self):
        return {
            '_': 'UpdateBotCommands',
            'peer': self.peer,
            'bot_id': self.bot_id,
            'commands': self.commands,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<q', self.bot_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.commands)))
        for item in self.commands:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_bot_id = reader.read_long()
        _args['bot_id'] = _val_bot_id
        reader.read_int(signed=False)  # skip vector id
        _count_commands = reader.read_int()
        _list_commands = []
        for _ in range(_count_commands):
            _item_commands = reader.tgread_object()
            _list_commands.append(_item_commands)
        _args['commands'] = _list_commands
        return cls(**_args)


class UpdateBotDeleteBusinessMessage(TLObject):
    """TL type: updateBotDeleteBusinessMessage"""
    CONSTRUCTOR_ID = 0xa02a982e
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, connection_id: str, peer: 'TypePeer', messages: List[int], qts: int):
        self.connection_id = connection_id
        self.peer = peer
        self.messages = messages
        self.qts = qts

    def to_dict(self):
        return {
            '_': 'UpdateBotDeleteBusinessMessage',
            'connection_id': self.connection_id,
            'peer': self.peer,
            'messages': self.messages,
            'qts': self.qts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.connection_id))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.messages)))
        for item in self.messages:
            buf.write(struct.pack('<i', self.item))
        buf.write(struct.pack('<i', self.qts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_connection_id = reader.tgread_string()
        _args['connection_id'] = _val_connection_id
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        reader.read_int(signed=False)  # skip vector id
        _count_messages = reader.read_int()
        _list_messages = []
        for _ in range(_count_messages):
            _item_messages = reader.read_int()
            _list_messages.append(_item_messages)
        _args['messages'] = _list_messages
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateBotEditBusinessMessage(TLObject):
    """TL type: updateBotEditBusinessMessage"""
    CONSTRUCTOR_ID = 0x07df587c
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, connection_id: str, message: 'TypeMessage', qts: int, reply_to_message: Optional['TypeMessage'] = None):
        self.connection_id = connection_id
        self.message = message
        self.qts = qts
        self.reply_to_message = reply_to_message

    def to_dict(self):
        return {
            '_': 'UpdateBotEditBusinessMessage',
            'connection_id': self.connection_id,
            'message': self.message,
            'qts': self.qts,
            'reply_to_message': self.reply_to_message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reply_to_message is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.connection_id))
        buf.write(bytes(self.message))
        buf.write(struct.pack('<i', self.qts))
        if self.reply_to_message is not None:
            buf.write(bytes(self.reply_to_message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_connection_id = reader.tgread_string()
        _args['connection_id'] = _val_connection_id
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        if flags & (1 << 0):
            _val_reply_to_message = reader.tgread_object()
            _args['reply_to_message'] = _val_reply_to_message
        else:
            _args['reply_to_message'] = None
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateBotInlineQuery(TLObject):
    """TL type: updateBotInlineQuery"""
    CONSTRUCTOR_ID = 0x496f379c
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, query_id: int, user_id: int, query: str, offset: str, geo: Optional['TypeGeoPoint'] = None, peer_type: Optional['TypeInlineQueryPeerType'] = None):
        self.query_id = query_id
        self.user_id = user_id
        self.query = query
        self.offset = offset
        self.geo = geo
        self.peer_type = peer_type

    def to_dict(self):
        return {
            '_': 'UpdateBotInlineQuery',
            'query_id': self.query_id,
            'user_id': self.user_id,
            'query': self.query,
            'offset': self.offset,
            'geo': self.geo,
            'peer_type': self.peer_type,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.geo is not None:
            flags |= (1 << 0)
        if self.peer_type is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.query_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(TLObject.serialize_bytes(self.query))
        buf.write(TLObject.serialize_bytes(self.offset))
        if self.geo is not None:
            buf.write(bytes(self.geo))
        if self.peer_type is not None:
            buf.write(bytes(self.peer_type))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_query = reader.tgread_string()
        _args['query'] = _val_query
        if flags & (1 << 0):
            _val_geo = reader.tgread_object()
            _args['geo'] = _val_geo
        else:
            _args['geo'] = None
        if flags & (1 << 1):
            _val_peer_type = reader.tgread_object()
            _args['peer_type'] = _val_peer_type
        else:
            _args['peer_type'] = None
        _val_offset = reader.tgread_string()
        _args['offset'] = _val_offset
        return cls(**_args)


class UpdateBotInlineSend(TLObject):
    """TL type: updateBotInlineSend"""
    CONSTRUCTOR_ID = 0x12f12a07
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, user_id: int, query: str, id: str, geo: Optional['TypeGeoPoint'] = None, msg_id: Optional['TypeInputBotInlineMessageID'] = None):
        self.user_id = user_id
        self.query = query
        self.id = id
        self.geo = geo
        self.msg_id = msg_id

    def to_dict(self):
        return {
            '_': 'UpdateBotInlineSend',
            'user_id': self.user_id,
            'query': self.query,
            'id': self.id,
            'geo': self.geo,
            'msg_id': self.msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.geo is not None:
            flags |= (1 << 0)
        if self.msg_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(TLObject.serialize_bytes(self.query))
        buf.write(TLObject.serialize_bytes(self.id))
        if self.geo is not None:
            buf.write(bytes(self.geo))
        if self.msg_id is not None:
            buf.write(bytes(self.msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_query = reader.tgread_string()
        _args['query'] = _val_query
        if flags & (1 << 0):
            _val_geo = reader.tgread_object()
            _args['geo'] = _val_geo
        else:
            _args['geo'] = None
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        if flags & (1 << 1):
            _val_msg_id = reader.tgread_object()
            _args['msg_id'] = _val_msg_id
        else:
            _args['msg_id'] = None
        return cls(**_args)


class UpdateBotMenuButton(TLObject):
    """TL type: updateBotMenuButton"""
    CONSTRUCTOR_ID = 0x14b85813
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, bot_id: int, button: 'TypeBotMenuButton'):
        self.bot_id = bot_id
        self.button = button

    def to_dict(self):
        return {
            '_': 'UpdateBotMenuButton',
            'bot_id': self.bot_id,
            'button': self.button,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.bot_id))
        buf.write(bytes(self.button))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot_id = reader.read_long()
        _args['bot_id'] = _val_bot_id
        _val_button = reader.tgread_object()
        _args['button'] = _val_button
        return cls(**_args)


class UpdateBotMessageReaction(TLObject):
    """TL type: updateBotMessageReaction"""
    CONSTRUCTOR_ID = 0xac21d3ce
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', msg_id: int, date: Optional[datetime], actor: 'TypePeer', old_reactions: List['TypeReaction'], new_reactions: List['TypeReaction'], qts: int):
        self.peer = peer
        self.msg_id = msg_id
        self.date = date
        self.actor = actor
        self.old_reactions = old_reactions
        self.new_reactions = new_reactions
        self.qts = qts

    def to_dict(self):
        return {
            '_': 'UpdateBotMessageReaction',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'date': self.date,
            'actor': self.actor,
            'old_reactions': self.old_reactions,
            'new_reactions': self.new_reactions,
            'qts': self.qts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(bytes(self.actor))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.old_reactions)))
        for item in self.old_reactions:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.new_reactions)))
        for item in self.new_reactions:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', self.qts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_actor = reader.tgread_object()
        _args['actor'] = _val_actor
        reader.read_int(signed=False)  # skip vector id
        _count_old_reactions = reader.read_int()
        _list_old_reactions = []
        for _ in range(_count_old_reactions):
            _item_old_reactions = reader.tgread_object()
            _list_old_reactions.append(_item_old_reactions)
        _args['old_reactions'] = _list_old_reactions
        reader.read_int(signed=False)  # skip vector id
        _count_new_reactions = reader.read_int()
        _list_new_reactions = []
        for _ in range(_count_new_reactions):
            _item_new_reactions = reader.tgread_object()
            _list_new_reactions.append(_item_new_reactions)
        _args['new_reactions'] = _list_new_reactions
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateBotMessageReactions(TLObject):
    """TL type: updateBotMessageReactions"""
    CONSTRUCTOR_ID = 0x09cb7759
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', msg_id: int, date: Optional[datetime], reactions: List['TypeReactionCount'], qts: int):
        self.peer = peer
        self.msg_id = msg_id
        self.date = date
        self.reactions = reactions
        self.qts = qts

    def to_dict(self):
        return {
            '_': 'UpdateBotMessageReactions',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'date': self.date,
            'reactions': self.reactions,
            'qts': self.qts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.reactions)))
        for item in self.reactions:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', self.qts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        reader.read_int(signed=False)  # skip vector id
        _count_reactions = reader.read_int()
        _list_reactions = []
        for _ in range(_count_reactions):
            _item_reactions = reader.tgread_object()
            _list_reactions.append(_item_reactions)
        _args['reactions'] = _list_reactions
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateBotNewBusinessMessage(TLObject):
    """TL type: updateBotNewBusinessMessage"""
    CONSTRUCTOR_ID = 0x9ddb347c
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, connection_id: str, message: 'TypeMessage', qts: int, reply_to_message: Optional['TypeMessage'] = None):
        self.connection_id = connection_id
        self.message = message
        self.qts = qts
        self.reply_to_message = reply_to_message

    def to_dict(self):
        return {
            '_': 'UpdateBotNewBusinessMessage',
            'connection_id': self.connection_id,
            'message': self.message,
            'qts': self.qts,
            'reply_to_message': self.reply_to_message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reply_to_message is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.connection_id))
        buf.write(bytes(self.message))
        buf.write(struct.pack('<i', self.qts))
        if self.reply_to_message is not None:
            buf.write(bytes(self.reply_to_message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_connection_id = reader.tgread_string()
        _args['connection_id'] = _val_connection_id
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        if flags & (1 << 0):
            _val_reply_to_message = reader.tgread_object()
            _args['reply_to_message'] = _val_reply_to_message
        else:
            _args['reply_to_message'] = None
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateBotPrecheckoutQuery(TLObject):
    """TL type: updateBotPrecheckoutQuery"""
    CONSTRUCTOR_ID = 0x8caa9a96
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, query_id: int, user_id: int, payload: bytes, currency: str, total_amount: int, info: Optional['TypePaymentRequestedInfo'] = None, shipping_option_id: Optional[str] = None):
        self.query_id = query_id
        self.user_id = user_id
        self.payload = payload
        self.currency = currency
        self.total_amount = total_amount
        self.info = info
        self.shipping_option_id = shipping_option_id

    def to_dict(self):
        return {
            '_': 'UpdateBotPrecheckoutQuery',
            'query_id': self.query_id,
            'user_id': self.user_id,
            'payload': self.payload,
            'currency': self.currency,
            'total_amount': self.total_amount,
            'info': self.info,
            'shipping_option_id': self.shipping_option_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.info is not None:
            flags |= (1 << 0)
        if self.shipping_option_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.query_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(TLObject.serialize_bytes(self.payload))
        buf.write(TLObject.serialize_bytes(self.currency))
        buf.write(struct.pack('<q', self.total_amount))
        if self.info is not None:
            buf.write(bytes(self.info))
        if self.shipping_option_id is not None:
            buf.write(TLObject.serialize_bytes(self.shipping_option_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_payload = reader.tgread_bytes()
        _args['payload'] = _val_payload
        if flags & (1 << 0):
            _val_info = reader.tgread_object()
            _args['info'] = _val_info
        else:
            _args['info'] = None
        if flags & (1 << 1):
            _val_shipping_option_id = reader.tgread_string()
            _args['shipping_option_id'] = _val_shipping_option_id
        else:
            _args['shipping_option_id'] = None
        _val_currency = reader.tgread_string()
        _args['currency'] = _val_currency
        _val_total_amount = reader.read_long()
        _args['total_amount'] = _val_total_amount
        return cls(**_args)


class UpdateBotPurchasedPaidMedia(TLObject):
    """TL type: updateBotPurchasedPaidMedia"""
    CONSTRUCTOR_ID = 0x283bd312
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, user_id: int, payload: str, qts: int):
        self.user_id = user_id
        self.payload = payload
        self.qts = qts

    def to_dict(self):
        return {
            '_': 'UpdateBotPurchasedPaidMedia',
            'user_id': self.user_id,
            'payload': self.payload,
            'qts': self.qts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(TLObject.serialize_bytes(self.payload))
        buf.write(struct.pack('<i', self.qts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_payload = reader.tgread_string()
        _args['payload'] = _val_payload
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateBotShippingQuery(TLObject):
    """TL type: updateBotShippingQuery"""
    CONSTRUCTOR_ID = 0xb5aefd7d
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, query_id: int, user_id: int, payload: bytes, shipping_address: 'TypePostAddress'):
        self.query_id = query_id
        self.user_id = user_id
        self.payload = payload
        self.shipping_address = shipping_address

    def to_dict(self):
        return {
            '_': 'UpdateBotShippingQuery',
            'query_id': self.query_id,
            'user_id': self.user_id,
            'payload': self.payload,
            'shipping_address': self.shipping_address,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.query_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(TLObject.serialize_bytes(self.payload))
        buf.write(bytes(self.shipping_address))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_payload = reader.tgread_bytes()
        _args['payload'] = _val_payload
        _val_shipping_address = reader.tgread_object()
        _args['shipping_address'] = _val_shipping_address
        return cls(**_args)


class UpdateBotStopped(TLObject):
    """TL type: updateBotStopped"""
    CONSTRUCTOR_ID = 0xc4870a49
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, user_id: int, date: Optional[datetime], stopped: bool, qts: int):
        self.user_id = user_id
        self.date = date
        self.stopped = stopped
        self.qts = qts

    def to_dict(self):
        return {
            '_': 'UpdateBotStopped',
            'user_id': self.user_id,
            'date': self.date,
            'stopped': self.stopped,
            'qts': self.qts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<I', 0x997275b5 if self.stopped else 0xbc799737))
        buf.write(struct.pack('<i', self.qts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_stopped = reader.tgread_bool()
        _args['stopped'] = _val_stopped
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateBotSubscriptionExpire(TLObject):
    """TL type: updateBotSubscriptionExpire"""
    CONSTRUCTOR_ID = 0xa8ae3eb1
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, user_id: int, payload: str, until_date: Optional[datetime], qts: int):
        self.user_id = user_id
        self.payload = payload
        self.until_date = until_date
        self.qts = qts

    def to_dict(self):
        return {
            '_': 'UpdateBotSubscriptionExpire',
            'user_id': self.user_id,
            'payload': self.payload,
            'until_date': self.until_date,
            'qts': self.qts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(TLObject.serialize_bytes(self.payload))
        buf.write(struct.pack('<i', self.until_date))
        buf.write(struct.pack('<i', self.qts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_payload = reader.tgread_string()
        _args['payload'] = _val_payload
        _val_until_date = reader.read_int()
        _args['until_date'] = _val_until_date
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateBotWebhookJson(TLObject):
    """TL type: updateBotWebhookJSON"""
    CONSTRUCTOR_ID = 0x8317c0c3
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, data: 'TypeDataJSON'):
        self.data = data

    def to_dict(self):
        return {
            '_': 'UpdateBotWebhookJson',
            'data': self.data,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_data = reader.tgread_object()
        _args['data'] = _val_data
        return cls(**_args)


class UpdateBotWebhookJsonquery(TLObject):
    """TL type: updateBotWebhookJSONQuery"""
    CONSTRUCTOR_ID = 0x9b9240a6
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, query_id: int, data: 'TypeDataJSON', timeout: int):
        self.query_id = query_id
        self.data = data
        self.timeout = timeout

    def to_dict(self):
        return {
            '_': 'UpdateBotWebhookJsonquery',
            'query_id': self.query_id,
            'data': self.data,
            'timeout': self.timeout,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.query_id))
        buf.write(bytes(self.data))
        buf.write(struct.pack('<i', self.timeout))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        _val_data = reader.tgread_object()
        _args['data'] = _val_data
        _val_timeout = reader.read_int()
        _args['timeout'] = _val_timeout
        return cls(**_args)


class UpdateBusinessBotCallbackQuery(TLObject):
    """TL type: updateBusinessBotCallbackQuery"""
    CONSTRUCTOR_ID = 0x1ea2fda7
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, query_id: int, user_id: int, connection_id: str, message: 'TypeMessage', chat_instance: int, reply_to_message: Optional['TypeMessage'] = None, data: Optional[bytes] = None):
        self.query_id = query_id
        self.user_id = user_id
        self.connection_id = connection_id
        self.message = message
        self.chat_instance = chat_instance
        self.reply_to_message = reply_to_message
        self.data = data

    def to_dict(self):
        return {
            '_': 'UpdateBusinessBotCallbackQuery',
            'query_id': self.query_id,
            'user_id': self.user_id,
            'connection_id': self.connection_id,
            'message': self.message,
            'chat_instance': self.chat_instance,
            'reply_to_message': self.reply_to_message,
            'data': self.data,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reply_to_message is not None:
            flags |= (1 << 2)
        if self.data is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.query_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(TLObject.serialize_bytes(self.connection_id))
        buf.write(bytes(self.message))
        buf.write(struct.pack('<q', self.chat_instance))
        if self.reply_to_message is not None:
            buf.write(bytes(self.reply_to_message))
        if self.data is not None:
            buf.write(TLObject.serialize_bytes(self.data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_connection_id = reader.tgread_string()
        _args['connection_id'] = _val_connection_id
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        if flags & (1 << 2):
            _val_reply_to_message = reader.tgread_object()
            _args['reply_to_message'] = _val_reply_to_message
        else:
            _args['reply_to_message'] = None
        _val_chat_instance = reader.read_long()
        _args['chat_instance'] = _val_chat_instance
        if flags & (1 << 0):
            _val_data = reader.tgread_bytes()
            _args['data'] = _val_data
        else:
            _args['data'] = None
        return cls(**_args)


class UpdateChannel(TLObject):
    """TL type: updateChannel"""
    CONSTRUCTOR_ID = 0x635b4c09
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int):
        self.channel_id = channel_id

    def to_dict(self):
        return {
            '_': 'UpdateChannel',
            'channel_id': self.channel_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        return cls(**_args)


class UpdateChannelAvailableMessages(TLObject):
    """TL type: updateChannelAvailableMessages"""
    CONSTRUCTOR_ID = 0xb23fc698
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, available_min_id: int):
        self.channel_id = channel_id
        self.available_min_id = available_min_id

    def to_dict(self):
        return {
            '_': 'UpdateChannelAvailableMessages',
            'channel_id': self.channel_id,
            'available_min_id': self.available_min_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', self.available_min_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_available_min_id = reader.read_int()
        _args['available_min_id'] = _val_available_min_id
        return cls(**_args)


class UpdateChannelMessageForwards(TLObject):
    """TL type: updateChannelMessageForwards"""
    CONSTRUCTOR_ID = 0xd29a27f4
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, id: int, forwards: int):
        self.channel_id = channel_id
        self.id = id
        self.forwards = forwards

    def to_dict(self):
        return {
            '_': 'UpdateChannelMessageForwards',
            'channel_id': self.channel_id,
            'id': self.id,
            'forwards': self.forwards,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<i', self.forwards))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_forwards = reader.read_int()
        _args['forwards'] = _val_forwards
        return cls(**_args)


class UpdateChannelMessageViews(TLObject):
    """TL type: updateChannelMessageViews"""
    CONSTRUCTOR_ID = 0xf226ac08
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, id: int, views: int):
        self.channel_id = channel_id
        self.id = id
        self.views = views

    def to_dict(self):
        return {
            '_': 'UpdateChannelMessageViews',
            'channel_id': self.channel_id,
            'id': self.id,
            'views': self.views,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<i', self.views))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_views = reader.read_int()
        _args['views'] = _val_views
        return cls(**_args)


class UpdateChannelParticipant(TLObject):
    """TL type: updateChannelParticipant"""
    CONSTRUCTOR_ID = 0x985d3abb
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, date: Optional[datetime], actor_id: int, user_id: int, qts: int, via_chatlist: Optional[bool] = None, prev_participant: Optional['TypeChannelParticipant'] = None, new_participant: Optional['TypeChannelParticipant'] = None, invite: Optional['TypeExportedChatInvite'] = None):
        self.channel_id = channel_id
        self.date = date
        self.actor_id = actor_id
        self.user_id = user_id
        self.qts = qts
        self.via_chatlist = via_chatlist
        self.prev_participant = prev_participant
        self.new_participant = new_participant
        self.invite = invite

    def to_dict(self):
        return {
            '_': 'UpdateChannelParticipant',
            'channel_id': self.channel_id,
            'date': self.date,
            'actor_id': self.actor_id,
            'user_id': self.user_id,
            'qts': self.qts,
            'via_chatlist': self.via_chatlist,
            'prev_participant': self.prev_participant,
            'new_participant': self.new_participant,
            'invite': self.invite,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.via_chatlist:
            flags |= (1 << 3)
        if self.prev_participant is not None:
            flags |= (1 << 0)
        if self.new_participant is not None:
            flags |= (1 << 1)
        if self.invite is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.actor_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.qts))
        if self.prev_participant is not None:
            buf.write(bytes(self.prev_participant))
        if self.new_participant is not None:
            buf.write(bytes(self.new_participant))
        if self.invite is not None:
            buf.write(bytes(self.invite))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['via_chatlist'] = bool(flags & (1 << 3))
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_actor_id = reader.read_long()
        _args['actor_id'] = _val_actor_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        if flags & (1 << 0):
            _val_prev_participant = reader.tgread_object()
            _args['prev_participant'] = _val_prev_participant
        else:
            _args['prev_participant'] = None
        if flags & (1 << 1):
            _val_new_participant = reader.tgread_object()
            _args['new_participant'] = _val_new_participant
        else:
            _args['new_participant'] = None
        if flags & (1 << 2):
            _val_invite = reader.tgread_object()
            _args['invite'] = _val_invite
        else:
            _args['invite'] = None
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateChannelReadMessagesContents(TLObject):
    """TL type: updateChannelReadMessagesContents"""
    CONSTRUCTOR_ID = 0x25f324f7
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, messages: List[int], top_msg_id: Optional[int] = None, saved_peer_id: Optional['TypePeer'] = None):
        self.channel_id = channel_id
        self.messages = messages
        self.top_msg_id = top_msg_id
        self.saved_peer_id = saved_peer_id

    def to_dict(self):
        return {
            '_': 'UpdateChannelReadMessagesContents',
            'channel_id': self.channel_id,
            'messages': self.messages,
            'top_msg_id': self.top_msg_id,
            'saved_peer_id': self.saved_peer_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.top_msg_id is not None:
            flags |= (1 << 0)
        if self.saved_peer_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.messages)))
        for item in self.messages:
            buf.write(struct.pack('<i', self.item))
        if self.top_msg_id is not None:
            buf.write(struct.pack('<i', self.top_msg_id))
        if self.saved_peer_id is not None:
            buf.write(bytes(self.saved_peer_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        if flags & (1 << 0):
            _val_top_msg_id = reader.read_int()
            _args['top_msg_id'] = _val_top_msg_id
        else:
            _args['top_msg_id'] = None
        if flags & (1 << 1):
            _val_saved_peer_id = reader.tgread_object()
            _args['saved_peer_id'] = _val_saved_peer_id
        else:
            _args['saved_peer_id'] = None
        reader.read_int(signed=False)  # skip vector id
        _count_messages = reader.read_int()
        _list_messages = []
        for _ in range(_count_messages):
            _item_messages = reader.read_int()
            _list_messages.append(_item_messages)
        _args['messages'] = _list_messages
        return cls(**_args)


class UpdateChannelTooLong(TLObject):
    """TL type: updateChannelTooLong"""
    CONSTRUCTOR_ID = 0x108d941f
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, pts: Optional[int] = None):
        self.channel_id = channel_id
        self.pts = pts

    def to_dict(self):
        return {
            '_': 'UpdateChannelTooLong',
            'channel_id': self.channel_id,
            'pts': self.pts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.pts is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.channel_id))
        if self.pts is not None:
            buf.write(struct.pack('<i', self.pts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        if flags & (1 << 0):
            _val_pts = reader.read_int()
            _args['pts'] = _val_pts
        else:
            _args['pts'] = None
        return cls(**_args)


class UpdateChannelUserTyping(TLObject):
    """TL type: updateChannelUserTyping"""
    CONSTRUCTOR_ID = 0x8c88c923
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, from_id: 'TypePeer', action: 'TypeSendMessageAction', top_msg_id: Optional[int] = None):
        self.channel_id = channel_id
        self.from_id = from_id
        self.action = action
        self.top_msg_id = top_msg_id

    def to_dict(self):
        return {
            '_': 'UpdateChannelUserTyping',
            'channel_id': self.channel_id,
            'from_id': self.from_id,
            'action': self.action,
            'top_msg_id': self.top_msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.top_msg_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(bytes(self.from_id))
        buf.write(bytes(self.action))
        if self.top_msg_id is not None:
            buf.write(struct.pack('<i', self.top_msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        if flags & (1 << 0):
            _val_top_msg_id = reader.read_int()
            _args['top_msg_id'] = _val_top_msg_id
        else:
            _args['top_msg_id'] = None
        _val_from_id = reader.tgread_object()
        _args['from_id'] = _val_from_id
        _val_action = reader.tgread_object()
        _args['action'] = _val_action
        return cls(**_args)


class UpdateChannelViewForumAsMessages(TLObject):
    """TL type: updateChannelViewForumAsMessages"""
    CONSTRUCTOR_ID = 0x07b68920
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, enabled: bool):
        self.channel_id = channel_id
        self.enabled = enabled

    def to_dict(self):
        return {
            '_': 'UpdateChannelViewForumAsMessages',
            'channel_id': self.channel_id,
            'enabled': self.enabled,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<I', 0x997275b5 if self.enabled else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_enabled = reader.tgread_bool()
        _args['enabled'] = _val_enabled
        return cls(**_args)


class UpdateChannelWebPage(TLObject):
    """TL type: updateChannelWebPage"""
    CONSTRUCTOR_ID = 0x2f2ba99f
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, webpage: 'TypeWebPage', pts: int, pts_count: int):
        self.channel_id = channel_id
        self.webpage = webpage
        self.pts = pts
        self.pts_count = pts_count

    def to_dict(self):
        return {
            '_': 'UpdateChannelWebPage',
            'channel_id': self.channel_id,
            'webpage': self.webpage,
            'pts': self.pts,
            'pts_count': self.pts_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(bytes(self.webpage))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_webpage = reader.tgread_object()
        _args['webpage'] = _val_webpage
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdateChat(TLObject):
    """TL type: updateChat"""
    CONSTRUCTOR_ID = 0xf89a6a4e
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, chat_id: int):
        self.chat_id = chat_id

    def to_dict(self):
        return {
            '_': 'UpdateChat',
            'chat_id': self.chat_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.chat_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        return cls(**_args)


class UpdateChatDefaultBannedRights(TLObject):
    """TL type: updateChatDefaultBannedRights"""
    CONSTRUCTOR_ID = 0x54c01850
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', default_banned_rights: 'TypeChatBannedRights', version: int):
        self.peer = peer
        self.default_banned_rights = default_banned_rights
        self.version = version

    def to_dict(self):
        return {
            '_': 'UpdateChatDefaultBannedRights',
            'peer': self.peer,
            'default_banned_rights': self.default_banned_rights,
            'version': self.version,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.default_banned_rights))
        buf.write(struct.pack('<i', self.version))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_default_banned_rights = reader.tgread_object()
        _args['default_banned_rights'] = _val_default_banned_rights
        _val_version = reader.read_int()
        _args['version'] = _val_version
        return cls(**_args)


class UpdateChatParticipant(TLObject):
    """TL type: updateChatParticipant"""
    CONSTRUCTOR_ID = 0xd087663a
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, chat_id: int, date: Optional[datetime], actor_id: int, user_id: int, qts: int, prev_participant: Optional['TypeChatParticipant'] = None, new_participant: Optional['TypeChatParticipant'] = None, invite: Optional['TypeExportedChatInvite'] = None):
        self.chat_id = chat_id
        self.date = date
        self.actor_id = actor_id
        self.user_id = user_id
        self.qts = qts
        self.prev_participant = prev_participant
        self.new_participant = new_participant
        self.invite = invite

    def to_dict(self):
        return {
            '_': 'UpdateChatParticipant',
            'chat_id': self.chat_id,
            'date': self.date,
            'actor_id': self.actor_id,
            'user_id': self.user_id,
            'qts': self.qts,
            'prev_participant': self.prev_participant,
            'new_participant': self.new_participant,
            'invite': self.invite,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.prev_participant is not None:
            flags |= (1 << 0)
        if self.new_participant is not None:
            flags |= (1 << 1)
        if self.invite is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.chat_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<q', self.actor_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.qts))
        if self.prev_participant is not None:
            buf.write(bytes(self.prev_participant))
        if self.new_participant is not None:
            buf.write(bytes(self.new_participant))
        if self.invite is not None:
            buf.write(bytes(self.invite))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_actor_id = reader.read_long()
        _args['actor_id'] = _val_actor_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        if flags & (1 << 0):
            _val_prev_participant = reader.tgread_object()
            _args['prev_participant'] = _val_prev_participant
        else:
            _args['prev_participant'] = None
        if flags & (1 << 1):
            _val_new_participant = reader.tgread_object()
            _args['new_participant'] = _val_new_participant
        else:
            _args['new_participant'] = None
        if flags & (1 << 2):
            _val_invite = reader.tgread_object()
            _args['invite'] = _val_invite
        else:
            _args['invite'] = None
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateChatParticipantAdd(TLObject):
    """TL type: updateChatParticipantAdd"""
    CONSTRUCTOR_ID = 0x3dda5451
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, chat_id: int, user_id: int, inviter_id: int, date: Optional[datetime], version: int):
        self.chat_id = chat_id
        self.user_id = user_id
        self.inviter_id = inviter_id
        self.date = date
        self.version = version

    def to_dict(self):
        return {
            '_': 'UpdateChatParticipantAdd',
            'chat_id': self.chat_id,
            'user_id': self.user_id,
            'inviter_id': self.inviter_id,
            'date': self.date,
            'version': self.version,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.chat_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<q', self.inviter_id))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.version))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_inviter_id = reader.read_long()
        _args['inviter_id'] = _val_inviter_id
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_version = reader.read_int()
        _args['version'] = _val_version
        return cls(**_args)


class UpdateChatParticipantAdmin(TLObject):
    """TL type: updateChatParticipantAdmin"""
    CONSTRUCTOR_ID = 0xd7ca61a2
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, chat_id: int, user_id: int, is_admin: bool, version: int):
        self.chat_id = chat_id
        self.user_id = user_id
        self.is_admin = is_admin
        self.version = version

    def to_dict(self):
        return {
            '_': 'UpdateChatParticipantAdmin',
            'chat_id': self.chat_id,
            'user_id': self.user_id,
            'is_admin': self.is_admin,
            'version': self.version,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.chat_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<I', 0x997275b5 if self.is_admin else 0xbc799737))
        buf.write(struct.pack('<i', self.version))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_is_admin = reader.tgread_bool()
        _args['is_admin'] = _val_is_admin
        _val_version = reader.read_int()
        _args['version'] = _val_version
        return cls(**_args)


class UpdateChatParticipantDelete(TLObject):
    """TL type: updateChatParticipantDelete"""
    CONSTRUCTOR_ID = 0xe32f3d77
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, chat_id: int, user_id: int, version: int):
        self.chat_id = chat_id
        self.user_id = user_id
        self.version = version

    def to_dict(self):
        return {
            '_': 'UpdateChatParticipantDelete',
            'chat_id': self.chat_id,
            'user_id': self.user_id,
            'version': self.version,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.chat_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(struct.pack('<i', self.version))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_version = reader.read_int()
        _args['version'] = _val_version
        return cls(**_args)


class UpdateChatParticipants(TLObject):
    """TL type: updateChatParticipants"""
    CONSTRUCTOR_ID = 0x07761198
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, participants: 'TypeChatParticipants'):
        self.participants = participants

    def to_dict(self):
        return {
            '_': 'UpdateChatParticipants',
            'participants': self.participants,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.participants))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_participants = reader.tgread_object()
        _args['participants'] = _val_participants
        return cls(**_args)


class UpdateChatUserTyping(TLObject):
    """TL type: updateChatUserTyping"""
    CONSTRUCTOR_ID = 0x83487af0
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, chat_id: int, from_id: 'TypePeer', action: 'TypeSendMessageAction'):
        self.chat_id = chat_id
        self.from_id = from_id
        self.action = action

    def to_dict(self):
        return {
            '_': 'UpdateChatUserTyping',
            'chat_id': self.chat_id,
            'from_id': self.from_id,
            'action': self.action,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.chat_id))
        buf.write(bytes(self.from_id))
        buf.write(bytes(self.action))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        _val_from_id = reader.tgread_object()
        _args['from_id'] = _val_from_id
        _val_action = reader.tgread_object()
        _args['action'] = _val_action
        return cls(**_args)


class UpdateConfig(TLObject):
    """TL type: updateConfig"""
    CONSTRUCTOR_ID = 0xa229dd06
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateConfig',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateContactsReset(TLObject):
    """TL type: updateContactsReset"""
    CONSTRUCTOR_ID = 0x7084a7be
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateContactsReset',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateDcOptions(TLObject):
    """TL type: updateDcOptions"""
    CONSTRUCTOR_ID = 0x8e5e9873
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, dc_options: List['TypeDcOption']):
        self.dc_options = dc_options

    def to_dict(self):
        return {
            '_': 'UpdateDcOptions',
            'dc_options': self.dc_options,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.dc_options)))
        for item in self.dc_options:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_dc_options = reader.read_int()
        _list_dc_options = []
        for _ in range(_count_dc_options):
            _item_dc_options = reader.tgread_object()
            _list_dc_options.append(_item_dc_options)
        _args['dc_options'] = _list_dc_options
        return cls(**_args)


class UpdateDeleteChannelMessages(TLObject):
    """TL type: updateDeleteChannelMessages"""
    CONSTRUCTOR_ID = 0xc32d5b12
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, messages: List[int], pts: int, pts_count: int):
        self.channel_id = channel_id
        self.messages = messages
        self.pts = pts
        self.pts_count = pts_count

    def to_dict(self):
        return {
            '_': 'UpdateDeleteChannelMessages',
            'channel_id': self.channel_id,
            'messages': self.messages,
            'pts': self.pts,
            'pts_count': self.pts_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.messages)))
        for item in self.messages:
            buf.write(struct.pack('<i', self.item))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        reader.read_int(signed=False)  # skip vector id
        _count_messages = reader.read_int()
        _list_messages = []
        for _ in range(_count_messages):
            _item_messages = reader.read_int()
            _list_messages.append(_item_messages)
        _args['messages'] = _list_messages
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdateDeleteGroupCallMessages(TLObject):
    """TL type: updateDeleteGroupCallMessages"""
    CONSTRUCTOR_ID = 0x3e85e92c
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, call: 'TypeInputGroupCall', messages: List[int]):
        self.call = call
        self.messages = messages

    def to_dict(self):
        return {
            '_': 'UpdateDeleteGroupCallMessages',
            'call': self.call,
            'messages': self.messages,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.call))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.messages)))
        for item in self.messages:
            buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        reader.read_int(signed=False)  # skip vector id
        _count_messages = reader.read_int()
        _list_messages = []
        for _ in range(_count_messages):
            _item_messages = reader.read_int()
            _list_messages.append(_item_messages)
        _args['messages'] = _list_messages
        return cls(**_args)


class UpdateDeleteMessages(TLObject):
    """TL type: updateDeleteMessages"""
    CONSTRUCTOR_ID = 0xa20db0e5
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, messages: List[int], pts: int, pts_count: int):
        self.messages = messages
        self.pts = pts
        self.pts_count = pts_count

    def to_dict(self):
        return {
            '_': 'UpdateDeleteMessages',
            'messages': self.messages,
            'pts': self.pts,
            'pts_count': self.pts_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.messages)))
        for item in self.messages:
            buf.write(struct.pack('<i', self.item))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_messages = reader.read_int()
        _list_messages = []
        for _ in range(_count_messages):
            _item_messages = reader.read_int()
            _list_messages.append(_item_messages)
        _args['messages'] = _list_messages
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdateDeleteQuickReply(TLObject):
    """TL type: updateDeleteQuickReply"""
    CONSTRUCTOR_ID = 0x53e6f1ec
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, shortcut_id: int):
        self.shortcut_id = shortcut_id

    def to_dict(self):
        return {
            '_': 'UpdateDeleteQuickReply',
            'shortcut_id': self.shortcut_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.shortcut_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_shortcut_id = reader.read_int()
        _args['shortcut_id'] = _val_shortcut_id
        return cls(**_args)


class UpdateDeleteQuickReplyMessages(TLObject):
    """TL type: updateDeleteQuickReplyMessages"""
    CONSTRUCTOR_ID = 0x566fe7cd
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, shortcut_id: int, messages: List[int]):
        self.shortcut_id = shortcut_id
        self.messages = messages

    def to_dict(self):
        return {
            '_': 'UpdateDeleteQuickReplyMessages',
            'shortcut_id': self.shortcut_id,
            'messages': self.messages,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.shortcut_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.messages)))
        for item in self.messages:
            buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_shortcut_id = reader.read_int()
        _args['shortcut_id'] = _val_shortcut_id
        reader.read_int(signed=False)  # skip vector id
        _count_messages = reader.read_int()
        _list_messages = []
        for _ in range(_count_messages):
            _item_messages = reader.read_int()
            _list_messages.append(_item_messages)
        _args['messages'] = _list_messages
        return cls(**_args)


class UpdateDeleteScheduledMessages(TLObject):
    """TL type: updateDeleteScheduledMessages"""
    CONSTRUCTOR_ID = 0xf2a71983
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', messages: List[int], sent_messages: Optional[List[int]] = None):
        self.peer = peer
        self.messages = messages
        self.sent_messages = sent_messages

    def to_dict(self):
        return {
            '_': 'UpdateDeleteScheduledMessages',
            'peer': self.peer,
            'messages': self.messages,
            'sent_messages': self.sent_messages,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.sent_messages is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.messages)))
        for item in self.messages:
            buf.write(struct.pack('<i', self.item))
        if self.sent_messages is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.sent_messages)))
            for item in self.sent_messages:
                buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        reader.read_int(signed=False)  # skip vector id
        _count_messages = reader.read_int()
        _list_messages = []
        for _ in range(_count_messages):
            _item_messages = reader.read_int()
            _list_messages.append(_item_messages)
        _args['messages'] = _list_messages
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_sent_messages = reader.read_int()
            _list_sent_messages = []
            for _ in range(_count_sent_messages):
                _item_sent_messages = reader.read_int()
                _list_sent_messages.append(_item_sent_messages)
            _args['sent_messages'] = _list_sent_messages
        else:
            _args['sent_messages'] = None
        return cls(**_args)


class UpdateDialogFilter(TLObject):
    """TL type: updateDialogFilter"""
    CONSTRUCTOR_ID = 0x26ffde7d
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, id: int, filter: Optional['TypeDialogFilter'] = None):
        self.id = id
        self.filter = filter

    def to_dict(self):
        return {
            '_': 'UpdateDialogFilter',
            'id': self.id,
            'filter': self.filter,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.filter is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        if self.filter is not None:
            buf.write(bytes(self.filter))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.read_int()
        _args['id'] = _val_id
        if flags & (1 << 0):
            _val_filter = reader.tgread_object()
            _args['filter'] = _val_filter
        else:
            _args['filter'] = None
        return cls(**_args)


class UpdateDialogFilterOrder(TLObject):
    """TL type: updateDialogFilterOrder"""
    CONSTRUCTOR_ID = 0xa5d72105
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, order: List[int]):
        self.order = order

    def to_dict(self):
        return {
            '_': 'UpdateDialogFilterOrder',
            'order': self.order,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.order)))
        for item in self.order:
            buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_order = reader.read_int()
        _list_order = []
        for _ in range(_count_order):
            _item_order = reader.read_int()
            _list_order.append(_item_order)
        _args['order'] = _list_order
        return cls(**_args)


class UpdateDialogFilters(TLObject):
    """TL type: updateDialogFilters"""
    CONSTRUCTOR_ID = 0x3504914f
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateDialogFilters',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateDialogPinned(TLObject):
    """TL type: updateDialogPinned"""
    CONSTRUCTOR_ID = 0x6e6fe51c
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypeDialogPeer', pinned: Optional[bool] = None, folder_id: Optional[int] = None):
        self.peer = peer
        self.pinned = pinned
        self.folder_id = folder_id

    def to_dict(self):
        return {
            '_': 'UpdateDialogPinned',
            'peer': self.peer,
            'pinned': self.pinned,
            'folder_id': self.folder_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.pinned:
            flags |= (1 << 0)
        if self.folder_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        if self.folder_id is not None:
            buf.write(struct.pack('<i', self.folder_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['pinned'] = bool(flags & (1 << 0))
        if flags & (1 << 1):
            _val_folder_id = reader.read_int()
            _args['folder_id'] = _val_folder_id
        else:
            _args['folder_id'] = None
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class UpdateDialogUnreadMark(TLObject):
    """TL type: updateDialogUnreadMark"""
    CONSTRUCTOR_ID = 0xb658f23e
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypeDialogPeer', unread: Optional[bool] = None, saved_peer_id: Optional['TypePeer'] = None):
        self.peer = peer
        self.unread = unread
        self.saved_peer_id = saved_peer_id

    def to_dict(self):
        return {
            '_': 'UpdateDialogUnreadMark',
            'peer': self.peer,
            'unread': self.unread,
            'saved_peer_id': self.saved_peer_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.unread:
            flags |= (1 << 0)
        if self.saved_peer_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        if self.saved_peer_id is not None:
            buf.write(bytes(self.saved_peer_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['unread'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 1):
            _val_saved_peer_id = reader.tgread_object()
            _args['saved_peer_id'] = _val_saved_peer_id
        else:
            _args['saved_peer_id'] = None
        return cls(**_args)


class UpdateDraftMessage(TLObject):
    """TL type: updateDraftMessage"""
    CONSTRUCTOR_ID = 0xedfc111e
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', draft: 'TypeDraftMessage', top_msg_id: Optional[int] = None, saved_peer_id: Optional['TypePeer'] = None):
        self.peer = peer
        self.draft = draft
        self.top_msg_id = top_msg_id
        self.saved_peer_id = saved_peer_id

    def to_dict(self):
        return {
            '_': 'UpdateDraftMessage',
            'peer': self.peer,
            'draft': self.draft,
            'top_msg_id': self.top_msg_id,
            'saved_peer_id': self.saved_peer_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.top_msg_id is not None:
            flags |= (1 << 0)
        if self.saved_peer_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.draft))
        if self.top_msg_id is not None:
            buf.write(struct.pack('<i', self.top_msg_id))
        if self.saved_peer_id is not None:
            buf.write(bytes(self.saved_peer_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _val_top_msg_id = reader.read_int()
            _args['top_msg_id'] = _val_top_msg_id
        else:
            _args['top_msg_id'] = None
        if flags & (1 << 1):
            _val_saved_peer_id = reader.tgread_object()
            _args['saved_peer_id'] = _val_saved_peer_id
        else:
            _args['saved_peer_id'] = None
        _val_draft = reader.tgread_object()
        _args['draft'] = _val_draft
        return cls(**_args)


class UpdateEditChannelMessage(TLObject):
    """TL type: updateEditChannelMessage"""
    CONSTRUCTOR_ID = 0x1b3f4df7
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, message: 'TypeMessage', pts: int, pts_count: int):
        self.message = message
        self.pts = pts
        self.pts_count = pts_count

    def to_dict(self):
        return {
            '_': 'UpdateEditChannelMessage',
            'message': self.message,
            'pts': self.pts,
            'pts_count': self.pts_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdateEditMessage(TLObject):
    """TL type: updateEditMessage"""
    CONSTRUCTOR_ID = 0xe40370a3
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, message: 'TypeMessage', pts: int, pts_count: int):
        self.message = message
        self.pts = pts
        self.pts_count = pts_count

    def to_dict(self):
        return {
            '_': 'UpdateEditMessage',
            'message': self.message,
            'pts': self.pts,
            'pts_count': self.pts_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdateEmojiGameInfo(TLObject):
    """TL type: updateEmojiGameInfo"""
    CONSTRUCTOR_ID = 0xfb9c547a
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, info: 'TypeEmojiGameInfo'):
        self.info = info

    def to_dict(self):
        return {
            '_': 'UpdateEmojiGameInfo',
            'info': self.info,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.info))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_info = reader.tgread_object()
        _args['info'] = _val_info
        return cls(**_args)


class UpdateEncryptedChatTyping(TLObject):
    """TL type: updateEncryptedChatTyping"""
    CONSTRUCTOR_ID = 0x1710f156
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, chat_id: int):
        self.chat_id = chat_id

    def to_dict(self):
        return {
            '_': 'UpdateEncryptedChatTyping',
            'chat_id': self.chat_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.chat_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_int()
        _args['chat_id'] = _val_chat_id
        return cls(**_args)


class UpdateEncryptedMessagesRead(TLObject):
    """TL type: updateEncryptedMessagesRead"""
    CONSTRUCTOR_ID = 0x38fe25b7
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, chat_id: int, max_date: Optional[datetime], date: Optional[datetime]):
        self.chat_id = chat_id
        self.max_date = max_date
        self.date = date

    def to_dict(self):
        return {
            '_': 'UpdateEncryptedMessagesRead',
            'chat_id': self.chat_id,
            'max_date': self.max_date,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.chat_id))
        buf.write(struct.pack('<i', self.max_date))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_int()
        _args['chat_id'] = _val_chat_id
        _val_max_date = reader.read_int()
        _args['max_date'] = _val_max_date
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class UpdateEncryption(TLObject):
    """TL type: updateEncryption"""
    CONSTRUCTOR_ID = 0xb4a2e88d
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, chat: 'TypeEncryptedChat', date: Optional[datetime]):
        self.chat = chat
        self.date = date

    def to_dict(self):
        return {
            '_': 'UpdateEncryption',
            'chat': self.chat,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.chat))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat = reader.tgread_object()
        _args['chat'] = _val_chat
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class UpdateFavedStickers(TLObject):
    """TL type: updateFavedStickers"""
    CONSTRUCTOR_ID = 0xe511996d
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateFavedStickers',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateFolderPeers(TLObject):
    """TL type: updateFolderPeers"""
    CONSTRUCTOR_ID = 0x19360dc0
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, folder_peers: List['TypeFolderPeer'], pts: int, pts_count: int):
        self.folder_peers = folder_peers
        self.pts = pts
        self.pts_count = pts_count

    def to_dict(self):
        return {
            '_': 'UpdateFolderPeers',
            'folder_peers': self.folder_peers,
            'pts': self.pts,
            'pts_count': self.pts_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.folder_peers)))
        for item in self.folder_peers:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_folder_peers = reader.read_int()
        _list_folder_peers = []
        for _ in range(_count_folder_peers):
            _item_folder_peers = reader.tgread_object()
            _list_folder_peers.append(_item_folder_peers)
        _args['folder_peers'] = _list_folder_peers
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdateGeoLiveViewed(TLObject):
    """TL type: updateGeoLiveViewed"""
    CONSTRUCTOR_ID = 0x871fb939
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', msg_id: int):
        self.peer = peer
        self.msg_id = msg_id

    def to_dict(self):
        return {
            '_': 'UpdateGeoLiveViewed',
            'peer': self.peer,
            'msg_id': self.msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        return cls(**_args)


class UpdateGroupCall(TLObject):
    """TL type: updateGroupCall"""
    CONSTRUCTOR_ID = 0x9d2216e0
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, call: 'TypeGroupCall', live_story: Optional[bool] = None, peer: Optional['TypePeer'] = None):
        self.call = call
        self.live_story = live_story
        self.peer = peer

    def to_dict(self):
        return {
            '_': 'UpdateGroupCall',
            'call': self.call,
            'live_story': self.live_story,
            'peer': self.peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.live_story:
            flags |= (1 << 2)
        if self.peer is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.call))
        if self.peer is not None:
            buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['live_story'] = bool(flags & (1 << 2))
        if flags & (1 << 1):
            _val_peer = reader.tgread_object()
            _args['peer'] = _val_peer
        else:
            _args['peer'] = None
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        return cls(**_args)


class UpdateGroupCallChainBlocks(TLObject):
    """TL type: updateGroupCallChainBlocks"""
    CONSTRUCTOR_ID = 0xa477288f
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, call: 'TypeInputGroupCall', sub_chain_id: int, blocks: List[bytes], next_offset: int):
        self.call = call
        self.sub_chain_id = sub_chain_id
        self.blocks = blocks
        self.next_offset = next_offset

    def to_dict(self):
        return {
            '_': 'UpdateGroupCallChainBlocks',
            'call': self.call,
            'sub_chain_id': self.sub_chain_id,
            'blocks': self.blocks,
            'next_offset': self.next_offset,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.call))
        buf.write(struct.pack('<i', self.sub_chain_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.blocks)))
        for item in self.blocks:
            buf.write(TLObject.serialize_bytes(self.item))
        buf.write(struct.pack('<i', self.next_offset))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_sub_chain_id = reader.read_int()
        _args['sub_chain_id'] = _val_sub_chain_id
        reader.read_int(signed=False)  # skip vector id
        _count_blocks = reader.read_int()
        _list_blocks = []
        for _ in range(_count_blocks):
            _item_blocks = reader.tgread_bytes()
            _list_blocks.append(_item_blocks)
        _args['blocks'] = _list_blocks
        _val_next_offset = reader.read_int()
        _args['next_offset'] = _val_next_offset
        return cls(**_args)


class UpdateGroupCallConnection(TLObject):
    """TL type: updateGroupCallConnection"""
    CONSTRUCTOR_ID = 0x0b783982
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, params: 'TypeDataJSON', presentation: Optional[bool] = None):
        self.params = params
        self.presentation = presentation

    def to_dict(self):
        return {
            '_': 'UpdateGroupCallConnection',
            'params': self.params,
            'presentation': self.presentation,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.presentation:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.params))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['presentation'] = bool(flags & (1 << 0))
        _val_params = reader.tgread_object()
        _args['params'] = _val_params
        return cls(**_args)


class UpdateGroupCallEncryptedMessage(TLObject):
    """TL type: updateGroupCallEncryptedMessage"""
    CONSTRUCTOR_ID = 0xc957a766
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, call: 'TypeInputGroupCall', from_id: 'TypePeer', encrypted_message: bytes):
        self.call = call
        self.from_id = from_id
        self.encrypted_message = encrypted_message

    def to_dict(self):
        return {
            '_': 'UpdateGroupCallEncryptedMessage',
            'call': self.call,
            'from_id': self.from_id,
            'encrypted_message': self.encrypted_message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.call))
        buf.write(bytes(self.from_id))
        buf.write(TLObject.serialize_bytes(self.encrypted_message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_from_id = reader.tgread_object()
        _args['from_id'] = _val_from_id
        _val_encrypted_message = reader.tgread_bytes()
        _args['encrypted_message'] = _val_encrypted_message
        return cls(**_args)


class UpdateGroupCallMessage(TLObject):
    """TL type: updateGroupCallMessage"""
    CONSTRUCTOR_ID = 0xd8326f0d
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, call: 'TypeInputGroupCall', message: 'TypeGroupCallMessage'):
        self.call = call
        self.message = message

    def to_dict(self):
        return {
            '_': 'UpdateGroupCallMessage',
            'call': self.call,
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.call))
        buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        return cls(**_args)


class UpdateGroupCallParticipants(TLObject):
    """TL type: updateGroupCallParticipants"""
    CONSTRUCTOR_ID = 0xf2ebdb4e
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, call: 'TypeInputGroupCall', participants: List['TypeGroupCallParticipant'], version: int):
        self.call = call
        self.participants = participants
        self.version = version

    def to_dict(self):
        return {
            '_': 'UpdateGroupCallParticipants',
            'call': self.call,
            'participants': self.participants,
            'version': self.version,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.call))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.participants)))
        for item in self.participants:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', self.version))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_call = reader.tgread_object()
        _args['call'] = _val_call
        reader.read_int(signed=False)  # skip vector id
        _count_participants = reader.read_int()
        _list_participants = []
        for _ in range(_count_participants):
            _item_participants = reader.tgread_object()
            _list_participants.append(_item_participants)
        _args['participants'] = _list_participants
        _val_version = reader.read_int()
        _args['version'] = _val_version
        return cls(**_args)


class UpdateInlineBotCallbackQuery(TLObject):
    """TL type: updateInlineBotCallbackQuery"""
    CONSTRUCTOR_ID = 0x691e9052
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, query_id: int, user_id: int, msg_id: 'TypeInputBotInlineMessageID', chat_instance: int, data: Optional[bytes] = None, game_short_name: Optional[str] = None):
        self.query_id = query_id
        self.user_id = user_id
        self.msg_id = msg_id
        self.chat_instance = chat_instance
        self.data = data
        self.game_short_name = game_short_name

    def to_dict(self):
        return {
            '_': 'UpdateInlineBotCallbackQuery',
            'query_id': self.query_id,
            'user_id': self.user_id,
            'msg_id': self.msg_id,
            'chat_instance': self.chat_instance,
            'data': self.data,
            'game_short_name': self.game_short_name,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.data is not None:
            flags |= (1 << 0)
        if self.game_short_name is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.query_id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(bytes(self.msg_id))
        buf.write(struct.pack('<q', self.chat_instance))
        if self.data is not None:
            buf.write(TLObject.serialize_bytes(self.data))
        if self.game_short_name is not None:
            buf.write(TLObject.serialize_bytes(self.game_short_name))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_msg_id = reader.tgread_object()
        _args['msg_id'] = _val_msg_id
        _val_chat_instance = reader.read_long()
        _args['chat_instance'] = _val_chat_instance
        if flags & (1 << 0):
            _val_data = reader.tgread_bytes()
            _args['data'] = _val_data
        else:
            _args['data'] = None
        if flags & (1 << 1):
            _val_game_short_name = reader.tgread_string()
            _args['game_short_name'] = _val_game_short_name
        else:
            _args['game_short_name'] = None
        return cls(**_args)


class UpdateLangPack(TLObject):
    """TL type: updateLangPack"""
    CONSTRUCTOR_ID = 0x56022f4d
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, difference: 'TypeLangPackDifference'):
        self.difference = difference

    def to_dict(self):
        return {
            '_': 'UpdateLangPack',
            'difference': self.difference,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.difference))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_difference = reader.tgread_object()
        _args['difference'] = _val_difference
        return cls(**_args)


class UpdateLangPackTooLong(TLObject):
    """TL type: updateLangPackTooLong"""
    CONSTRUCTOR_ID = 0x46560264
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, lang_code: str):
        self.lang_code = lang_code

    def to_dict(self):
        return {
            '_': 'UpdateLangPackTooLong',
            'lang_code': self.lang_code,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.lang_code))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        return cls(**_args)


class UpdateLoginToken(TLObject):
    """TL type: updateLoginToken"""
    CONSTRUCTOR_ID = 0x564fe691
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateLoginToken',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateMessageExtendedMedia(TLObject):
    """TL type: updateMessageExtendedMedia"""
    CONSTRUCTOR_ID = 0xd5a41724
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', msg_id: int, extended_media: List['TypeMessageExtendedMedia']):
        self.peer = peer
        self.msg_id = msg_id
        self.extended_media = extended_media

    def to_dict(self):
        return {
            '_': 'UpdateMessageExtendedMedia',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'extended_media': self.extended_media,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.extended_media)))
        for item in self.extended_media:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        reader.read_int(signed=False)  # skip vector id
        _count_extended_media = reader.read_int()
        _list_extended_media = []
        for _ in range(_count_extended_media):
            _item_extended_media = reader.tgread_object()
            _list_extended_media.append(_item_extended_media)
        _args['extended_media'] = _list_extended_media
        return cls(**_args)


class UpdateMessageId(TLObject):
    """TL type: updateMessageID"""
    CONSTRUCTOR_ID = 0x4e90bfd6
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, id: int, random_id: int = None):
        self.id = id
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'UpdateMessageId',
            'id': self.id,
            'random_id': self.random_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<q', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        return cls(**_args)


class UpdateMessagePoll(TLObject):
    """TL type: updateMessagePoll"""
    CONSTRUCTOR_ID = 0xaca1657b
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, poll_id: int, results: 'TypePollResults', poll: Optional['TypePoll'] = None):
        self.poll_id = poll_id
        self.results = results
        self.poll = poll

    def to_dict(self):
        return {
            '_': 'UpdateMessagePoll',
            'poll_id': self.poll_id,
            'results': self.results,
            'poll': self.poll,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.poll is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.poll_id))
        buf.write(bytes(self.results))
        if self.poll is not None:
            buf.write(bytes(self.poll))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_poll_id = reader.read_long()
        _args['poll_id'] = _val_poll_id
        if flags & (1 << 0):
            _val_poll = reader.tgread_object()
            _args['poll'] = _val_poll
        else:
            _args['poll'] = None
        _val_results = reader.tgread_object()
        _args['results'] = _val_results
        return cls(**_args)


class UpdateMessagePollVote(TLObject):
    """TL type: updateMessagePollVote"""
    CONSTRUCTOR_ID = 0x24f40e77
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, poll_id: int, peer: 'TypePeer', options: List[bytes], qts: int):
        self.poll_id = poll_id
        self.peer = peer
        self.options = options
        self.qts = qts

    def to_dict(self):
        return {
            '_': 'UpdateMessagePollVote',
            'poll_id': self.poll_id,
            'peer': self.peer,
            'options': self.options,
            'qts': self.qts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.poll_id))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.options)))
        for item in self.options:
            buf.write(TLObject.serialize_bytes(self.item))
        buf.write(struct.pack('<i', self.qts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_poll_id = reader.read_long()
        _args['poll_id'] = _val_poll_id
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        reader.read_int(signed=False)  # skip vector id
        _count_options = reader.read_int()
        _list_options = []
        for _ in range(_count_options):
            _item_options = reader.tgread_bytes()
            _list_options.append(_item_options)
        _args['options'] = _list_options
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateMessageReactions(TLObject):
    """TL type: updateMessageReactions"""
    CONSTRUCTOR_ID = 0x1e297bfa
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', msg_id: int, reactions: 'TypeMessageReactions', top_msg_id: Optional[int] = None, saved_peer_id: Optional['TypePeer'] = None):
        self.peer = peer
        self.msg_id = msg_id
        self.reactions = reactions
        self.top_msg_id = top_msg_id
        self.saved_peer_id = saved_peer_id

    def to_dict(self):
        return {
            '_': 'UpdateMessageReactions',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'reactions': self.reactions,
            'top_msg_id': self.top_msg_id,
            'saved_peer_id': self.saved_peer_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.top_msg_id is not None:
            flags |= (1 << 0)
        if self.saved_peer_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(bytes(self.reactions))
        if self.top_msg_id is not None:
            buf.write(struct.pack('<i', self.top_msg_id))
        if self.saved_peer_id is not None:
            buf.write(bytes(self.saved_peer_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        if flags & (1 << 0):
            _val_top_msg_id = reader.read_int()
            _args['top_msg_id'] = _val_top_msg_id
        else:
            _args['top_msg_id'] = None
        if flags & (1 << 1):
            _val_saved_peer_id = reader.tgread_object()
            _args['saved_peer_id'] = _val_saved_peer_id
        else:
            _args['saved_peer_id'] = None
        _val_reactions = reader.tgread_object()
        _args['reactions'] = _val_reactions
        return cls(**_args)


class UpdateMonoForumNoPaidException(TLObject):
    """TL type: updateMonoForumNoPaidException"""
    CONSTRUCTOR_ID = 0x9f812b08
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, saved_peer_id: 'TypePeer', exception: Optional[bool] = None):
        self.channel_id = channel_id
        self.saved_peer_id = saved_peer_id
        self.exception = exception

    def to_dict(self):
        return {
            '_': 'UpdateMonoForumNoPaidException',
            'channel_id': self.channel_id,
            'saved_peer_id': self.saved_peer_id,
            'exception': self.exception,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.exception:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(bytes(self.saved_peer_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['exception'] = bool(flags & (1 << 0))
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_saved_peer_id = reader.tgread_object()
        _args['saved_peer_id'] = _val_saved_peer_id
        return cls(**_args)


class UpdateMoveStickerSetToTop(TLObject):
    """TL type: updateMoveStickerSetToTop"""
    CONSTRUCTOR_ID = 0x86fccf85
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, stickerset: int, masks: Optional[bool] = None, emojis: Optional[bool] = None):
        self.stickerset = stickerset
        self.masks = masks
        self.emojis = emojis

    def to_dict(self):
        return {
            '_': 'UpdateMoveStickerSetToTop',
            'stickerset': self.stickerset,
            'masks': self.masks,
            'emojis': self.emojis,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.masks:
            flags |= (1 << 0)
        if self.emojis:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.stickerset))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['masks'] = bool(flags & (1 << 0))
        _args['emojis'] = bool(flags & (1 << 1))
        _val_stickerset = reader.read_long()
        _args['stickerset'] = _val_stickerset
        return cls(**_args)


class UpdateNewAuthorization(TLObject):
    """TL type: updateNewAuthorization"""
    CONSTRUCTOR_ID = 0x8951abef
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, hash: int, unconfirmed: Optional[bool] = None, date: Optional[datetime] = None, device: Optional[str] = None, location: Optional[str] = None):
        self.hash = hash
        self.unconfirmed = unconfirmed
        self.date = date
        self.device = device
        self.location = location

    def to_dict(self):
        return {
            '_': 'UpdateNewAuthorization',
            'hash': self.hash,
            'unconfirmed': self.unconfirmed,
            'date': self.date,
            'device': self.device,
            'location': self.location,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.location is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.hash))
        if self.date is not None:
            buf.write(struct.pack('<i', self.date))
        if self.device is not None:
            buf.write(TLObject.serialize_bytes(self.device))
        if self.location is not None:
            buf.write(TLObject.serialize_bytes(self.location))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['unconfirmed'] = bool(flags & (1 << 0))
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        if flags & (1 << 0):
            _val_date = reader.read_int()
            _args['date'] = _val_date
        else:
            _args['date'] = None
        if flags & (1 << 0):
            _val_device = reader.tgread_string()
            _args['device'] = _val_device
        else:
            _args['device'] = None
        if flags & (1 << 0):
            _val_location = reader.tgread_string()
            _args['location'] = _val_location
        else:
            _args['location'] = None
        return cls(**_args)


class UpdateNewChannelMessage(TLObject):
    """TL type: updateNewChannelMessage"""
    CONSTRUCTOR_ID = 0x62ba04d9
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, message: 'TypeMessage', pts: int, pts_count: int):
        self.message = message
        self.pts = pts
        self.pts_count = pts_count

    def to_dict(self):
        return {
            '_': 'UpdateNewChannelMessage',
            'message': self.message,
            'pts': self.pts,
            'pts_count': self.pts_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdateNewEncryptedMessage(TLObject):
    """TL type: updateNewEncryptedMessage"""
    CONSTRUCTOR_ID = 0x12bcbd9a
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, message: 'TypeEncryptedMessage', qts: int):
        self.message = message
        self.qts = qts

    def to_dict(self):
        return {
            '_': 'UpdateNewEncryptedMessage',
            'message': self.message,
            'qts': self.qts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        buf.write(struct.pack('<i', self.qts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        _val_qts = reader.read_int()
        _args['qts'] = _val_qts
        return cls(**_args)


class UpdateNewMessage(TLObject):
    """TL type: updateNewMessage"""
    CONSTRUCTOR_ID = 0x1f2b0afd
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, message: 'TypeMessage', pts: int, pts_count: int):
        self.message = message
        self.pts = pts
        self.pts_count = pts_count

    def to_dict(self):
        return {
            '_': 'UpdateNewMessage',
            'message': self.message,
            'pts': self.pts,
            'pts_count': self.pts_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdateNewQuickReply(TLObject):
    """TL type: updateNewQuickReply"""
    CONSTRUCTOR_ID = 0xf53da717
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, quick_reply: 'TypeQuickReply'):
        self.quick_reply = quick_reply

    def to_dict(self):
        return {
            '_': 'UpdateNewQuickReply',
            'quick_reply': self.quick_reply,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.quick_reply))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_quick_reply = reader.tgread_object()
        _args['quick_reply'] = _val_quick_reply
        return cls(**_args)


class UpdateNewScheduledMessage(TLObject):
    """TL type: updateNewScheduledMessage"""
    CONSTRUCTOR_ID = 0x39a51dfb
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, message: 'TypeMessage'):
        self.message = message

    def to_dict(self):
        return {
            '_': 'UpdateNewScheduledMessage',
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        return cls(**_args)


class UpdateNewStickerSet(TLObject):
    """TL type: updateNewStickerSet"""
    CONSTRUCTOR_ID = 0x688a30aa
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, stickerset: 'TypeStickerSet'):
        self.stickerset = stickerset

    def to_dict(self):
        return {
            '_': 'UpdateNewStickerSet',
            'stickerset': self.stickerset,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.stickerset))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_stickerset = reader.tgread_object()
        _args['stickerset'] = _val_stickerset
        return cls(**_args)


class UpdateNewStoryReaction(TLObject):
    """TL type: updateNewStoryReaction"""
    CONSTRUCTOR_ID = 0x1824e40b
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, story_id: int, peer: 'TypePeer', reaction: 'TypeReaction'):
        self.story_id = story_id
        self.peer = peer
        self.reaction = reaction

    def to_dict(self):
        return {
            '_': 'UpdateNewStoryReaction',
            'story_id': self.story_id,
            'peer': self.peer,
            'reaction': self.reaction,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.story_id))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.reaction))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_story_id = reader.read_int()
        _args['story_id'] = _val_story_id
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_reaction = reader.tgread_object()
        _args['reaction'] = _val_reaction
        return cls(**_args)


class UpdateNotifySettings(TLObject):
    """TL type: updateNotifySettings"""
    CONSTRUCTOR_ID = 0xbec268ef
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypeNotifyPeer', notify_settings: 'TypePeerNotifySettings'):
        self.peer = peer
        self.notify_settings = notify_settings

    def to_dict(self):
        return {
            '_': 'UpdateNotifySettings',
            'peer': self.peer,
            'notify_settings': self.notify_settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.notify_settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_notify_settings = reader.tgread_object()
        _args['notify_settings'] = _val_notify_settings
        return cls(**_args)


class UpdatePaidReactionPrivacy(TLObject):
    """TL type: updatePaidReactionPrivacy"""
    CONSTRUCTOR_ID = 0x8b725fce
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, private: 'TypePaidReactionPrivacy'):
        self.private = private

    def to_dict(self):
        return {
            '_': 'UpdatePaidReactionPrivacy',
            'private': self.private,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.private))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_private = reader.tgread_object()
        _args['private'] = _val_private
        return cls(**_args)


class UpdatePeerBlocked(TLObject):
    """TL type: updatePeerBlocked"""
    CONSTRUCTOR_ID = 0xebe07752
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer_id: 'TypePeer', blocked: Optional[bool] = None, blocked_my_stories_from: Optional[bool] = None):
        self.peer_id = peer_id
        self.blocked = blocked
        self.blocked_my_stories_from = blocked_my_stories_from

    def to_dict(self):
        return {
            '_': 'UpdatePeerBlocked',
            'peer_id': self.peer_id,
            'blocked': self.blocked,
            'blocked_my_stories_from': self.blocked_my_stories_from,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.blocked:
            flags |= (1 << 0)
        if self.blocked_my_stories_from:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['blocked'] = bool(flags & (1 << 0))
        _args['blocked_my_stories_from'] = bool(flags & (1 << 1))
        _val_peer_id = reader.tgread_object()
        _args['peer_id'] = _val_peer_id
        return cls(**_args)


class UpdatePeerHistoryTtl(TLObject):
    """TL type: updatePeerHistoryTTL"""
    CONSTRUCTOR_ID = 0xbb9bb9a5
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', ttl_period: Optional[int] = None):
        self.peer = peer
        self.ttl_period = ttl_period

    def to_dict(self):
        return {
            '_': 'UpdatePeerHistoryTtl',
            'peer': self.peer,
            'ttl_period': self.ttl_period,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.ttl_period is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        if self.ttl_period is not None:
            buf.write(struct.pack('<i', self.ttl_period))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _val_ttl_period = reader.read_int()
            _args['ttl_period'] = _val_ttl_period
        else:
            _args['ttl_period'] = None
        return cls(**_args)


class UpdatePeerLocated(TLObject):
    """TL type: updatePeerLocated"""
    CONSTRUCTOR_ID = 0xb4afcfb0
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peers: List['TypePeerLocated']):
        self.peers = peers

    def to_dict(self):
        return {
            '_': 'UpdatePeerLocated',
            'peers': self.peers,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.peers)))
        for item in self.peers:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_peers = reader.read_int()
        _list_peers = []
        for _ in range(_count_peers):
            _item_peers = reader.tgread_object()
            _list_peers.append(_item_peers)
        _args['peers'] = _list_peers
        return cls(**_args)


class UpdatePeerSettings(TLObject):
    """TL type: updatePeerSettings"""
    CONSTRUCTOR_ID = 0x6a7e7366
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', settings: 'TypePeerSettings'):
        self.peer = peer
        self.settings = settings

    def to_dict(self):
        return {
            '_': 'UpdatePeerSettings',
            'peer': self.peer,
            'settings': self.settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_settings = reader.tgread_object()
        _args['settings'] = _val_settings
        return cls(**_args)


class UpdatePeerWallpaper(TLObject):
    """TL type: updatePeerWallpaper"""
    CONSTRUCTOR_ID = 0xae3f101d
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', wallpaper_overridden: Optional[bool] = None, wallpaper: Optional['TypeWallPaper'] = None):
        self.peer = peer
        self.wallpaper_overridden = wallpaper_overridden
        self.wallpaper = wallpaper

    def to_dict(self):
        return {
            '_': 'UpdatePeerWallpaper',
            'peer': self.peer,
            'wallpaper_overridden': self.wallpaper_overridden,
            'wallpaper': self.wallpaper,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.wallpaper_overridden:
            flags |= (1 << 1)
        if self.wallpaper is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        if self.wallpaper is not None:
            buf.write(bytes(self.wallpaper))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['wallpaper_overridden'] = bool(flags & (1 << 1))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _val_wallpaper = reader.tgread_object()
            _args['wallpaper'] = _val_wallpaper
        else:
            _args['wallpaper'] = None
        return cls(**_args)


class UpdatePendingJoinRequests(TLObject):
    """TL type: updatePendingJoinRequests"""
    CONSTRUCTOR_ID = 0x7063c3db
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', requests_pending: int, recent_requesters: List[int]):
        self.peer = peer
        self.requests_pending = requests_pending
        self.recent_requesters = recent_requesters

    def to_dict(self):
        return {
            '_': 'UpdatePendingJoinRequests',
            'peer': self.peer,
            'requests_pending': self.requests_pending,
            'recent_requesters': self.recent_requesters,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.requests_pending))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.recent_requesters)))
        for item in self.recent_requesters:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_requests_pending = reader.read_int()
        _args['requests_pending'] = _val_requests_pending
        reader.read_int(signed=False)  # skip vector id
        _count_recent_requesters = reader.read_int()
        _list_recent_requesters = []
        for _ in range(_count_recent_requesters):
            _item_recent_requesters = reader.read_long()
            _list_recent_requesters.append(_item_recent_requesters)
        _args['recent_requesters'] = _list_recent_requesters
        return cls(**_args)


class UpdatePhoneCall(TLObject):
    """TL type: updatePhoneCall"""
    CONSTRUCTOR_ID = 0xab0f6b1e
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, phone_call: 'TypePhoneCall'):
        self.phone_call = phone_call

    def to_dict(self):
        return {
            '_': 'UpdatePhoneCall',
            'phone_call': self.phone_call,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.phone_call))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone_call = reader.tgread_object()
        _args['phone_call'] = _val_phone_call
        return cls(**_args)


class UpdatePhoneCallSignalingData(TLObject):
    """TL type: updatePhoneCallSignalingData"""
    CONSTRUCTOR_ID = 0x2661bf09
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, phone_call_id: int, data: bytes):
        self.phone_call_id = phone_call_id
        self.data = data

    def to_dict(self):
        return {
            '_': 'UpdatePhoneCallSignalingData',
            'phone_call_id': self.phone_call_id,
            'data': self.data,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.phone_call_id))
        buf.write(TLObject.serialize_bytes(self.data))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_phone_call_id = reader.read_long()
        _args['phone_call_id'] = _val_phone_call_id
        _val_data = reader.tgread_bytes()
        _args['data'] = _val_data
        return cls(**_args)


class UpdatePinnedChannelMessages(TLObject):
    """TL type: updatePinnedChannelMessages"""
    CONSTRUCTOR_ID = 0x5bb98608
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, messages: List[int], pts: int, pts_count: int, pinned: Optional[bool] = None):
        self.channel_id = channel_id
        self.messages = messages
        self.pts = pts
        self.pts_count = pts_count
        self.pinned = pinned

    def to_dict(self):
        return {
            '_': 'UpdatePinnedChannelMessages',
            'channel_id': self.channel_id,
            'messages': self.messages,
            'pts': self.pts,
            'pts_count': self.pts_count,
            'pinned': self.pinned,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.pinned:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.messages)))
        for item in self.messages:
            buf.write(struct.pack('<i', self.item))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['pinned'] = bool(flags & (1 << 0))
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        reader.read_int(signed=False)  # skip vector id
        _count_messages = reader.read_int()
        _list_messages = []
        for _ in range(_count_messages):
            _item_messages = reader.read_int()
            _list_messages.append(_item_messages)
        _args['messages'] = _list_messages
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdatePinnedDialogs(TLObject):
    """TL type: updatePinnedDialogs"""
    CONSTRUCTOR_ID = 0xfa0f3ca2
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, folder_id: Optional[int] = None, order: Optional[List['TypeDialogPeer']] = None):
        self.folder_id = folder_id
        self.order = order

    def to_dict(self):
        return {
            '_': 'UpdatePinnedDialogs',
            'folder_id': self.folder_id,
            'order': self.order,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.folder_id is not None:
            flags |= (1 << 1)
        if self.order is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        if self.folder_id is not None:
            buf.write(struct.pack('<i', self.folder_id))
        if self.order is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.order)))
            for item in self.order:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 1):
            _val_folder_id = reader.read_int()
            _args['folder_id'] = _val_folder_id
        else:
            _args['folder_id'] = None
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_order = reader.read_int()
            _list_order = []
            for _ in range(_count_order):
                _item_order = reader.tgread_object()
                _list_order.append(_item_order)
            _args['order'] = _list_order
        else:
            _args['order'] = None
        return cls(**_args)


class UpdatePinnedForumTopic(TLObject):
    """TL type: updatePinnedForumTopic"""
    CONSTRUCTOR_ID = 0x683b2c52
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', topic_id: int, pinned: Optional[bool] = None):
        self.peer = peer
        self.topic_id = topic_id
        self.pinned = pinned

    def to_dict(self):
        return {
            '_': 'UpdatePinnedForumTopic',
            'peer': self.peer,
            'topic_id': self.topic_id,
            'pinned': self.pinned,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.pinned:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.topic_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['pinned'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_topic_id = reader.read_int()
        _args['topic_id'] = _val_topic_id
        return cls(**_args)


class UpdatePinnedForumTopics(TLObject):
    """TL type: updatePinnedForumTopics"""
    CONSTRUCTOR_ID = 0xdef143d0
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', order: Optional[List[int]] = None):
        self.peer = peer
        self.order = order

    def to_dict(self):
        return {
            '_': 'UpdatePinnedForumTopics',
            'peer': self.peer,
            'order': self.order,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.order is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        if self.order is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.order)))
            for item in self.order:
                buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_order = reader.read_int()
            _list_order = []
            for _ in range(_count_order):
                _item_order = reader.read_int()
                _list_order.append(_item_order)
            _args['order'] = _list_order
        else:
            _args['order'] = None
        return cls(**_args)


class UpdatePinnedMessages(TLObject):
    """TL type: updatePinnedMessages"""
    CONSTRUCTOR_ID = 0xed85eab5
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', messages: List[int], pts: int, pts_count: int, pinned: Optional[bool] = None):
        self.peer = peer
        self.messages = messages
        self.pts = pts
        self.pts_count = pts_count
        self.pinned = pinned

    def to_dict(self):
        return {
            '_': 'UpdatePinnedMessages',
            'peer': self.peer,
            'messages': self.messages,
            'pts': self.pts,
            'pts_count': self.pts_count,
            'pinned': self.pinned,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.pinned:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.messages)))
        for item in self.messages:
            buf.write(struct.pack('<i', self.item))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['pinned'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        reader.read_int(signed=False)  # skip vector id
        _count_messages = reader.read_int()
        _list_messages = []
        for _ in range(_count_messages):
            _item_messages = reader.read_int()
            _list_messages.append(_item_messages)
        _args['messages'] = _list_messages
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdatePinnedSavedDialogs(TLObject):
    """TL type: updatePinnedSavedDialogs"""
    CONSTRUCTOR_ID = 0x686c85a6
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, order: Optional[List['TypeDialogPeer']] = None):
        self.order = order

    def to_dict(self):
        return {
            '_': 'UpdatePinnedSavedDialogs',
            'order': self.order,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.order is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        if self.order is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.order)))
            for item in self.order:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_order = reader.read_int()
            _list_order = []
            for _ in range(_count_order):
                _item_order = reader.tgread_object()
                _list_order.append(_item_order)
            _args['order'] = _list_order
        else:
            _args['order'] = None
        return cls(**_args)


class UpdatePrivacy(TLObject):
    """TL type: updatePrivacy"""
    CONSTRUCTOR_ID = 0xee3b272a
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, key: 'TypePrivacyKey', rules: List['TypePrivacyRule']):
        self.key = key
        self.rules = rules

    def to_dict(self):
        return {
            '_': 'UpdatePrivacy',
            'key': self.key,
            'rules': self.rules,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.key))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.rules)))
        for item in self.rules:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_key = reader.tgread_object()
        _args['key'] = _val_key
        reader.read_int(signed=False)  # skip vector id
        _count_rules = reader.read_int()
        _list_rules = []
        for _ in range(_count_rules):
            _item_rules = reader.tgread_object()
            _list_rules.append(_item_rules)
        _args['rules'] = _list_rules
        return cls(**_args)


class UpdatePtsChanged(TLObject):
    """TL type: updatePtsChanged"""
    CONSTRUCTOR_ID = 0x3354678f
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdatePtsChanged',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateQuickReplies(TLObject):
    """TL type: updateQuickReplies"""
    CONSTRUCTOR_ID = 0xf9470ab2
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, quick_replies: List['TypeQuickReply']):
        self.quick_replies = quick_replies

    def to_dict(self):
        return {
            '_': 'UpdateQuickReplies',
            'quick_replies': self.quick_replies,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.quick_replies)))
        for item in self.quick_replies:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_quick_replies = reader.read_int()
        _list_quick_replies = []
        for _ in range(_count_quick_replies):
            _item_quick_replies = reader.tgread_object()
            _list_quick_replies.append(_item_quick_replies)
        _args['quick_replies'] = _list_quick_replies
        return cls(**_args)


class UpdateQuickReplyMessage(TLObject):
    """TL type: updateQuickReplyMessage"""
    CONSTRUCTOR_ID = 0x3e050d0f
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, message: 'TypeMessage'):
        self.message = message

    def to_dict(self):
        return {
            '_': 'UpdateQuickReplyMessage',
            'message': self.message,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.message))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_message = reader.tgread_object()
        _args['message'] = _val_message
        return cls(**_args)


class UpdateReadChannelDiscussionInbox(TLObject):
    """TL type: updateReadChannelDiscussionInbox"""
    CONSTRUCTOR_ID = 0xd6b19546
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, top_msg_id: int, read_max_id: int, broadcast_id: Optional[int] = None, broadcast_post: Optional[int] = None):
        self.channel_id = channel_id
        self.top_msg_id = top_msg_id
        self.read_max_id = read_max_id
        self.broadcast_id = broadcast_id
        self.broadcast_post = broadcast_post

    def to_dict(self):
        return {
            '_': 'UpdateReadChannelDiscussionInbox',
            'channel_id': self.channel_id,
            'top_msg_id': self.top_msg_id,
            'read_max_id': self.read_max_id,
            'broadcast_id': self.broadcast_id,
            'broadcast_post': self.broadcast_post,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.broadcast_post is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', self.top_msg_id))
        buf.write(struct.pack('<i', self.read_max_id))
        if self.broadcast_id is not None:
            buf.write(struct.pack('<q', self.broadcast_id))
        if self.broadcast_post is not None:
            buf.write(struct.pack('<i', self.broadcast_post))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_top_msg_id = reader.read_int()
        _args['top_msg_id'] = _val_top_msg_id
        _val_read_max_id = reader.read_int()
        _args['read_max_id'] = _val_read_max_id
        if flags & (1 << 0):
            _val_broadcast_id = reader.read_long()
            _args['broadcast_id'] = _val_broadcast_id
        else:
            _args['broadcast_id'] = None
        if flags & (1 << 0):
            _val_broadcast_post = reader.read_int()
            _args['broadcast_post'] = _val_broadcast_post
        else:
            _args['broadcast_post'] = None
        return cls(**_args)


class UpdateReadChannelDiscussionOutbox(TLObject):
    """TL type: updateReadChannelDiscussionOutbox"""
    CONSTRUCTOR_ID = 0x695c9e7c
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, top_msg_id: int, read_max_id: int):
        self.channel_id = channel_id
        self.top_msg_id = top_msg_id
        self.read_max_id = read_max_id

    def to_dict(self):
        return {
            '_': 'UpdateReadChannelDiscussionOutbox',
            'channel_id': self.channel_id,
            'top_msg_id': self.top_msg_id,
            'read_max_id': self.read_max_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', self.top_msg_id))
        buf.write(struct.pack('<i', self.read_max_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_top_msg_id = reader.read_int()
        _args['top_msg_id'] = _val_top_msg_id
        _val_read_max_id = reader.read_int()
        _args['read_max_id'] = _val_read_max_id
        return cls(**_args)


class UpdateReadChannelInbox(TLObject):
    """TL type: updateReadChannelInbox"""
    CONSTRUCTOR_ID = 0x922e6e10
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, max_id: int, still_unread_count: int, pts: int, folder_id: Optional[int] = None):
        self.channel_id = channel_id
        self.max_id = max_id
        self.still_unread_count = still_unread_count
        self.pts = pts
        self.folder_id = folder_id

    def to_dict(self):
        return {
            '_': 'UpdateReadChannelInbox',
            'channel_id': self.channel_id,
            'max_id': self.max_id,
            'still_unread_count': self.still_unread_count,
            'pts': self.pts,
            'folder_id': self.folder_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.folder_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', self.max_id))
        buf.write(struct.pack('<i', self.still_unread_count))
        buf.write(struct.pack('<i', self.pts))
        if self.folder_id is not None:
            buf.write(struct.pack('<i', self.folder_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_folder_id = reader.read_int()
            _args['folder_id'] = _val_folder_id
        else:
            _args['folder_id'] = None
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        _val_still_unread_count = reader.read_int()
        _args['still_unread_count'] = _val_still_unread_count
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        return cls(**_args)


class UpdateReadChannelOutbox(TLObject):
    """TL type: updateReadChannelOutbox"""
    CONSTRUCTOR_ID = 0xb75f99a9
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, max_id: int):
        self.channel_id = channel_id
        self.max_id = max_id

    def to_dict(self):
        return {
            '_': 'UpdateReadChannelOutbox',
            'channel_id': self.channel_id,
            'max_id': self.max_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(struct.pack('<i', self.max_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        return cls(**_args)


class UpdateReadFeaturedEmojiStickers(TLObject):
    """TL type: updateReadFeaturedEmojiStickers"""
    CONSTRUCTOR_ID = 0xfb4c496c
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateReadFeaturedEmojiStickers',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateReadFeaturedStickers(TLObject):
    """TL type: updateReadFeaturedStickers"""
    CONSTRUCTOR_ID = 0x571d2742
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateReadFeaturedStickers',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateReadHistoryInbox(TLObject):
    """TL type: updateReadHistoryInbox"""
    CONSTRUCTOR_ID = 0x9e84bc99
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', max_id: int, still_unread_count: int, pts: int, pts_count: int, folder_id: Optional[int] = None, top_msg_id: Optional[int] = None):
        self.peer = peer
        self.max_id = max_id
        self.still_unread_count = still_unread_count
        self.pts = pts
        self.pts_count = pts_count
        self.folder_id = folder_id
        self.top_msg_id = top_msg_id

    def to_dict(self):
        return {
            '_': 'UpdateReadHistoryInbox',
            'peer': self.peer,
            'max_id': self.max_id,
            'still_unread_count': self.still_unread_count,
            'pts': self.pts,
            'pts_count': self.pts_count,
            'folder_id': self.folder_id,
            'top_msg_id': self.top_msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.folder_id is not None:
            flags |= (1 << 0)
        if self.top_msg_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.max_id))
        buf.write(struct.pack('<i', self.still_unread_count))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        if self.folder_id is not None:
            buf.write(struct.pack('<i', self.folder_id))
        if self.top_msg_id is not None:
            buf.write(struct.pack('<i', self.top_msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_folder_id = reader.read_int()
            _args['folder_id'] = _val_folder_id
        else:
            _args['folder_id'] = None
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 1):
            _val_top_msg_id = reader.read_int()
            _args['top_msg_id'] = _val_top_msg_id
        else:
            _args['top_msg_id'] = None
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        _val_still_unread_count = reader.read_int()
        _args['still_unread_count'] = _val_still_unread_count
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdateReadHistoryOutbox(TLObject):
    """TL type: updateReadHistoryOutbox"""
    CONSTRUCTOR_ID = 0x2f2f21bf
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', max_id: int, pts: int, pts_count: int):
        self.peer = peer
        self.max_id = max_id
        self.pts = pts
        self.pts_count = pts_count

    def to_dict(self):
        return {
            '_': 'UpdateReadHistoryOutbox',
            'peer': self.peer,
            'max_id': self.max_id,
            'pts': self.pts,
            'pts_count': self.pts_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.max_id))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdateReadMessagesContents(TLObject):
    """TL type: updateReadMessagesContents"""
    CONSTRUCTOR_ID = 0xf8227181
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, messages: List[int], pts: int, pts_count: int, date: Optional[datetime] = None):
        self.messages = messages
        self.pts = pts
        self.pts_count = pts_count
        self.date = date

    def to_dict(self):
        return {
            '_': 'UpdateReadMessagesContents',
            'messages': self.messages,
            'pts': self.pts,
            'pts_count': self.pts_count,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.date is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.messages)))
        for item in self.messages:
            buf.write(struct.pack('<i', self.item))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        if self.date is not None:
            buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        reader.read_int(signed=False)  # skip vector id
        _count_messages = reader.read_int()
        _list_messages = []
        for _ in range(_count_messages):
            _item_messages = reader.read_int()
            _list_messages.append(_item_messages)
        _args['messages'] = _list_messages
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        if flags & (1 << 0):
            _val_date = reader.read_int()
            _args['date'] = _val_date
        else:
            _args['date'] = None
        return cls(**_args)


class UpdateReadMonoForumInbox(TLObject):
    """TL type: updateReadMonoForumInbox"""
    CONSTRUCTOR_ID = 0x77b0e372
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, saved_peer_id: 'TypePeer', read_max_id: int):
        self.channel_id = channel_id
        self.saved_peer_id = saved_peer_id
        self.read_max_id = read_max_id

    def to_dict(self):
        return {
            '_': 'UpdateReadMonoForumInbox',
            'channel_id': self.channel_id,
            'saved_peer_id': self.saved_peer_id,
            'read_max_id': self.read_max_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(bytes(self.saved_peer_id))
        buf.write(struct.pack('<i', self.read_max_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_saved_peer_id = reader.tgread_object()
        _args['saved_peer_id'] = _val_saved_peer_id
        _val_read_max_id = reader.read_int()
        _args['read_max_id'] = _val_read_max_id
        return cls(**_args)


class UpdateReadMonoForumOutbox(TLObject):
    """TL type: updateReadMonoForumOutbox"""
    CONSTRUCTOR_ID = 0xa4a79376
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, channel_id: int, saved_peer_id: 'TypePeer', read_max_id: int):
        self.channel_id = channel_id
        self.saved_peer_id = saved_peer_id
        self.read_max_id = read_max_id

    def to_dict(self):
        return {
            '_': 'UpdateReadMonoForumOutbox',
            'channel_id': self.channel_id,
            'saved_peer_id': self.saved_peer_id,
            'read_max_id': self.read_max_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.channel_id))
        buf.write(bytes(self.saved_peer_id))
        buf.write(struct.pack('<i', self.read_max_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel_id = reader.read_long()
        _args['channel_id'] = _val_channel_id
        _val_saved_peer_id = reader.tgread_object()
        _args['saved_peer_id'] = _val_saved_peer_id
        _val_read_max_id = reader.read_int()
        _args['read_max_id'] = _val_read_max_id
        return cls(**_args)


class UpdateReadStories(TLObject):
    """TL type: updateReadStories"""
    CONSTRUCTOR_ID = 0xf74e932b
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', max_id: int):
        self.peer = peer
        self.max_id = max_id

    def to_dict(self):
        return {
            '_': 'UpdateReadStories',
            'peer': self.peer,
            'max_id': self.max_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.max_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        return cls(**_args)


class UpdateRecentEmojiStatuses(TLObject):
    """TL type: updateRecentEmojiStatuses"""
    CONSTRUCTOR_ID = 0x30f443db
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateRecentEmojiStatuses',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateRecentReactions(TLObject):
    """TL type: updateRecentReactions"""
    CONSTRUCTOR_ID = 0x6f7863f4
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateRecentReactions',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateRecentStickers(TLObject):
    """TL type: updateRecentStickers"""
    CONSTRUCTOR_ID = 0x9a422c20
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateRecentStickers',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateSavedDialogPinned(TLObject):
    """TL type: updateSavedDialogPinned"""
    CONSTRUCTOR_ID = 0xaeaf9e74
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypeDialogPeer', pinned: Optional[bool] = None):
        self.peer = peer
        self.pinned = pinned

    def to_dict(self):
        return {
            '_': 'UpdateSavedDialogPinned',
            'peer': self.peer,
            'pinned': self.pinned,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.pinned:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['pinned'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class UpdateSavedGifs(TLObject):
    """TL type: updateSavedGifs"""
    CONSTRUCTOR_ID = 0x9375341e
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateSavedGifs',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateSavedReactionTags(TLObject):
    """TL type: updateSavedReactionTags"""
    CONSTRUCTOR_ID = 0x39c67432
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateSavedReactionTags',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateSavedRingtones(TLObject):
    """TL type: updateSavedRingtones"""
    CONSTRUCTOR_ID = 0x74d8be99
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateSavedRingtones',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateSentPhoneCode(TLObject):
    """TL type: updateSentPhoneCode"""
    CONSTRUCTOR_ID = 0x504aa18f
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, sent_code: 'TypeSentCode'):
        self.sent_code = sent_code

    def to_dict(self):
        return {
            '_': 'UpdateSentPhoneCode',
            'sent_code': self.sent_code,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.sent_code))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_sent_code = reader.tgread_object()
        _args['sent_code'] = _val_sent_code
        return cls(**_args)


class UpdateSentStoryReaction(TLObject):
    """TL type: updateSentStoryReaction"""
    CONSTRUCTOR_ID = 0x7d627683
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', story_id: int, reaction: 'TypeReaction'):
        self.peer = peer
        self.story_id = story_id
        self.reaction = reaction

    def to_dict(self):
        return {
            '_': 'UpdateSentStoryReaction',
            'peer': self.peer,
            'story_id': self.story_id,
            'reaction': self.reaction,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.story_id))
        buf.write(bytes(self.reaction))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_story_id = reader.read_int()
        _args['story_id'] = _val_story_id
        _val_reaction = reader.tgread_object()
        _args['reaction'] = _val_reaction
        return cls(**_args)


class UpdateServiceNotification(TLObject):
    """TL type: updateServiceNotification"""
    CONSTRUCTOR_ID = 0xebe46819
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, type: str, message: str, media: 'TypeMessageMedia', entities: List['TypeMessageEntity'], popup: Optional[bool] = None, invert_media: Optional[bool] = None, inbox_date: Optional[datetime] = None):
        self.type = type
        self.message = message
        self.media = media
        self.entities = entities
        self.popup = popup
        self.invert_media = invert_media
        self.inbox_date = inbox_date

    def to_dict(self):
        return {
            '_': 'UpdateServiceNotification',
            'type': self.type,
            'message': self.message,
            'media': self.media,
            'entities': self.entities,
            'popup': self.popup,
            'invert_media': self.invert_media,
            'inbox_date': self.inbox_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.popup:
            flags |= (1 << 0)
        if self.invert_media:
            flags |= (1 << 2)
        if self.inbox_date is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(TLObject.serialize_bytes(self.message))
        buf.write(bytes(self.media))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.entities)))
        for item in self.entities:
            buf.write(bytes(self.item))
        if self.inbox_date is not None:
            buf.write(struct.pack('<i', self.inbox_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['popup'] = bool(flags & (1 << 0))
        _args['invert_media'] = bool(flags & (1 << 2))
        if flags & (1 << 1):
            _val_inbox_date = reader.read_int()
            _args['inbox_date'] = _val_inbox_date
        else:
            _args['inbox_date'] = None
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        _val_media = reader.tgread_object()
        _args['media'] = _val_media
        reader.read_int(signed=False)  # skip vector id
        _count_entities = reader.read_int()
        _list_entities = []
        for _ in range(_count_entities):
            _item_entities = reader.tgread_object()
            _list_entities.append(_item_entities)
        _args['entities'] = _list_entities
        return cls(**_args)


class UpdateShort(TLObject):
    """TL type: updateShort"""
    CONSTRUCTOR_ID = 0x78d4dec1
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, update: 'TypeUpdate', date: Optional[datetime]):
        self.update = update
        self.date = date

    def to_dict(self):
        return {
            '_': 'UpdateShort',
            'update': self.update,
            'date': self.date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.update))
        buf.write(struct.pack('<i', self.date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_update = reader.tgread_object()
        _args['update'] = _val_update
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class UpdateShortChatMessage(TLObject):
    """TL type: updateShortChatMessage"""
    CONSTRUCTOR_ID = 0x4d6deea5
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, id: int, from_id: int, chat_id: int, message: str, pts: int, pts_count: int, date: Optional[datetime], out: Optional[bool] = None, mentioned: Optional[bool] = None, media_unread: Optional[bool] = None, silent: Optional[bool] = None, fwd_from: Optional['TypeMessageFwdHeader'] = None, via_bot_id: Optional[int] = None, reply_to: Optional['TypeMessageReplyHeader'] = None, entities: Optional[List['TypeMessageEntity']] = None, ttl_period: Optional[int] = None):
        self.id = id
        self.from_id = from_id
        self.chat_id = chat_id
        self.message = message
        self.pts = pts
        self.pts_count = pts_count
        self.date = date
        self.out = out
        self.mentioned = mentioned
        self.media_unread = media_unread
        self.silent = silent
        self.fwd_from = fwd_from
        self.via_bot_id = via_bot_id
        self.reply_to = reply_to
        self.entities = entities
        self.ttl_period = ttl_period

    def to_dict(self):
        return {
            '_': 'UpdateShortChatMessage',
            'id': self.id,
            'from_id': self.from_id,
            'chat_id': self.chat_id,
            'message': self.message,
            'pts': self.pts,
            'pts_count': self.pts_count,
            'date': self.date,
            'out': self.out,
            'mentioned': self.mentioned,
            'media_unread': self.media_unread,
            'silent': self.silent,
            'fwd_from': self.fwd_from,
            'via_bot_id': self.via_bot_id,
            'reply_to': self.reply_to,
            'entities': self.entities,
            'ttl_period': self.ttl_period,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.out:
            flags |= (1 << 1)
        if self.mentioned:
            flags |= (1 << 4)
        if self.media_unread:
            flags |= (1 << 5)
        if self.silent:
            flags |= (1 << 13)
        if self.fwd_from is not None:
            flags |= (1 << 2)
        if self.via_bot_id is not None:
            flags |= (1 << 11)
        if self.reply_to is not None:
            flags |= (1 << 3)
        if self.entities is not None:
            flags |= (1 << 7)
        if self.ttl_period is not None:
            flags |= (1 << 25)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<q', self.from_id))
        buf.write(struct.pack('<q', self.chat_id))
        buf.write(TLObject.serialize_bytes(self.message))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        buf.write(struct.pack('<i', self.date))
        if self.fwd_from is not None:
            buf.write(bytes(self.fwd_from))
        if self.via_bot_id is not None:
            buf.write(struct.pack('<q', self.via_bot_id))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.ttl_period is not None:
            buf.write(struct.pack('<i', self.ttl_period))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['out'] = bool(flags & (1 << 1))
        _args['mentioned'] = bool(flags & (1 << 4))
        _args['media_unread'] = bool(flags & (1 << 5))
        _args['silent'] = bool(flags & (1 << 13))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_from_id = reader.read_long()
        _args['from_id'] = _val_from_id
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 2):
            _val_fwd_from = reader.tgread_object()
            _args['fwd_from'] = _val_fwd_from
        else:
            _args['fwd_from'] = None
        if flags & (1 << 11):
            _val_via_bot_id = reader.read_long()
            _args['via_bot_id'] = _val_via_bot_id
        else:
            _args['via_bot_id'] = None
        if flags & (1 << 3):
            _val_reply_to = reader.tgread_object()
            _args['reply_to'] = _val_reply_to
        else:
            _args['reply_to'] = None
        if flags & (1 << 7):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 25):
            _val_ttl_period = reader.read_int()
            _args['ttl_period'] = _val_ttl_period
        else:
            _args['ttl_period'] = None
        return cls(**_args)


class UpdateShortMessage(TLObject):
    """TL type: updateShortMessage"""
    CONSTRUCTOR_ID = 0x313bc7f8
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, id: int, user_id: int, message: str, pts: int, pts_count: int, date: Optional[datetime], out: Optional[bool] = None, mentioned: Optional[bool] = None, media_unread: Optional[bool] = None, silent: Optional[bool] = None, fwd_from: Optional['TypeMessageFwdHeader'] = None, via_bot_id: Optional[int] = None, reply_to: Optional['TypeMessageReplyHeader'] = None, entities: Optional[List['TypeMessageEntity']] = None, ttl_period: Optional[int] = None):
        self.id = id
        self.user_id = user_id
        self.message = message
        self.pts = pts
        self.pts_count = pts_count
        self.date = date
        self.out = out
        self.mentioned = mentioned
        self.media_unread = media_unread
        self.silent = silent
        self.fwd_from = fwd_from
        self.via_bot_id = via_bot_id
        self.reply_to = reply_to
        self.entities = entities
        self.ttl_period = ttl_period

    def to_dict(self):
        return {
            '_': 'UpdateShortMessage',
            'id': self.id,
            'user_id': self.user_id,
            'message': self.message,
            'pts': self.pts,
            'pts_count': self.pts_count,
            'date': self.date,
            'out': self.out,
            'mentioned': self.mentioned,
            'media_unread': self.media_unread,
            'silent': self.silent,
            'fwd_from': self.fwd_from,
            'via_bot_id': self.via_bot_id,
            'reply_to': self.reply_to,
            'entities': self.entities,
            'ttl_period': self.ttl_period,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.out:
            flags |= (1 << 1)
        if self.mentioned:
            flags |= (1 << 4)
        if self.media_unread:
            flags |= (1 << 5)
        if self.silent:
            flags |= (1 << 13)
        if self.fwd_from is not None:
            flags |= (1 << 2)
        if self.via_bot_id is not None:
            flags |= (1 << 11)
        if self.reply_to is not None:
            flags |= (1 << 3)
        if self.entities is not None:
            flags |= (1 << 7)
        if self.ttl_period is not None:
            flags |= (1 << 25)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(TLObject.serialize_bytes(self.message))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        buf.write(struct.pack('<i', self.date))
        if self.fwd_from is not None:
            buf.write(bytes(self.fwd_from))
        if self.via_bot_id is not None:
            buf.write(struct.pack('<q', self.via_bot_id))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.ttl_period is not None:
            buf.write(struct.pack('<i', self.ttl_period))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['out'] = bool(flags & (1 << 1))
        _args['mentioned'] = bool(flags & (1 << 4))
        _args['media_unread'] = bool(flags & (1 << 5))
        _args['silent'] = bool(flags & (1 << 13))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 2):
            _val_fwd_from = reader.tgread_object()
            _args['fwd_from'] = _val_fwd_from
        else:
            _args['fwd_from'] = None
        if flags & (1 << 11):
            _val_via_bot_id = reader.read_long()
            _args['via_bot_id'] = _val_via_bot_id
        else:
            _args['via_bot_id'] = None
        if flags & (1 << 3):
            _val_reply_to = reader.tgread_object()
            _args['reply_to'] = _val_reply_to
        else:
            _args['reply_to'] = None
        if flags & (1 << 7):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 25):
            _val_ttl_period = reader.read_int()
            _args['ttl_period'] = _val_ttl_period
        else:
            _args['ttl_period'] = None
        return cls(**_args)


class UpdateShortSentMessage(TLObject):
    """TL type: updateShortSentMessage"""
    CONSTRUCTOR_ID = 0x9015e101
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, id: int, pts: int, pts_count: int, date: Optional[datetime], out: Optional[bool] = None, media: Optional['TypeMessageMedia'] = None, entities: Optional[List['TypeMessageEntity']] = None, ttl_period: Optional[int] = None):
        self.id = id
        self.pts = pts
        self.pts_count = pts_count
        self.date = date
        self.out = out
        self.media = media
        self.entities = entities
        self.ttl_period = ttl_period

    def to_dict(self):
        return {
            '_': 'UpdateShortSentMessage',
            'id': self.id,
            'pts': self.pts,
            'pts_count': self.pts_count,
            'date': self.date,
            'out': self.out,
            'media': self.media,
            'entities': self.entities,
            'ttl_period': self.ttl_period,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.out:
            flags |= (1 << 1)
        if self.media is not None:
            flags |= (1 << 9)
        if self.entities is not None:
            flags |= (1 << 7)
        if self.ttl_period is not None:
            flags |= (1 << 25)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        buf.write(struct.pack('<i', self.date))
        if self.media is not None:
            buf.write(bytes(self.media))
        if self.entities is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.entities)))
            for item in self.entities:
                buf.write(bytes(self.item))
        if self.ttl_period is not None:
            buf.write(struct.pack('<i', self.ttl_period))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['out'] = bool(flags & (1 << 1))
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        _val_date = reader.read_int()
        _args['date'] = _val_date
        if flags & (1 << 9):
            _val_media = reader.tgread_object()
            _args['media'] = _val_media
        else:
            _args['media'] = None
        if flags & (1 << 7):
            reader.read_int(signed=False)  # skip vector id
            _count_entities = reader.read_int()
            _list_entities = []
            for _ in range(_count_entities):
                _item_entities = reader.tgread_object()
                _list_entities.append(_item_entities)
            _args['entities'] = _list_entities
        else:
            _args['entities'] = None
        if flags & (1 << 25):
            _val_ttl_period = reader.read_int()
            _args['ttl_period'] = _val_ttl_period
        else:
            _args['ttl_period'] = None
        return cls(**_args)


class UpdateSmsJob(TLObject):
    """TL type: updateSmsJob"""
    CONSTRUCTOR_ID = 0xf16269d4
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, job_id: str):
        self.job_id = job_id

    def to_dict(self):
        return {
            '_': 'UpdateSmsJob',
            'job_id': self.job_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.job_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_job_id = reader.tgread_string()
        _args['job_id'] = _val_job_id
        return cls(**_args)


class UpdateStarGiftAuctionState(TLObject):
    """TL type: updateStarGiftAuctionState"""
    CONSTRUCTOR_ID = 0x48e246c2
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, gift_id: int, state: 'TypeStarGiftAuctionState'):
        self.gift_id = gift_id
        self.state = state

    def to_dict(self):
        return {
            '_': 'UpdateStarGiftAuctionState',
            'gift_id': self.gift_id,
            'state': self.state,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.gift_id))
        buf.write(bytes(self.state))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_gift_id = reader.read_long()
        _args['gift_id'] = _val_gift_id
        _val_state = reader.tgread_object()
        _args['state'] = _val_state
        return cls(**_args)


class UpdateStarGiftAuctionUserState(TLObject):
    """TL type: updateStarGiftAuctionUserState"""
    CONSTRUCTOR_ID = 0xdc58f31e
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, gift_id: int, user_state: 'TypeStarGiftAuctionUserState'):
        self.gift_id = gift_id
        self.user_state = user_state

    def to_dict(self):
        return {
            '_': 'UpdateStarGiftAuctionUserState',
            'gift_id': self.gift_id,
            'user_state': self.user_state,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.gift_id))
        buf.write(bytes(self.user_state))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_gift_id = reader.read_long()
        _args['gift_id'] = _val_gift_id
        _val_user_state = reader.tgread_object()
        _args['user_state'] = _val_user_state
        return cls(**_args)


class UpdateStarGiftCraftFail(TLObject):
    """TL type: updateStarGiftCraftFail"""
    CONSTRUCTOR_ID = 0xac072444
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdateStarGiftCraftFail',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UpdateStarsBalance(TLObject):
    """TL type: updateStarsBalance"""
    CONSTRUCTOR_ID = 0x4e80a379
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, balance: 'TypeStarsAmount'):
        self.balance = balance

    def to_dict(self):
        return {
            '_': 'UpdateStarsBalance',
            'balance': self.balance,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.balance))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_balance = reader.tgread_object()
        _args['balance'] = _val_balance
        return cls(**_args)


class UpdateStarsRevenueStatus(TLObject):
    """TL type: updateStarsRevenueStatus"""
    CONSTRUCTOR_ID = 0xa584b019
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', status: 'TypeStarsRevenueStatus'):
        self.peer = peer
        self.status = status

    def to_dict(self):
        return {
            '_': 'UpdateStarsRevenueStatus',
            'peer': self.peer,
            'status': self.status,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.status))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_status = reader.tgread_object()
        _args['status'] = _val_status
        return cls(**_args)


class UpdateStickerSets(TLObject):
    """TL type: updateStickerSets"""
    CONSTRUCTOR_ID = 0x31c24808
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, masks: Optional[bool] = None, emojis: Optional[bool] = None):
        self.masks = masks
        self.emojis = emojis

    def to_dict(self):
        return {
            '_': 'UpdateStickerSets',
            'masks': self.masks,
            'emojis': self.emojis,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.masks:
            flags |= (1 << 0)
        if self.emojis:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['masks'] = bool(flags & (1 << 0))
        _args['emojis'] = bool(flags & (1 << 1))
        return cls(**_args)


class UpdateStickerSetsOrder(TLObject):
    """TL type: updateStickerSetsOrder"""
    CONSTRUCTOR_ID = 0x0bb2d201
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, order: List[int], masks: Optional[bool] = None, emojis: Optional[bool] = None):
        self.order = order
        self.masks = masks
        self.emojis = emojis

    def to_dict(self):
        return {
            '_': 'UpdateStickerSetsOrder',
            'order': self.order,
            'masks': self.masks,
            'emojis': self.emojis,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.masks:
            flags |= (1 << 0)
        if self.emojis:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.order)))
        for item in self.order:
            buf.write(struct.pack('<q', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['masks'] = bool(flags & (1 << 0))
        _args['emojis'] = bool(flags & (1 << 1))
        reader.read_int(signed=False)  # skip vector id
        _count_order = reader.read_int()
        _list_order = []
        for _ in range(_count_order):
            _item_order = reader.read_long()
            _list_order.append(_item_order)
        _args['order'] = _list_order
        return cls(**_args)


class UpdateStoriesStealthMode(TLObject):
    """TL type: updateStoriesStealthMode"""
    CONSTRUCTOR_ID = 0x2c084dc1
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, stealth_mode: 'TypeStoriesStealthMode'):
        self.stealth_mode = stealth_mode

    def to_dict(self):
        return {
            '_': 'UpdateStoriesStealthMode',
            'stealth_mode': self.stealth_mode,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.stealth_mode))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_stealth_mode = reader.tgread_object()
        _args['stealth_mode'] = _val_stealth_mode
        return cls(**_args)


class UpdateStory(TLObject):
    """TL type: updateStory"""
    CONSTRUCTOR_ID = 0x75b3b798
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', story: 'TypeStoryItem'):
        self.peer = peer
        self.story = story

    def to_dict(self):
        return {
            '_': 'UpdateStory',
            'peer': self.peer,
            'story': self.story,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.story))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_story = reader.tgread_object()
        _args['story'] = _val_story
        return cls(**_args)


class UpdateStoryId(TLObject):
    """TL type: updateStoryID"""
    CONSTRUCTOR_ID = 0x1bf335b9
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, id: int, random_id: int = None):
        self.id = id
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'UpdateStoryId',
            'id': self.id,
            'random_id': self.random_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<q', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        return cls(**_args)


class UpdateTheme(TLObject):
    """TL type: updateTheme"""
    CONSTRUCTOR_ID = 0x8216fba3
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, theme: 'TypeTheme'):
        self.theme = theme

    def to_dict(self):
        return {
            '_': 'UpdateTheme',
            'theme': self.theme,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.theme))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_theme = reader.tgread_object()
        _args['theme'] = _val_theme
        return cls(**_args)


class UpdateTranscribeAudio(TLObject):
    """TL type: updateTranscribeAudio"""
    CONSTRUCTOR_ID = 0x88617090
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, transcription_id: int, text: str, final: Optional[bool] = None):
        self.transcription_id = transcription_id
        self.text = text
        self.final = final

    def to_dict(self):
        return {
            '_': 'UpdateTranscribeAudio',
            'transcription_id': self.transcription_id,
            'text': self.text,
            'final': self.final,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.final:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.transcription_id))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['final'] = bool(flags & (1 << 0))
        _val_transcription_id = reader.read_long()
        _args['transcription_id'] = _val_transcription_id
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class UpdateTranscribedAudio(TLObject):
    """TL type: updateTranscribedAudio"""
    CONSTRUCTOR_ID = 0x0084cd5a
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, peer: 'TypePeer', msg_id: int, transcription_id: int, text: str, pending: Optional[bool] = None):
        self.peer = peer
        self.msg_id = msg_id
        self.transcription_id = transcription_id
        self.text = text
        self.pending = pending

    def to_dict(self):
        return {
            '_': 'UpdateTranscribedAudio',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'transcription_id': self.transcription_id,
            'text': self.text,
            'pending': self.pending,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.pending:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<q', self.transcription_id))
        buf.write(TLObject.serialize_bytes(self.text))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['pending'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        _val_transcription_id = reader.read_long()
        _args['transcription_id'] = _val_transcription_id
        _val_text = reader.tgread_string()
        _args['text'] = _val_text
        return cls(**_args)


class UpdateUser(TLObject):
    """TL type: updateUser"""
    CONSTRUCTOR_ID = 0x20529438
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, user_id: int):
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'UpdateUser',
            'user_id': self.user_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class UpdateUserEmojiStatus(TLObject):
    """TL type: updateUserEmojiStatus"""
    CONSTRUCTOR_ID = 0x28373599
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, user_id: int, emoji_status: 'TypeEmojiStatus'):
        self.user_id = user_id
        self.emoji_status = emoji_status

    def to_dict(self):
        return {
            '_': 'UpdateUserEmojiStatus',
            'user_id': self.user_id,
            'emoji_status': self.emoji_status,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(bytes(self.emoji_status))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_emoji_status = reader.tgread_object()
        _args['emoji_status'] = _val_emoji_status
        return cls(**_args)


class UpdateUserName(TLObject):
    """TL type: updateUserName"""
    CONSTRUCTOR_ID = 0xa7848924
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, user_id: int, first_name: str, last_name: str, usernames: List['TypeUsername']):
        self.user_id = user_id
        self.first_name = first_name
        self.last_name = last_name
        self.usernames = usernames

    def to_dict(self):
        return {
            '_': 'UpdateUserName',
            'user_id': self.user_id,
            'first_name': self.first_name,
            'last_name': self.last_name,
            'usernames': self.usernames,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(TLObject.serialize_bytes(self.first_name))
        buf.write(TLObject.serialize_bytes(self.last_name))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.usernames)))
        for item in self.usernames:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_first_name = reader.tgread_string()
        _args['first_name'] = _val_first_name
        _val_last_name = reader.tgread_string()
        _args['last_name'] = _val_last_name
        reader.read_int(signed=False)  # skip vector id
        _count_usernames = reader.read_int()
        _list_usernames = []
        for _ in range(_count_usernames):
            _item_usernames = reader.tgread_object()
            _list_usernames.append(_item_usernames)
        _args['usernames'] = _list_usernames
        return cls(**_args)


class UpdateUserPhone(TLObject):
    """TL type: updateUserPhone"""
    CONSTRUCTOR_ID = 0x05492a13
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, user_id: int, phone: str):
        self.user_id = user_id
        self.phone = phone

    def to_dict(self):
        return {
            '_': 'UpdateUserPhone',
            'user_id': self.user_id,
            'phone': self.phone,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(TLObject.serialize_bytes(self.phone))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_phone = reader.tgread_string()
        _args['phone'] = _val_phone
        return cls(**_args)


class UpdateUserStatus(TLObject):
    """TL type: updateUserStatus"""
    CONSTRUCTOR_ID = 0xe5bdf8de
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, user_id: int, status: 'TypeUserStatus'):
        self.user_id = user_id
        self.status = status

    def to_dict(self):
        return {
            '_': 'UpdateUserStatus',
            'user_id': self.user_id,
            'status': self.status,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(bytes(self.status))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        _val_status = reader.tgread_object()
        _args['status'] = _val_status
        return cls(**_args)


class UpdateUserTyping(TLObject):
    """TL type: updateUserTyping"""
    CONSTRUCTOR_ID = 0x2a17bf5c
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, user_id: int, action: 'TypeSendMessageAction', top_msg_id: Optional[int] = None):
        self.user_id = user_id
        self.action = action
        self.top_msg_id = top_msg_id

    def to_dict(self):
        return {
            '_': 'UpdateUserTyping',
            'user_id': self.user_id,
            'action': self.action,
            'top_msg_id': self.top_msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.top_msg_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.user_id))
        buf.write(bytes(self.action))
        if self.top_msg_id is not None:
            buf.write(struct.pack('<i', self.top_msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_user_id = reader.read_long()
        _args['user_id'] = _val_user_id
        if flags & (1 << 0):
            _val_top_msg_id = reader.read_int()
            _args['top_msg_id'] = _val_top_msg_id
        else:
            _args['top_msg_id'] = None
        _val_action = reader.tgread_object()
        _args['action'] = _val_action
        return cls(**_args)


class UpdateWebPage(TLObject):
    """TL type: updateWebPage"""
    CONSTRUCTOR_ID = 0x7f891213
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, webpage: 'TypeWebPage', pts: int, pts_count: int):
        self.webpage = webpage
        self.pts = pts
        self.pts_count = pts_count

    def to_dict(self):
        return {
            '_': 'UpdateWebPage',
            'webpage': self.webpage,
            'pts': self.pts,
            'pts_count': self.pts_count,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.webpage))
        buf.write(struct.pack('<i', self.pts))
        buf.write(struct.pack('<i', self.pts_count))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_webpage = reader.tgread_object()
        _args['webpage'] = _val_webpage
        _val_pts = reader.read_int()
        _args['pts'] = _val_pts
        _val_pts_count = reader.read_int()
        _args['pts_count'] = _val_pts_count
        return cls(**_args)


class UpdateWebViewResultSent(TLObject):
    """TL type: updateWebViewResultSent"""
    CONSTRUCTOR_ID = 0x1592b79d
    SUBCLASS_OF_ID = 0x9f89304e

    def __init__(self, query_id: int):
        self.query_id = query_id

    def to_dict(self):
        return {
            '_': 'UpdateWebViewResultSent',
            'query_id': self.query_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.query_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        return cls(**_args)


class Updates(TLObject):
    """TL type: updates"""
    CONSTRUCTOR_ID = 0x74ae4240
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, updates: List['TypeUpdate'], users: List['TypeUser'], chats: List['TypeChat'], date: Optional[datetime], seq: int):
        self.updates = updates
        self.users = users
        self.chats = chats
        self.date = date
        self.seq = seq

    def to_dict(self):
        return {
            '_': 'Updates',
            'updates': self.updates,
            'users': self.users,
            'chats': self.chats,
            'date': self.date,
            'seq': self.seq,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.updates)))
        for item in self.updates:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.seq))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_updates = reader.read_int()
        _list_updates = []
        for _ in range(_count_updates):
            _item_updates = reader.tgread_object()
            _list_updates.append(_item_updates)
        _args['updates'] = _list_updates
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.tgread_object()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_seq = reader.read_int()
        _args['seq'] = _val_seq
        return cls(**_args)


class UpdatesCombined(TLObject):
    """TL type: updatesCombined"""
    CONSTRUCTOR_ID = 0x725b04c3
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, updates: List['TypeUpdate'], users: List['TypeUser'], chats: List['TypeChat'], date: Optional[datetime], seq_start: int, seq: int):
        self.updates = updates
        self.users = users
        self.chats = chats
        self.date = date
        self.seq_start = seq_start
        self.seq = seq

    def to_dict(self):
        return {
            '_': 'UpdatesCombined',
            'updates': self.updates,
            'users': self.users,
            'chats': self.chats,
            'date': self.date,
            'seq_start': self.seq_start,
            'seq': self.seq,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.updates)))
        for item in self.updates:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.users)))
        for item in self.users:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', self.date))
        buf.write(struct.pack('<i', self.seq_start))
        buf.write(struct.pack('<i', self.seq))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_updates = reader.read_int()
        _list_updates = []
        for _ in range(_count_updates):
            _item_updates = reader.tgread_object()
            _list_updates.append(_item_updates)
        _args['updates'] = _list_updates
        reader.read_int(signed=False)  # skip vector id
        _count_users = reader.read_int()
        _list_users = []
        for _ in range(_count_users):
            _item_users = reader.tgread_object()
            _list_users.append(_item_users)
        _args['users'] = _list_users
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.tgread_object()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        _val_date = reader.read_int()
        _args['date'] = _val_date
        _val_seq_start = reader.read_int()
        _args['seq_start'] = _val_seq_start
        _val_seq = reader.read_int()
        _args['seq'] = _val_seq
        return cls(**_args)


class UpdatesTooLong(TLObject):
    """TL type: updatesTooLong"""
    CONSTRUCTOR_ID = 0xe317af7e
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UpdatesTooLong',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UrlAuthResultAccepted(TLObject):
    """TL type: urlAuthResultAccepted"""
    CONSTRUCTOR_ID = 0x623a8fa0
    SUBCLASS_OF_ID = 0x7765cb1e

    def __init__(self, url: Optional[str] = None):
        self.url = url

    def to_dict(self):
        return {
            '_': 'UrlAuthResultAccepted',
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.url is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        if self.url is not None:
            buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        return cls(**_args)


class UrlAuthResultDefault(TLObject):
    """TL type: urlAuthResultDefault"""
    CONSTRUCTOR_ID = 0xa9d6db1f
    SUBCLASS_OF_ID = 0x7765cb1e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UrlAuthResultDefault',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UrlAuthResultRequest(TLObject):
    """TL type: urlAuthResultRequest"""
    CONSTRUCTOR_ID = 0x32fabf1a
    SUBCLASS_OF_ID = 0x7765cb1e

    def __init__(self, bot: 'TypeUser', domain: str, request_write_access: Optional[bool] = None, request_phone_number: Optional[bool] = None, browser: Optional[str] = None, platform: Optional[str] = None, ip: Optional[str] = None, region: Optional[str] = None):
        self.bot = bot
        self.domain = domain
        self.request_write_access = request_write_access
        self.request_phone_number = request_phone_number
        self.browser = browser
        self.platform = platform
        self.ip = ip
        self.region = region

    def to_dict(self):
        return {
            '_': 'UrlAuthResultRequest',
            'bot': self.bot,
            'domain': self.domain,
            'request_write_access': self.request_write_access,
            'request_phone_number': self.request_phone_number,
            'browser': self.browser,
            'platform': self.platform,
            'ip': self.ip,
            'region': self.region,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.request_write_access:
            flags |= (1 << 0)
        if self.request_phone_number:
            flags |= (1 << 1)
        if self.region is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.bot))
        buf.write(TLObject.serialize_bytes(self.domain))
        if self.browser is not None:
            buf.write(TLObject.serialize_bytes(self.browser))
        if self.platform is not None:
            buf.write(TLObject.serialize_bytes(self.platform))
        if self.ip is not None:
            buf.write(TLObject.serialize_bytes(self.ip))
        if self.region is not None:
            buf.write(TLObject.serialize_bytes(self.region))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['request_write_access'] = bool(flags & (1 << 0))
        _args['request_phone_number'] = bool(flags & (1 << 1))
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        _val_domain = reader.tgread_string()
        _args['domain'] = _val_domain
        if flags & (1 << 2):
            _val_browser = reader.tgread_string()
            _args['browser'] = _val_browser
        else:
            _args['browser'] = None
        if flags & (1 << 2):
            _val_platform = reader.tgread_string()
            _args['platform'] = _val_platform
        else:
            _args['platform'] = None
        if flags & (1 << 2):
            _val_ip = reader.tgread_string()
            _args['ip'] = _val_ip
        else:
            _args['ip'] = None
        if flags & (1 << 2):
            _val_region = reader.tgread_string()
            _args['region'] = _val_region
        else:
            _args['region'] = None
        return cls(**_args)


class User(TLObject):
    """TL type: user"""
    CONSTRUCTOR_ID = 0x31774388
    SUBCLASS_OF_ID = 0x2da17977

    def __init__(self, id: int, is_self: Optional[bool] = None, contact: Optional[bool] = None, mutual_contact: Optional[bool] = None, deleted: Optional[bool] = None, bot: Optional[bool] = None, bot_chat_history: Optional[bool] = None, bot_nochats: Optional[bool] = None, verified: Optional[bool] = None, restricted: Optional[bool] = None, min: Optional[bool] = None, bot_inline_geo: Optional[bool] = None, support: Optional[bool] = None, scam: Optional[bool] = None, apply_min_photo: Optional[bool] = None, fake: Optional[bool] = None, bot_attach_menu: Optional[bool] = None, premium: Optional[bool] = None, attach_menu_enabled: Optional[bool] = None, bot_can_edit: Optional[bool] = None, close_friend: Optional[bool] = None, stories_hidden: Optional[bool] = None, stories_unavailable: Optional[bool] = None, contact_require_premium: Optional[bool] = None, bot_business: Optional[bool] = None, bot_has_main_app: Optional[bool] = None, bot_forum_view: Optional[bool] = None, bot_forum_can_manage_topics: Optional[bool] = None, access_hash: Optional[int] = None, first_name: Optional[str] = None, last_name: Optional[str] = None, username: Optional[str] = None, phone: Optional[str] = None, photo: Optional['TypeUserProfilePhoto'] = None, status: Optional['TypeUserStatus'] = None, bot_info_version: Optional[int] = None, restriction_reason: Optional[List['TypeRestrictionReason']] = None, bot_inline_placeholder: Optional[str] = None, lang_code: Optional[str] = None, emoji_status: Optional['TypeEmojiStatus'] = None, usernames: Optional[List['TypeUsername']] = None, stories_max_id: Optional['TypeRecentStory'] = None, color: Optional['TypePeerColor'] = None, profile_color: Optional['TypePeerColor'] = None, bot_active_users: Optional[int] = None, bot_verification_icon: Optional[int] = None, send_paid_messages_stars: Optional[int] = None):
        self.id = id
        self.is_self = is_self
        self.contact = contact
        self.mutual_contact = mutual_contact
        self.deleted = deleted
        self.bot = bot
        self.bot_chat_history = bot_chat_history
        self.bot_nochats = bot_nochats
        self.verified = verified
        self.restricted = restricted
        self.min = min
        self.bot_inline_geo = bot_inline_geo
        self.support = support
        self.scam = scam
        self.apply_min_photo = apply_min_photo
        self.fake = fake
        self.bot_attach_menu = bot_attach_menu
        self.premium = premium
        self.attach_menu_enabled = attach_menu_enabled
        self.bot_can_edit = bot_can_edit
        self.close_friend = close_friend
        self.stories_hidden = stories_hidden
        self.stories_unavailable = stories_unavailable
        self.contact_require_premium = contact_require_premium
        self.bot_business = bot_business
        self.bot_has_main_app = bot_has_main_app
        self.bot_forum_view = bot_forum_view
        self.bot_forum_can_manage_topics = bot_forum_can_manage_topics
        self.access_hash = access_hash
        self.first_name = first_name
        self.last_name = last_name
        self.username = username
        self.phone = phone
        self.photo = photo
        self.status = status
        self.bot_info_version = bot_info_version
        self.restriction_reason = restriction_reason
        self.bot_inline_placeholder = bot_inline_placeholder
        self.lang_code = lang_code
        self.emoji_status = emoji_status
        self.usernames = usernames
        self.stories_max_id = stories_max_id
        self.color = color
        self.profile_color = profile_color
        self.bot_active_users = bot_active_users
        self.bot_verification_icon = bot_verification_icon
        self.send_paid_messages_stars = send_paid_messages_stars

    def to_dict(self):
        return {
            '_': 'User',
            'id': self.id,
            'is_self': self.is_self,
            'contact': self.contact,
            'mutual_contact': self.mutual_contact,
            'deleted': self.deleted,
            'bot': self.bot,
            'bot_chat_history': self.bot_chat_history,
            'bot_nochats': self.bot_nochats,
            'verified': self.verified,
            'restricted': self.restricted,
            'min': self.min,
            'bot_inline_geo': self.bot_inline_geo,
            'support': self.support,
            'scam': self.scam,
            'apply_min_photo': self.apply_min_photo,
            'fake': self.fake,
            'bot_attach_menu': self.bot_attach_menu,
            'premium': self.premium,
            'attach_menu_enabled': self.attach_menu_enabled,
            'bot_can_edit': self.bot_can_edit,
            'close_friend': self.close_friend,
            'stories_hidden': self.stories_hidden,
            'stories_unavailable': self.stories_unavailable,
            'contact_require_premium': self.contact_require_premium,
            'bot_business': self.bot_business,
            'bot_has_main_app': self.bot_has_main_app,
            'bot_forum_view': self.bot_forum_view,
            'bot_forum_can_manage_topics': self.bot_forum_can_manage_topics,
            'access_hash': self.access_hash,
            'first_name': self.first_name,
            'last_name': self.last_name,
            'username': self.username,
            'phone': self.phone,
            'photo': self.photo,
            'status': self.status,
            'bot_info_version': self.bot_info_version,
            'restriction_reason': self.restriction_reason,
            'bot_inline_placeholder': self.bot_inline_placeholder,
            'lang_code': self.lang_code,
            'emoji_status': self.emoji_status,
            'usernames': self.usernames,
            'stories_max_id': self.stories_max_id,
            'color': self.color,
            'profile_color': self.profile_color,
            'bot_active_users': self.bot_active_users,
            'bot_verification_icon': self.bot_verification_icon,
            'send_paid_messages_stars': self.send_paid_messages_stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.is_self:
            flags |= (1 << 10)
        if self.contact:
            flags |= (1 << 11)
        if self.mutual_contact:
            flags |= (1 << 12)
        if self.deleted:
            flags |= (1 << 13)
        if self.bot_info_version is not None:
            flags |= (1 << 14)
        if self.bot_chat_history:
            flags |= (1 << 15)
        if self.bot_nochats:
            flags |= (1 << 16)
        if self.verified:
            flags |= (1 << 17)
        if self.restriction_reason is not None:
            flags |= (1 << 18)
        if self.min:
            flags |= (1 << 20)
        if self.bot_inline_geo:
            flags |= (1 << 21)
        if self.support:
            flags |= (1 << 23)
        if self.scam:
            flags |= (1 << 24)
        if self.apply_min_photo:
            flags |= (1 << 25)
        if self.fake:
            flags |= (1 << 26)
        if self.bot_attach_menu:
            flags |= (1 << 27)
        if self.premium:
            flags |= (1 << 28)
        if self.attach_menu_enabled:
            flags |= (1 << 29)
        if self.access_hash is not None:
            flags |= (1 << 0)
        if self.first_name is not None:
            flags |= (1 << 1)
        if self.last_name is not None:
            flags |= (1 << 2)
        if self.username is not None:
            flags |= (1 << 3)
        if self.phone is not None:
            flags |= (1 << 4)
        if self.photo is not None:
            flags |= (1 << 5)
        if self.status is not None:
            flags |= (1 << 6)
        if self.bot_inline_placeholder is not None:
            flags |= (1 << 19)
        if self.lang_code is not None:
            flags |= (1 << 22)
        if self.emoji_status is not None:
            flags |= (1 << 30)
        flags2 = 0
        if self.bot_can_edit:
            flags2 |= (1 << 1)
        if self.close_friend:
            flags2 |= (1 << 2)
        if self.stories_hidden:
            flags2 |= (1 << 3)
        if self.stories_unavailable:
            flags2 |= (1 << 4)
        if self.contact_require_premium:
            flags2 |= (1 << 10)
        if self.bot_business:
            flags2 |= (1 << 11)
        if self.bot_has_main_app:
            flags2 |= (1 << 13)
        if self.bot_forum_view:
            flags2 |= (1 << 16)
        if self.bot_forum_can_manage_topics:
            flags2 |= (1 << 17)
        if self.usernames is not None:
            flags2 |= (1 << 0)
        if self.stories_max_id is not None:
            flags2 |= (1 << 5)
        if self.color is not None:
            flags2 |= (1 << 8)
        if self.profile_color is not None:
            flags2 |= (1 << 9)
        if self.bot_active_users is not None:
            flags2 |= (1 << 12)
        if self.bot_verification_icon is not None:
            flags2 |= (1 << 14)
        if self.send_paid_messages_stars is not None:
            flags2 |= (1 << 15)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<I', flags2))
        buf.write(struct.pack('<q', self.id))
        if self.access_hash is not None:
            buf.write(struct.pack('<q', self.access_hash))
        if self.first_name is not None:
            buf.write(TLObject.serialize_bytes(self.first_name))
        if self.last_name is not None:
            buf.write(TLObject.serialize_bytes(self.last_name))
        if self.username is not None:
            buf.write(TLObject.serialize_bytes(self.username))
        if self.phone is not None:
            buf.write(TLObject.serialize_bytes(self.phone))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        if self.status is not None:
            buf.write(bytes(self.status))
        if self.bot_info_version is not None:
            buf.write(struct.pack('<i', self.bot_info_version))
        if self.restriction_reason is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.restriction_reason)))
            for item in self.restriction_reason:
                buf.write(bytes(self.item))
        if self.bot_inline_placeholder is not None:
            buf.write(TLObject.serialize_bytes(self.bot_inline_placeholder))
        if self.lang_code is not None:
            buf.write(TLObject.serialize_bytes(self.lang_code))
        if self.emoji_status is not None:
            buf.write(bytes(self.emoji_status))
        if self.usernames is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.usernames)))
            for item in self.usernames:
                buf.write(bytes(self.item))
        if self.stories_max_id is not None:
            buf.write(bytes(self.stories_max_id))
        if self.color is not None:
            buf.write(bytes(self.color))
        if self.profile_color is not None:
            buf.write(bytes(self.profile_color))
        if self.bot_active_users is not None:
            buf.write(struct.pack('<i', self.bot_active_users))
        if self.bot_verification_icon is not None:
            buf.write(struct.pack('<q', self.bot_verification_icon))
        if self.send_paid_messages_stars is not None:
            buf.write(struct.pack('<q', self.send_paid_messages_stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['is_self'] = bool(flags & (1 << 10))
        _args['contact'] = bool(flags & (1 << 11))
        _args['mutual_contact'] = bool(flags & (1 << 12))
        _args['deleted'] = bool(flags & (1 << 13))
        _args['bot'] = bool(flags & (1 << 14))
        _args['bot_chat_history'] = bool(flags & (1 << 15))
        _args['bot_nochats'] = bool(flags & (1 << 16))
        _args['verified'] = bool(flags & (1 << 17))
        _args['restricted'] = bool(flags & (1 << 18))
        _args['min'] = bool(flags & (1 << 20))
        _args['bot_inline_geo'] = bool(flags & (1 << 21))
        _args['support'] = bool(flags & (1 << 23))
        _args['scam'] = bool(flags & (1 << 24))
        _args['apply_min_photo'] = bool(flags & (1 << 25))
        _args['fake'] = bool(flags & (1 << 26))
        _args['bot_attach_menu'] = bool(flags & (1 << 27))
        _args['premium'] = bool(flags & (1 << 28))
        _args['attach_menu_enabled'] = bool(flags & (1 << 29))
        flags2 = reader.read_int(signed=False)
        _args['bot_can_edit'] = bool(flags2 & (1 << 1))
        _args['close_friend'] = bool(flags2 & (1 << 2))
        _args['stories_hidden'] = bool(flags2 & (1 << 3))
        _args['stories_unavailable'] = bool(flags2 & (1 << 4))
        _args['contact_require_premium'] = bool(flags2 & (1 << 10))
        _args['bot_business'] = bool(flags2 & (1 << 11))
        _args['bot_has_main_app'] = bool(flags2 & (1 << 13))
        _args['bot_forum_view'] = bool(flags2 & (1 << 16))
        _args['bot_forum_can_manage_topics'] = bool(flags2 & (1 << 17))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        if flags & (1 << 0):
            _val_access_hash = reader.read_long()
            _args['access_hash'] = _val_access_hash
        else:
            _args['access_hash'] = None
        if flags & (1 << 1):
            _val_first_name = reader.tgread_string()
            _args['first_name'] = _val_first_name
        else:
            _args['first_name'] = None
        if flags & (1 << 2):
            _val_last_name = reader.tgread_string()
            _args['last_name'] = _val_last_name
        else:
            _args['last_name'] = None
        if flags & (1 << 3):
            _val_username = reader.tgread_string()
            _args['username'] = _val_username
        else:
            _args['username'] = None
        if flags & (1 << 4):
            _val_phone = reader.tgread_string()
            _args['phone'] = _val_phone
        else:
            _args['phone'] = None
        if flags & (1 << 5):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        if flags & (1 << 6):
            _val_status = reader.tgread_object()
            _args['status'] = _val_status
        else:
            _args['status'] = None
        if flags & (1 << 14):
            _val_bot_info_version = reader.read_int()
            _args['bot_info_version'] = _val_bot_info_version
        else:
            _args['bot_info_version'] = None
        if flags & (1 << 18):
            reader.read_int(signed=False)  # skip vector id
            _count_restriction_reason = reader.read_int()
            _list_restriction_reason = []
            for _ in range(_count_restriction_reason):
                _item_restriction_reason = reader.tgread_object()
                _list_restriction_reason.append(_item_restriction_reason)
            _args['restriction_reason'] = _list_restriction_reason
        else:
            _args['restriction_reason'] = None
        if flags & (1 << 19):
            _val_bot_inline_placeholder = reader.tgread_string()
            _args['bot_inline_placeholder'] = _val_bot_inline_placeholder
        else:
            _args['bot_inline_placeholder'] = None
        if flags & (1 << 22):
            _val_lang_code = reader.tgread_string()
            _args['lang_code'] = _val_lang_code
        else:
            _args['lang_code'] = None
        if flags & (1 << 30):
            _val_emoji_status = reader.tgread_object()
            _args['emoji_status'] = _val_emoji_status
        else:
            _args['emoji_status'] = None
        if flags2 & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_usernames = reader.read_int()
            _list_usernames = []
            for _ in range(_count_usernames):
                _item_usernames = reader.tgread_object()
                _list_usernames.append(_item_usernames)
            _args['usernames'] = _list_usernames
        else:
            _args['usernames'] = None
        if flags2 & (1 << 5):
            _val_stories_max_id = reader.tgread_object()
            _args['stories_max_id'] = _val_stories_max_id
        else:
            _args['stories_max_id'] = None
        if flags2 & (1 << 8):
            _val_color = reader.tgread_object()
            _args['color'] = _val_color
        else:
            _args['color'] = None
        if flags2 & (1 << 9):
            _val_profile_color = reader.tgread_object()
            _args['profile_color'] = _val_profile_color
        else:
            _args['profile_color'] = None
        if flags2 & (1 << 12):
            _val_bot_active_users = reader.read_int()
            _args['bot_active_users'] = _val_bot_active_users
        else:
            _args['bot_active_users'] = None
        if flags2 & (1 << 14):
            _val_bot_verification_icon = reader.read_long()
            _args['bot_verification_icon'] = _val_bot_verification_icon
        else:
            _args['bot_verification_icon'] = None
        if flags2 & (1 << 15):
            _val_send_paid_messages_stars = reader.read_long()
            _args['send_paid_messages_stars'] = _val_send_paid_messages_stars
        else:
            _args['send_paid_messages_stars'] = None
        return cls(**_args)


class UserEmpty(TLObject):
    """TL type: userEmpty"""
    CONSTRUCTOR_ID = 0xd3bc4b7a
    SUBCLASS_OF_ID = 0x2da17977

    def __init__(self, id: int):
        self.id = id

    def to_dict(self):
        return {
            '_': 'UserEmpty',
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        return cls(**_args)


class UserFull(TLObject):
    """TL type: userFull"""
    CONSTRUCTOR_ID = 0xa02bc13e
    SUBCLASS_OF_ID = 0x1f4661b9

    def __init__(self, id: int, settings: 'TypePeerSettings', notify_settings: 'TypePeerNotifySettings', common_chats_count: int, blocked: Optional[bool] = None, phone_calls_available: Optional[bool] = None, phone_calls_private: Optional[bool] = None, can_pin_message: Optional[bool] = None, has_scheduled: Optional[bool] = None, video_calls_available: Optional[bool] = None, voice_messages_forbidden: Optional[bool] = None, translations_disabled: Optional[bool] = None, stories_pinned_available: Optional[bool] = None, blocked_my_stories_from: Optional[bool] = None, wallpaper_overridden: Optional[bool] = None, contact_require_premium: Optional[bool] = None, read_dates_private: Optional[bool] = None, sponsored_enabled: Optional[bool] = None, can_view_revenue: Optional[bool] = None, bot_can_manage_emoji_status: Optional[bool] = None, display_gifts_button: Optional[bool] = None, about: Optional[str] = None, personal_photo: Optional['TypePhoto'] = None, profile_photo: Optional['TypePhoto'] = None, fallback_photo: Optional['TypePhoto'] = None, bot_info: Optional['TypeBotInfo'] = None, pinned_msg_id: Optional[int] = None, folder_id: Optional[int] = None, ttl_period: Optional[int] = None, theme: Optional['TypeChatTheme'] = None, private_forward_name: Optional[str] = None, bot_group_admin_rights: Optional['TypeChatAdminRights'] = None, bot_broadcast_admin_rights: Optional['TypeChatAdminRights'] = None, wallpaper: Optional['TypeWallPaper'] = None, stories: Optional['TypePeerStories'] = None, business_work_hours: Optional['TypeBusinessWorkHours'] = None, business_location: Optional['TypeBusinessLocation'] = None, business_greeting_message: Optional['TypeBusinessGreetingMessage'] = None, business_away_message: Optional['TypeBusinessAwayMessage'] = None, business_intro: Optional['TypeBusinessIntro'] = None, birthday: Optional['TypeBirthday'] = None, personal_channel_id: Optional[int] = None, personal_channel_message: Optional[int] = None, stargifts_count: Optional[int] = None, starref_program: Optional['TypeStarRefProgram'] = None, bot_verification: Optional['TypeBotVerification'] = None, send_paid_messages_stars: Optional[int] = None, disallowed_gifts: Optional['TypeDisallowedGiftsSettings'] = None, stars_rating: Optional['TypeStarsRating'] = None, stars_my_pending_rating: Optional['TypeStarsRating'] = None, stars_my_pending_rating_date: Optional[datetime] = None, main_tab: Optional['TypeProfileTab'] = None, saved_music: Optional['TypeDocument'] = None, note: Optional['TypeTextWithEntities'] = None):
        self.id = id
        self.settings = settings
        self.notify_settings = notify_settings
        self.common_chats_count = common_chats_count
        self.blocked = blocked
        self.phone_calls_available = phone_calls_available
        self.phone_calls_private = phone_calls_private
        self.can_pin_message = can_pin_message
        self.has_scheduled = has_scheduled
        self.video_calls_available = video_calls_available
        self.voice_messages_forbidden = voice_messages_forbidden
        self.translations_disabled = translations_disabled
        self.stories_pinned_available = stories_pinned_available
        self.blocked_my_stories_from = blocked_my_stories_from
        self.wallpaper_overridden = wallpaper_overridden
        self.contact_require_premium = contact_require_premium
        self.read_dates_private = read_dates_private
        self.sponsored_enabled = sponsored_enabled
        self.can_view_revenue = can_view_revenue
        self.bot_can_manage_emoji_status = bot_can_manage_emoji_status
        self.display_gifts_button = display_gifts_button
        self.about = about
        self.personal_photo = personal_photo
        self.profile_photo = profile_photo
        self.fallback_photo = fallback_photo
        self.bot_info = bot_info
        self.pinned_msg_id = pinned_msg_id
        self.folder_id = folder_id
        self.ttl_period = ttl_period
        self.theme = theme
        self.private_forward_name = private_forward_name
        self.bot_group_admin_rights = bot_group_admin_rights
        self.bot_broadcast_admin_rights = bot_broadcast_admin_rights
        self.wallpaper = wallpaper
        self.stories = stories
        self.business_work_hours = business_work_hours
        self.business_location = business_location
        self.business_greeting_message = business_greeting_message
        self.business_away_message = business_away_message
        self.business_intro = business_intro
        self.birthday = birthday
        self.personal_channel_id = personal_channel_id
        self.personal_channel_message = personal_channel_message
        self.stargifts_count = stargifts_count
        self.starref_program = starref_program
        self.bot_verification = bot_verification
        self.send_paid_messages_stars = send_paid_messages_stars
        self.disallowed_gifts = disallowed_gifts
        self.stars_rating = stars_rating
        self.stars_my_pending_rating = stars_my_pending_rating
        self.stars_my_pending_rating_date = stars_my_pending_rating_date
        self.main_tab = main_tab
        self.saved_music = saved_music
        self.note = note

    def to_dict(self):
        return {
            '_': 'UserFull',
            'id': self.id,
            'settings': self.settings,
            'notify_settings': self.notify_settings,
            'common_chats_count': self.common_chats_count,
            'blocked': self.blocked,
            'phone_calls_available': self.phone_calls_available,
            'phone_calls_private': self.phone_calls_private,
            'can_pin_message': self.can_pin_message,
            'has_scheduled': self.has_scheduled,
            'video_calls_available': self.video_calls_available,
            'voice_messages_forbidden': self.voice_messages_forbidden,
            'translations_disabled': self.translations_disabled,
            'stories_pinned_available': self.stories_pinned_available,
            'blocked_my_stories_from': self.blocked_my_stories_from,
            'wallpaper_overridden': self.wallpaper_overridden,
            'contact_require_premium': self.contact_require_premium,
            'read_dates_private': self.read_dates_private,
            'sponsored_enabled': self.sponsored_enabled,
            'can_view_revenue': self.can_view_revenue,
            'bot_can_manage_emoji_status': self.bot_can_manage_emoji_status,
            'display_gifts_button': self.display_gifts_button,
            'about': self.about,
            'personal_photo': self.personal_photo,
            'profile_photo': self.profile_photo,
            'fallback_photo': self.fallback_photo,
            'bot_info': self.bot_info,
            'pinned_msg_id': self.pinned_msg_id,
            'folder_id': self.folder_id,
            'ttl_period': self.ttl_period,
            'theme': self.theme,
            'private_forward_name': self.private_forward_name,
            'bot_group_admin_rights': self.bot_group_admin_rights,
            'bot_broadcast_admin_rights': self.bot_broadcast_admin_rights,
            'wallpaper': self.wallpaper,
            'stories': self.stories,
            'business_work_hours': self.business_work_hours,
            'business_location': self.business_location,
            'business_greeting_message': self.business_greeting_message,
            'business_away_message': self.business_away_message,
            'business_intro': self.business_intro,
            'birthday': self.birthday,
            'personal_channel_id': self.personal_channel_id,
            'personal_channel_message': self.personal_channel_message,
            'stargifts_count': self.stargifts_count,
            'starref_program': self.starref_program,
            'bot_verification': self.bot_verification,
            'send_paid_messages_stars': self.send_paid_messages_stars,
            'disallowed_gifts': self.disallowed_gifts,
            'stars_rating': self.stars_rating,
            'stars_my_pending_rating': self.stars_my_pending_rating,
            'stars_my_pending_rating_date': self.stars_my_pending_rating_date,
            'main_tab': self.main_tab,
            'saved_music': self.saved_music,
            'note': self.note,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.blocked:
            flags |= (1 << 0)
        if self.phone_calls_available:
            flags |= (1 << 4)
        if self.phone_calls_private:
            flags |= (1 << 5)
        if self.can_pin_message:
            flags |= (1 << 7)
        if self.has_scheduled:
            flags |= (1 << 12)
        if self.video_calls_available:
            flags |= (1 << 13)
        if self.voice_messages_forbidden:
            flags |= (1 << 20)
        if self.translations_disabled:
            flags |= (1 << 23)
        if self.stories_pinned_available:
            flags |= (1 << 26)
        if self.blocked_my_stories_from:
            flags |= (1 << 27)
        if self.wallpaper_overridden:
            flags |= (1 << 28)
        if self.contact_require_premium:
            flags |= (1 << 29)
        if self.read_dates_private:
            flags |= (1 << 30)
        if self.about is not None:
            flags |= (1 << 1)
        if self.personal_photo is not None:
            flags |= (1 << 21)
        if self.profile_photo is not None:
            flags |= (1 << 2)
        if self.fallback_photo is not None:
            flags |= (1 << 22)
        if self.bot_info is not None:
            flags |= (1 << 3)
        if self.pinned_msg_id is not None:
            flags |= (1 << 6)
        if self.folder_id is not None:
            flags |= (1 << 11)
        if self.ttl_period is not None:
            flags |= (1 << 14)
        if self.theme is not None:
            flags |= (1 << 15)
        if self.private_forward_name is not None:
            flags |= (1 << 16)
        if self.bot_group_admin_rights is not None:
            flags |= (1 << 17)
        if self.bot_broadcast_admin_rights is not None:
            flags |= (1 << 18)
        if self.wallpaper is not None:
            flags |= (1 << 24)
        if self.stories is not None:
            flags |= (1 << 25)
        flags2 = 0
        if self.sponsored_enabled:
            flags2 |= (1 << 7)
        if self.can_view_revenue:
            flags2 |= (1 << 9)
        if self.bot_can_manage_emoji_status:
            flags2 |= (1 << 10)
        if self.display_gifts_button:
            flags2 |= (1 << 16)
        if self.business_work_hours is not None:
            flags2 |= (1 << 0)
        if self.business_location is not None:
            flags2 |= (1 << 1)
        if self.business_greeting_message is not None:
            flags2 |= (1 << 2)
        if self.business_away_message is not None:
            flags2 |= (1 << 3)
        if self.business_intro is not None:
            flags2 |= (1 << 4)
        if self.birthday is not None:
            flags2 |= (1 << 5)
        if self.personal_channel_message is not None:
            flags2 |= (1 << 6)
        if self.stargifts_count is not None:
            flags2 |= (1 << 8)
        if self.starref_program is not None:
            flags2 |= (1 << 11)
        if self.bot_verification is not None:
            flags2 |= (1 << 12)
        if self.send_paid_messages_stars is not None:
            flags2 |= (1 << 14)
        if self.disallowed_gifts is not None:
            flags2 |= (1 << 15)
        if self.stars_rating is not None:
            flags2 |= (1 << 17)
        if self.stars_my_pending_rating_date is not None:
            flags2 |= (1 << 18)
        if self.main_tab is not None:
            flags2 |= (1 << 20)
        if self.saved_music is not None:
            flags2 |= (1 << 21)
        if self.note is not None:
            flags2 |= (1 << 22)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<I', flags2))
        buf.write(struct.pack('<q', self.id))
        buf.write(bytes(self.settings))
        buf.write(bytes(self.notify_settings))
        buf.write(struct.pack('<i', self.common_chats_count))
        if self.about is not None:
            buf.write(TLObject.serialize_bytes(self.about))
        if self.personal_photo is not None:
            buf.write(bytes(self.personal_photo))
        if self.profile_photo is not None:
            buf.write(bytes(self.profile_photo))
        if self.fallback_photo is not None:
            buf.write(bytes(self.fallback_photo))
        if self.bot_info is not None:
            buf.write(bytes(self.bot_info))
        if self.pinned_msg_id is not None:
            buf.write(struct.pack('<i', self.pinned_msg_id))
        if self.folder_id is not None:
            buf.write(struct.pack('<i', self.folder_id))
        if self.ttl_period is not None:
            buf.write(struct.pack('<i', self.ttl_period))
        if self.theme is not None:
            buf.write(bytes(self.theme))
        if self.private_forward_name is not None:
            buf.write(TLObject.serialize_bytes(self.private_forward_name))
        if self.bot_group_admin_rights is not None:
            buf.write(bytes(self.bot_group_admin_rights))
        if self.bot_broadcast_admin_rights is not None:
            buf.write(bytes(self.bot_broadcast_admin_rights))
        if self.wallpaper is not None:
            buf.write(bytes(self.wallpaper))
        if self.stories is not None:
            buf.write(bytes(self.stories))
        if self.business_work_hours is not None:
            buf.write(bytes(self.business_work_hours))
        if self.business_location is not None:
            buf.write(bytes(self.business_location))
        if self.business_greeting_message is not None:
            buf.write(bytes(self.business_greeting_message))
        if self.business_away_message is not None:
            buf.write(bytes(self.business_away_message))
        if self.business_intro is not None:
            buf.write(bytes(self.business_intro))
        if self.birthday is not None:
            buf.write(bytes(self.birthday))
        if self.personal_channel_id is not None:
            buf.write(struct.pack('<q', self.personal_channel_id))
        if self.personal_channel_message is not None:
            buf.write(struct.pack('<i', self.personal_channel_message))
        if self.stargifts_count is not None:
            buf.write(struct.pack('<i', self.stargifts_count))
        if self.starref_program is not None:
            buf.write(bytes(self.starref_program))
        if self.bot_verification is not None:
            buf.write(bytes(self.bot_verification))
        if self.send_paid_messages_stars is not None:
            buf.write(struct.pack('<q', self.send_paid_messages_stars))
        if self.disallowed_gifts is not None:
            buf.write(bytes(self.disallowed_gifts))
        if self.stars_rating is not None:
            buf.write(bytes(self.stars_rating))
        if self.stars_my_pending_rating is not None:
            buf.write(bytes(self.stars_my_pending_rating))
        if self.stars_my_pending_rating_date is not None:
            buf.write(struct.pack('<i', self.stars_my_pending_rating_date))
        if self.main_tab is not None:
            buf.write(bytes(self.main_tab))
        if self.saved_music is not None:
            buf.write(bytes(self.saved_music))
        if self.note is not None:
            buf.write(bytes(self.note))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['blocked'] = bool(flags & (1 << 0))
        _args['phone_calls_available'] = bool(flags & (1 << 4))
        _args['phone_calls_private'] = bool(flags & (1 << 5))
        _args['can_pin_message'] = bool(flags & (1 << 7))
        _args['has_scheduled'] = bool(flags & (1 << 12))
        _args['video_calls_available'] = bool(flags & (1 << 13))
        _args['voice_messages_forbidden'] = bool(flags & (1 << 20))
        _args['translations_disabled'] = bool(flags & (1 << 23))
        _args['stories_pinned_available'] = bool(flags & (1 << 26))
        _args['blocked_my_stories_from'] = bool(flags & (1 << 27))
        _args['wallpaper_overridden'] = bool(flags & (1 << 28))
        _args['contact_require_premium'] = bool(flags & (1 << 29))
        _args['read_dates_private'] = bool(flags & (1 << 30))
        flags2 = reader.read_int(signed=False)
        _args['sponsored_enabled'] = bool(flags2 & (1 << 7))
        _args['can_view_revenue'] = bool(flags2 & (1 << 9))
        _args['bot_can_manage_emoji_status'] = bool(flags2 & (1 << 10))
        _args['display_gifts_button'] = bool(flags2 & (1 << 16))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        if flags & (1 << 1):
            _val_about = reader.tgread_string()
            _args['about'] = _val_about
        else:
            _args['about'] = None
        _val_settings = reader.tgread_object()
        _args['settings'] = _val_settings
        if flags & (1 << 21):
            _val_personal_photo = reader.tgread_object()
            _args['personal_photo'] = _val_personal_photo
        else:
            _args['personal_photo'] = None
        if flags & (1 << 2):
            _val_profile_photo = reader.tgread_object()
            _args['profile_photo'] = _val_profile_photo
        else:
            _args['profile_photo'] = None
        if flags & (1 << 22):
            _val_fallback_photo = reader.tgread_object()
            _args['fallback_photo'] = _val_fallback_photo
        else:
            _args['fallback_photo'] = None
        _val_notify_settings = reader.tgread_object()
        _args['notify_settings'] = _val_notify_settings
        if flags & (1 << 3):
            _val_bot_info = reader.tgread_object()
            _args['bot_info'] = _val_bot_info
        else:
            _args['bot_info'] = None
        if flags & (1 << 6):
            _val_pinned_msg_id = reader.read_int()
            _args['pinned_msg_id'] = _val_pinned_msg_id
        else:
            _args['pinned_msg_id'] = None
        _val_common_chats_count = reader.read_int()
        _args['common_chats_count'] = _val_common_chats_count
        if flags & (1 << 11):
            _val_folder_id = reader.read_int()
            _args['folder_id'] = _val_folder_id
        else:
            _args['folder_id'] = None
        if flags & (1 << 14):
            _val_ttl_period = reader.read_int()
            _args['ttl_period'] = _val_ttl_period
        else:
            _args['ttl_period'] = None
        if flags & (1 << 15):
            _val_theme = reader.tgread_object()
            _args['theme'] = _val_theme
        else:
            _args['theme'] = None
        if flags & (1 << 16):
            _val_private_forward_name = reader.tgread_string()
            _args['private_forward_name'] = _val_private_forward_name
        else:
            _args['private_forward_name'] = None
        if flags & (1 << 17):
            _val_bot_group_admin_rights = reader.tgread_object()
            _args['bot_group_admin_rights'] = _val_bot_group_admin_rights
        else:
            _args['bot_group_admin_rights'] = None
        if flags & (1 << 18):
            _val_bot_broadcast_admin_rights = reader.tgread_object()
            _args['bot_broadcast_admin_rights'] = _val_bot_broadcast_admin_rights
        else:
            _args['bot_broadcast_admin_rights'] = None
        if flags & (1 << 24):
            _val_wallpaper = reader.tgread_object()
            _args['wallpaper'] = _val_wallpaper
        else:
            _args['wallpaper'] = None
        if flags & (1 << 25):
            _val_stories = reader.tgread_object()
            _args['stories'] = _val_stories
        else:
            _args['stories'] = None
        if flags2 & (1 << 0):
            _val_business_work_hours = reader.tgread_object()
            _args['business_work_hours'] = _val_business_work_hours
        else:
            _args['business_work_hours'] = None
        if flags2 & (1 << 1):
            _val_business_location = reader.tgread_object()
            _args['business_location'] = _val_business_location
        else:
            _args['business_location'] = None
        if flags2 & (1 << 2):
            _val_business_greeting_message = reader.tgread_object()
            _args['business_greeting_message'] = _val_business_greeting_message
        else:
            _args['business_greeting_message'] = None
        if flags2 & (1 << 3):
            _val_business_away_message = reader.tgread_object()
            _args['business_away_message'] = _val_business_away_message
        else:
            _args['business_away_message'] = None
        if flags2 & (1 << 4):
            _val_business_intro = reader.tgread_object()
            _args['business_intro'] = _val_business_intro
        else:
            _args['business_intro'] = None
        if flags2 & (1 << 5):
            _val_birthday = reader.tgread_object()
            _args['birthday'] = _val_birthday
        else:
            _args['birthday'] = None
        if flags2 & (1 << 6):
            _val_personal_channel_id = reader.read_long()
            _args['personal_channel_id'] = _val_personal_channel_id
        else:
            _args['personal_channel_id'] = None
        if flags2 & (1 << 6):
            _val_personal_channel_message = reader.read_int()
            _args['personal_channel_message'] = _val_personal_channel_message
        else:
            _args['personal_channel_message'] = None
        if flags2 & (1 << 8):
            _val_stargifts_count = reader.read_int()
            _args['stargifts_count'] = _val_stargifts_count
        else:
            _args['stargifts_count'] = None
        if flags2 & (1 << 11):
            _val_starref_program = reader.tgread_object()
            _args['starref_program'] = _val_starref_program
        else:
            _args['starref_program'] = None
        if flags2 & (1 << 12):
            _val_bot_verification = reader.tgread_object()
            _args['bot_verification'] = _val_bot_verification
        else:
            _args['bot_verification'] = None
        if flags2 & (1 << 14):
            _val_send_paid_messages_stars = reader.read_long()
            _args['send_paid_messages_stars'] = _val_send_paid_messages_stars
        else:
            _args['send_paid_messages_stars'] = None
        if flags2 & (1 << 15):
            _val_disallowed_gifts = reader.tgread_object()
            _args['disallowed_gifts'] = _val_disallowed_gifts
        else:
            _args['disallowed_gifts'] = None
        if flags2 & (1 << 17):
            _val_stars_rating = reader.tgread_object()
            _args['stars_rating'] = _val_stars_rating
        else:
            _args['stars_rating'] = None
        if flags2 & (1 << 18):
            _val_stars_my_pending_rating = reader.tgread_object()
            _args['stars_my_pending_rating'] = _val_stars_my_pending_rating
        else:
            _args['stars_my_pending_rating'] = None
        if flags2 & (1 << 18):
            _val_stars_my_pending_rating_date = reader.read_int()
            _args['stars_my_pending_rating_date'] = _val_stars_my_pending_rating_date
        else:
            _args['stars_my_pending_rating_date'] = None
        if flags2 & (1 << 20):
            _val_main_tab = reader.tgread_object()
            _args['main_tab'] = _val_main_tab
        else:
            _args['main_tab'] = None
        if flags2 & (1 << 21):
            _val_saved_music = reader.tgread_object()
            _args['saved_music'] = _val_saved_music
        else:
            _args['saved_music'] = None
        if flags2 & (1 << 22):
            _val_note = reader.tgread_object()
            _args['note'] = _val_note
        else:
            _args['note'] = None
        return cls(**_args)


class UserProfilePhoto(TLObject):
    """TL type: userProfilePhoto"""
    CONSTRUCTOR_ID = 0x82d1f706
    SUBCLASS_OF_ID = 0xc6338f7d

    def __init__(self, photo_id: int, dc_id: int, has_video: Optional[bool] = None, personal: Optional[bool] = None, stripped_thumb: Optional[bytes] = None):
        self.photo_id = photo_id
        self.dc_id = dc_id
        self.has_video = has_video
        self.personal = personal
        self.stripped_thumb = stripped_thumb

    def to_dict(self):
        return {
            '_': 'UserProfilePhoto',
            'photo_id': self.photo_id,
            'dc_id': self.dc_id,
            'has_video': self.has_video,
            'personal': self.personal,
            'stripped_thumb': self.stripped_thumb,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.has_video:
            flags |= (1 << 0)
        if self.personal:
            flags |= (1 << 2)
        if self.stripped_thumb is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.photo_id))
        buf.write(struct.pack('<i', self.dc_id))
        if self.stripped_thumb is not None:
            buf.write(TLObject.serialize_bytes(self.stripped_thumb))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['has_video'] = bool(flags & (1 << 0))
        _args['personal'] = bool(flags & (1 << 2))
        _val_photo_id = reader.read_long()
        _args['photo_id'] = _val_photo_id
        if flags & (1 << 1):
            _val_stripped_thumb = reader.tgread_bytes()
            _args['stripped_thumb'] = _val_stripped_thumb
        else:
            _args['stripped_thumb'] = None
        _val_dc_id = reader.read_int()
        _args['dc_id'] = _val_dc_id
        return cls(**_args)


class UserProfilePhotoEmpty(TLObject):
    """TL type: userProfilePhotoEmpty"""
    CONSTRUCTOR_ID = 0x4f11bae1
    SUBCLASS_OF_ID = 0xc6338f7d

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UserProfilePhotoEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UserStatusEmpty(TLObject):
    """TL type: userStatusEmpty"""
    CONSTRUCTOR_ID = 0x09d05049
    SUBCLASS_OF_ID = 0x5b0b743e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UserStatusEmpty',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UserStatusHidden(TLObject):
    """TL type: userStatusHidden"""
    CONSTRUCTOR_ID = 0xcf7d64b1
    SUBCLASS_OF_ID = 0x5b0b743e

    def __init__(self):
        pass

    def to_dict(self):
        return {
            '_': 'UserStatusHidden',
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        return cls()


class UserStatusLastMonth(TLObject):
    """TL type: userStatusLastMonth"""
    CONSTRUCTOR_ID = 0x65899777
    SUBCLASS_OF_ID = 0x5b0b743e

    def __init__(self, by_me: Optional[bool] = None):
        self.by_me = by_me

    def to_dict(self):
        return {
            '_': 'UserStatusLastMonth',
            'by_me': self.by_me,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.by_me:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['by_me'] = bool(flags & (1 << 0))
        return cls(**_args)


class UserStatusLastWeek(TLObject):
    """TL type: userStatusLastWeek"""
    CONSTRUCTOR_ID = 0x541a1d1a
    SUBCLASS_OF_ID = 0x5b0b743e

    def __init__(self, by_me: Optional[bool] = None):
        self.by_me = by_me

    def to_dict(self):
        return {
            '_': 'UserStatusLastWeek',
            'by_me': self.by_me,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.by_me:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['by_me'] = bool(flags & (1 << 0))
        return cls(**_args)


class UserStatusOffline(TLObject):
    """TL type: userStatusOffline"""
    CONSTRUCTOR_ID = 0x008c703f
    SUBCLASS_OF_ID = 0x5b0b743e

    def __init__(self, was_online: Optional[datetime]):
        self.was_online = was_online

    def to_dict(self):
        return {
            '_': 'UserStatusOffline',
            'was_online': self.was_online,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.was_online))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_was_online = reader.read_int()
        _args['was_online'] = _val_was_online
        return cls(**_args)


class UserStatusOnline(TLObject):
    """TL type: userStatusOnline"""
    CONSTRUCTOR_ID = 0xedb93949
    SUBCLASS_OF_ID = 0x5b0b743e

    def __init__(self, expires: Optional[datetime]):
        self.expires = expires

    def to_dict(self):
        return {
            '_': 'UserStatusOnline',
            'expires': self.expires,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.expires))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_expires = reader.read_int()
        _args['expires'] = _val_expires
        return cls(**_args)


class UserStatusRecently(TLObject):
    """TL type: userStatusRecently"""
    CONSTRUCTOR_ID = 0x7b197dc8
    SUBCLASS_OF_ID = 0x5b0b743e

    def __init__(self, by_me: Optional[bool] = None):
        self.by_me = by_me

    def to_dict(self):
        return {
            '_': 'UserStatusRecently',
            'by_me': self.by_me,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.by_me:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['by_me'] = bool(flags & (1 << 0))
        return cls(**_args)


class Username(TLObject):
    """TL type: username"""
    CONSTRUCTOR_ID = 0xb4073647
    SUBCLASS_OF_ID = 0x01286421

    def __init__(self, username: str, editable: Optional[bool] = None, active: Optional[bool] = None):
        self.username = username
        self.editable = editable
        self.active = active

    def to_dict(self):
        return {
            '_': 'Username',
            'username': self.username,
            'editable': self.editable,
            'active': self.active,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.editable:
            flags |= (1 << 0)
        if self.active:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.username))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['editable'] = bool(flags & (1 << 0))
        _args['active'] = bool(flags & (1 << 1))
        _val_username = reader.tgread_string()
        _args['username'] = _val_username
        return cls(**_args)


class VideoSize(TLObject):
    """TL type: videoSize"""
    CONSTRUCTOR_ID = 0xde33b094
    SUBCLASS_OF_ID = 0x62f1d509

    def __init__(self, type: str, w: int, h: int, size: int, video_start_ts: Optional[float] = None):
        self.type = type
        self.w = w
        self.h = h
        self.size = size
        self.video_start_ts = video_start_ts

    def to_dict(self):
        return {
            '_': 'VideoSize',
            'type': self.type,
            'w': self.w,
            'h': self.h,
            'size': self.size,
            'video_start_ts': self.video_start_ts,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.video_start_ts is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.type))
        buf.write(struct.pack('<i', self.w))
        buf.write(struct.pack('<i', self.h))
        buf.write(struct.pack('<i', self.size))
        if self.video_start_ts is not None:
            buf.write(struct.pack('<d', self.video_start_ts))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_type = reader.tgread_string()
        _args['type'] = _val_type
        _val_w = reader.read_int()
        _args['w'] = _val_w
        _val_h = reader.read_int()
        _args['h'] = _val_h
        _val_size = reader.read_int()
        _args['size'] = _val_size
        if flags & (1 << 0):
            _val_video_start_ts = reader.read_double()
            _args['video_start_ts'] = _val_video_start_ts
        else:
            _args['video_start_ts'] = None
        return cls(**_args)


class VideoSizeEmojiMarkup(TLObject):
    """TL type: videoSizeEmojiMarkup"""
    CONSTRUCTOR_ID = 0xf85c413c
    SUBCLASS_OF_ID = 0x62f1d509

    def __init__(self, emoji_id: int, background_colors: List[int]):
        self.emoji_id = emoji_id
        self.background_colors = background_colors

    def to_dict(self):
        return {
            '_': 'VideoSizeEmojiMarkup',
            'emoji_id': self.emoji_id,
            'background_colors': self.background_colors,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.emoji_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.background_colors)))
        for item in self.background_colors:
            buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_emoji_id = reader.read_long()
        _args['emoji_id'] = _val_emoji_id
        reader.read_int(signed=False)  # skip vector id
        _count_background_colors = reader.read_int()
        _list_background_colors = []
        for _ in range(_count_background_colors):
            _item_background_colors = reader.read_int()
            _list_background_colors.append(_item_background_colors)
        _args['background_colors'] = _list_background_colors
        return cls(**_args)


class VideoSizeStickerMarkup(TLObject):
    """TL type: videoSizeStickerMarkup"""
    CONSTRUCTOR_ID = 0x0da082fe
    SUBCLASS_OF_ID = 0x62f1d509

    def __init__(self, stickerset: 'TypeInputStickerSet', sticker_id: int, background_colors: List[int]):
        self.stickerset = stickerset
        self.sticker_id = sticker_id
        self.background_colors = background_colors

    def to_dict(self):
        return {
            '_': 'VideoSizeStickerMarkup',
            'stickerset': self.stickerset,
            'sticker_id': self.sticker_id,
            'background_colors': self.background_colors,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.stickerset))
        buf.write(struct.pack('<q', self.sticker_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.background_colors)))
        for item in self.background_colors:
            buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_stickerset = reader.tgread_object()
        _args['stickerset'] = _val_stickerset
        _val_sticker_id = reader.read_long()
        _args['sticker_id'] = _val_sticker_id
        reader.read_int(signed=False)  # skip vector id
        _count_background_colors = reader.read_int()
        _list_background_colors = []
        for _ in range(_count_background_colors):
            _item_background_colors = reader.read_int()
            _list_background_colors.append(_item_background_colors)
        _args['background_colors'] = _list_background_colors
        return cls(**_args)


class WallPaper(TLObject):
    """TL type: wallPaper"""
    CONSTRUCTOR_ID = 0xa437c3ed
    SUBCLASS_OF_ID = 0x96a2c98b

    def __init__(self, id: int, access_hash: int, slug: str, document: 'TypeDocument', creator: Optional[bool] = None, default: Optional[bool] = None, pattern: Optional[bool] = None, dark: Optional[bool] = None, settings: Optional['TypeWallPaperSettings'] = None):
        self.id = id
        self.access_hash = access_hash
        self.slug = slug
        self.document = document
        self.creator = creator
        self.default = default
        self.pattern = pattern
        self.dark = dark
        self.settings = settings

    def to_dict(self):
        return {
            '_': 'WallPaper',
            'id': self.id,
            'access_hash': self.access_hash,
            'slug': self.slug,
            'document': self.document,
            'creator': self.creator,
            'default': self.default,
            'pattern': self.pattern,
            'dark': self.dark,
            'settings': self.settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.creator:
            flags |= (1 << 0)
        if self.default:
            flags |= (1 << 1)
        if self.pattern:
            flags |= (1 << 3)
        if self.dark:
            flags |= (1 << 4)
        if self.settings is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(TLObject.serialize_bytes(self.slug))
        buf.write(bytes(self.document))
        if self.settings is not None:
            buf.write(bytes(self.settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        flags = reader.read_int(signed=False)
        _args['creator'] = bool(flags & (1 << 0))
        _args['default'] = bool(flags & (1 << 1))
        _args['pattern'] = bool(flags & (1 << 3))
        _args['dark'] = bool(flags & (1 << 4))
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_slug = reader.tgread_string()
        _args['slug'] = _val_slug
        _val_document = reader.tgread_object()
        _args['document'] = _val_document
        if flags & (1 << 2):
            _val_settings = reader.tgread_object()
            _args['settings'] = _val_settings
        else:
            _args['settings'] = None
        return cls(**_args)


class WallPaperNoFile(TLObject):
    """TL type: wallPaperNoFile"""
    CONSTRUCTOR_ID = 0xe0804116
    SUBCLASS_OF_ID = 0x96a2c98b

    def __init__(self, id: int, default: Optional[bool] = None, dark: Optional[bool] = None, settings: Optional['TypeWallPaperSettings'] = None):
        self.id = id
        self.default = default
        self.dark = dark
        self.settings = settings

    def to_dict(self):
        return {
            '_': 'WallPaperNoFile',
            'id': self.id,
            'default': self.default,
            'dark': self.dark,
            'settings': self.settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.default:
            flags |= (1 << 1)
        if self.dark:
            flags |= (1 << 4)
        if self.settings is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<I', flags))
        if self.settings is not None:
            buf.write(bytes(self.settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_id = reader.read_long()
        _args['id'] = _val_id
        flags = reader.read_int(signed=False)
        _args['default'] = bool(flags & (1 << 1))
        _args['dark'] = bool(flags & (1 << 4))
        if flags & (1 << 2):
            _val_settings = reader.tgread_object()
            _args['settings'] = _val_settings
        else:
            _args['settings'] = None
        return cls(**_args)


class WallPaperSettings(TLObject):
    """TL type: wallPaperSettings"""
    CONSTRUCTOR_ID = 0x372efcd0
    SUBCLASS_OF_ID = 0x4175e312

    def __init__(self, blur: Optional[bool] = None, motion: Optional[bool] = None, background_color: Optional[int] = None, second_background_color: Optional[int] = None, third_background_color: Optional[int] = None, fourth_background_color: Optional[int] = None, intensity: Optional[int] = None, rotation: Optional[int] = None, emoticon: Optional[str] = None):
        self.blur = blur
        self.motion = motion
        self.background_color = background_color
        self.second_background_color = second_background_color
        self.third_background_color = third_background_color
        self.fourth_background_color = fourth_background_color
        self.intensity = intensity
        self.rotation = rotation
        self.emoticon = emoticon

    def to_dict(self):
        return {
            '_': 'WallPaperSettings',
            'blur': self.blur,
            'motion': self.motion,
            'background_color': self.background_color,
            'second_background_color': self.second_background_color,
            'third_background_color': self.third_background_color,
            'fourth_background_color': self.fourth_background_color,
            'intensity': self.intensity,
            'rotation': self.rotation,
            'emoticon': self.emoticon,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.blur:
            flags |= (1 << 1)
        if self.motion:
            flags |= (1 << 2)
        if self.background_color is not None:
            flags |= (1 << 0)
        if self.rotation is not None:
            flags |= (1 << 4)
        if self.third_background_color is not None:
            flags |= (1 << 5)
        if self.fourth_background_color is not None:
            flags |= (1 << 6)
        if self.intensity is not None:
            flags |= (1 << 3)
        if self.emoticon is not None:
            flags |= (1 << 7)
        buf.write(struct.pack('<I', flags))
        if self.background_color is not None:
            buf.write(struct.pack('<i', self.background_color))
        if self.second_background_color is not None:
            buf.write(struct.pack('<i', self.second_background_color))
        if self.third_background_color is not None:
            buf.write(struct.pack('<i', self.third_background_color))
        if self.fourth_background_color is not None:
            buf.write(struct.pack('<i', self.fourth_background_color))
        if self.intensity is not None:
            buf.write(struct.pack('<i', self.intensity))
        if self.rotation is not None:
            buf.write(struct.pack('<i', self.rotation))
        if self.emoticon is not None:
            buf.write(TLObject.serialize_bytes(self.emoticon))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['blur'] = bool(flags & (1 << 1))
        _args['motion'] = bool(flags & (1 << 2))
        if flags & (1 << 0):
            _val_background_color = reader.read_int()
            _args['background_color'] = _val_background_color
        else:
            _args['background_color'] = None
        if flags & (1 << 4):
            _val_second_background_color = reader.read_int()
            _args['second_background_color'] = _val_second_background_color
        else:
            _args['second_background_color'] = None
        if flags & (1 << 5):
            _val_third_background_color = reader.read_int()
            _args['third_background_color'] = _val_third_background_color
        else:
            _args['third_background_color'] = None
        if flags & (1 << 6):
            _val_fourth_background_color = reader.read_int()
            _args['fourth_background_color'] = _val_fourth_background_color
        else:
            _args['fourth_background_color'] = None
        if flags & (1 << 3):
            _val_intensity = reader.read_int()
            _args['intensity'] = _val_intensity
        else:
            _args['intensity'] = None
        if flags & (1 << 4):
            _val_rotation = reader.read_int()
            _args['rotation'] = _val_rotation
        else:
            _args['rotation'] = None
        if flags & (1 << 7):
            _val_emoticon = reader.tgread_string()
            _args['emoticon'] = _val_emoticon
        else:
            _args['emoticon'] = None
        return cls(**_args)


class WebAuthorization(TLObject):
    """TL type: webAuthorization"""
    CONSTRUCTOR_ID = 0xa6f8f452
    SUBCLASS_OF_ID = 0x03764d30

    def __init__(self, hash: int, bot_id: int, domain: str, browser: str, platform: str, date_created: Optional[datetime], date_active: Optional[datetime], ip: str, region: str):
        self.hash = hash
        self.bot_id = bot_id
        self.domain = domain
        self.browser = browser
        self.platform = platform
        self.date_created = date_created
        self.date_active = date_active
        self.ip = ip
        self.region = region

    def to_dict(self):
        return {
            '_': 'WebAuthorization',
            'hash': self.hash,
            'bot_id': self.bot_id,
            'domain': self.domain,
            'browser': self.browser,
            'platform': self.platform,
            'date_created': self.date_created,
            'date_active': self.date_active,
            'ip': self.ip,
            'region': self.region,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<q', self.hash))
        buf.write(struct.pack('<q', self.bot_id))
        buf.write(TLObject.serialize_bytes(self.domain))
        buf.write(TLObject.serialize_bytes(self.browser))
        buf.write(TLObject.serialize_bytes(self.platform))
        buf.write(struct.pack('<i', self.date_created))
        buf.write(struct.pack('<i', self.date_active))
        buf.write(TLObject.serialize_bytes(self.ip))
        buf.write(TLObject.serialize_bytes(self.region))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        _val_bot_id = reader.read_long()
        _args['bot_id'] = _val_bot_id
        _val_domain = reader.tgread_string()
        _args['domain'] = _val_domain
        _val_browser = reader.tgread_string()
        _args['browser'] = _val_browser
        _val_platform = reader.tgread_string()
        _args['platform'] = _val_platform
        _val_date_created = reader.read_int()
        _args['date_created'] = _val_date_created
        _val_date_active = reader.read_int()
        _args['date_active'] = _val_date_active
        _val_ip = reader.tgread_string()
        _args['ip'] = _val_ip
        _val_region = reader.tgread_string()
        _args['region'] = _val_region
        return cls(**_args)


class WebDocument(TLObject):
    """TL type: webDocument"""
    CONSTRUCTOR_ID = 0x1c570ed1
    SUBCLASS_OF_ID = 0x3b642814

    def __init__(self, url: str, access_hash: int, size: int, mime_type: str, attributes: List['TypeDocumentAttribute']):
        self.url = url
        self.access_hash = access_hash
        self.size = size
        self.mime_type = mime_type
        self.attributes = attributes

    def to_dict(self):
        return {
            '_': 'WebDocument',
            'url': self.url,
            'access_hash': self.access_hash,
            'size': self.size,
            'mime_type': self.mime_type,
            'attributes': self.attributes,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<q', self.access_hash))
        buf.write(struct.pack('<i', self.size))
        buf.write(TLObject.serialize_bytes(self.mime_type))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.attributes)))
        for item in self.attributes:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_access_hash = reader.read_long()
        _args['access_hash'] = _val_access_hash
        _val_size = reader.read_int()
        _args['size'] = _val_size
        _val_mime_type = reader.tgread_string()
        _args['mime_type'] = _val_mime_type
        reader.read_int(signed=False)  # skip vector id
        _count_attributes = reader.read_int()
        _list_attributes = []
        for _ in range(_count_attributes):
            _item_attributes = reader.tgread_object()
            _list_attributes.append(_item_attributes)
        _args['attributes'] = _list_attributes
        return cls(**_args)


class WebDocumentNoProxy(TLObject):
    """TL type: webDocumentNoProxy"""
    CONSTRUCTOR_ID = 0xf9c8bcc6
    SUBCLASS_OF_ID = 0x3b642814

    def __init__(self, url: str, size: int, mime_type: str, attributes: List['TypeDocumentAttribute']):
        self.url = url
        self.size = size
        self.mime_type = mime_type
        self.attributes = attributes

    def to_dict(self):
        return {
            '_': 'WebDocumentNoProxy',
            'url': self.url,
            'size': self.size,
            'mime_type': self.mime_type,
            'attributes': self.attributes,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(struct.pack('<i', self.size))
        buf.write(TLObject.serialize_bytes(self.mime_type))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.attributes)))
        for item in self.attributes:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_size = reader.read_int()
        _args['size'] = _val_size
        _val_mime_type = reader.tgread_string()
        _args['mime_type'] = _val_mime_type
        reader.read_int(signed=False)  # skip vector id
        _count_attributes = reader.read_int()
        _list_attributes = []
        for _ in range(_count_attributes):
            _item_attributes = reader.tgread_object()
            _list_attributes.append(_item_attributes)
        _args['attributes'] = _list_attributes
        return cls(**_args)


class WebPage(TLObject):
    """TL type: webPage"""
    CONSTRUCTOR_ID = 0xe89c45b2
    SUBCLASS_OF_ID = 0x55a97481

    def __init__(self, id: int, url: str, display_url: str, hash: int, has_large_media: Optional[bool] = None, video_cover_photo: Optional[bool] = None, type: Optional[str] = None, site_name: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, photo: Optional['TypePhoto'] = None, embed_url: Optional[str] = None, embed_type: Optional[str] = None, embed_width: Optional[int] = None, embed_height: Optional[int] = None, duration: Optional[int] = None, author: Optional[str] = None, document: Optional['TypeDocument'] = None, cached_page: Optional['TypePage'] = None, attributes: Optional[List['TypeWebPageAttribute']] = None):
        self.id = id
        self.url = url
        self.display_url = display_url
        self.hash = hash
        self.has_large_media = has_large_media
        self.video_cover_photo = video_cover_photo
        self.type = type
        self.site_name = site_name
        self.title = title
        self.description = description
        self.photo = photo
        self.embed_url = embed_url
        self.embed_type = embed_type
        self.embed_width = embed_width
        self.embed_height = embed_height
        self.duration = duration
        self.author = author
        self.document = document
        self.cached_page = cached_page
        self.attributes = attributes

    def to_dict(self):
        return {
            '_': 'WebPage',
            'id': self.id,
            'url': self.url,
            'display_url': self.display_url,
            'hash': self.hash,
            'has_large_media': self.has_large_media,
            'video_cover_photo': self.video_cover_photo,
            'type': self.type,
            'site_name': self.site_name,
            'title': self.title,
            'description': self.description,
            'photo': self.photo,
            'embed_url': self.embed_url,
            'embed_type': self.embed_type,
            'embed_width': self.embed_width,
            'embed_height': self.embed_height,
            'duration': self.duration,
            'author': self.author,
            'document': self.document,
            'cached_page': self.cached_page,
            'attributes': self.attributes,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.has_large_media:
            flags |= (1 << 13)
        if self.video_cover_photo:
            flags |= (1 << 14)
        if self.type is not None:
            flags |= (1 << 0)
        if self.site_name is not None:
            flags |= (1 << 1)
        if self.title is not None:
            flags |= (1 << 2)
        if self.description is not None:
            flags |= (1 << 3)
        if self.photo is not None:
            flags |= (1 << 4)
        if self.embed_type is not None:
            flags |= (1 << 5)
        if self.embed_height is not None:
            flags |= (1 << 6)
        if self.duration is not None:
            flags |= (1 << 7)
        if self.author is not None:
            flags |= (1 << 8)
        if self.document is not None:
            flags |= (1 << 9)
        if self.cached_page is not None:
            flags |= (1 << 10)
        if self.attributes is not None:
            flags |= (1 << 12)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(TLObject.serialize_bytes(self.url))
        buf.write(TLObject.serialize_bytes(self.display_url))
        buf.write(struct.pack('<i', self.hash))
        if self.type is not None:
            buf.write(TLObject.serialize_bytes(self.type))
        if self.site_name is not None:
            buf.write(TLObject.serialize_bytes(self.site_name))
        if self.title is not None:
            buf.write(TLObject.serialize_bytes(self.title))
        if self.description is not None:
            buf.write(TLObject.serialize_bytes(self.description))
        if self.photo is not None:
            buf.write(bytes(self.photo))
        if self.embed_url is not None:
            buf.write(TLObject.serialize_bytes(self.embed_url))
        if self.embed_type is not None:
            buf.write(TLObject.serialize_bytes(self.embed_type))
        if self.embed_width is not None:
            buf.write(struct.pack('<i', self.embed_width))
        if self.embed_height is not None:
            buf.write(struct.pack('<i', self.embed_height))
        if self.duration is not None:
            buf.write(struct.pack('<i', self.duration))
        if self.author is not None:
            buf.write(TLObject.serialize_bytes(self.author))
        if self.document is not None:
            buf.write(bytes(self.document))
        if self.cached_page is not None:
            buf.write(bytes(self.cached_page))
        if self.attributes is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.attributes)))
            for item in self.attributes:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['has_large_media'] = bool(flags & (1 << 13))
        _args['video_cover_photo'] = bool(flags & (1 << 14))
        _val_id = reader.read_long()
        _args['id'] = _val_id
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        _val_display_url = reader.tgread_string()
        _args['display_url'] = _val_display_url
        _val_hash = reader.read_int()
        _args['hash'] = _val_hash
        if flags & (1 << 0):
            _val_type = reader.tgread_string()
            _args['type'] = _val_type
        else:
            _args['type'] = None
        if flags & (1 << 1):
            _val_site_name = reader.tgread_string()
            _args['site_name'] = _val_site_name
        else:
            _args['site_name'] = None
        if flags & (1 << 2):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 3):
            _val_description = reader.tgread_string()
            _args['description'] = _val_description
        else:
            _args['description'] = None
        if flags & (1 << 4):
            _val_photo = reader.tgread_object()
            _args['photo'] = _val_photo
        else:
            _args['photo'] = None
        if flags & (1 << 5):
            _val_embed_url = reader.tgread_string()
            _args['embed_url'] = _val_embed_url
        else:
            _args['embed_url'] = None
        if flags & (1 << 5):
            _val_embed_type = reader.tgread_string()
            _args['embed_type'] = _val_embed_type
        else:
            _args['embed_type'] = None
        if flags & (1 << 6):
            _val_embed_width = reader.read_int()
            _args['embed_width'] = _val_embed_width
        else:
            _args['embed_width'] = None
        if flags & (1 << 6):
            _val_embed_height = reader.read_int()
            _args['embed_height'] = _val_embed_height
        else:
            _args['embed_height'] = None
        if flags & (1 << 7):
            _val_duration = reader.read_int()
            _args['duration'] = _val_duration
        else:
            _args['duration'] = None
        if flags & (1 << 8):
            _val_author = reader.tgread_string()
            _args['author'] = _val_author
        else:
            _args['author'] = None
        if flags & (1 << 9):
            _val_document = reader.tgread_object()
            _args['document'] = _val_document
        else:
            _args['document'] = None
        if flags & (1 << 10):
            _val_cached_page = reader.tgread_object()
            _args['cached_page'] = _val_cached_page
        else:
            _args['cached_page'] = None
        if flags & (1 << 12):
            reader.read_int(signed=False)  # skip vector id
            _count_attributes = reader.read_int()
            _list_attributes = []
            for _ in range(_count_attributes):
                _item_attributes = reader.tgread_object()
                _list_attributes.append(_item_attributes)
            _args['attributes'] = _list_attributes
        else:
            _args['attributes'] = None
        return cls(**_args)


class WebPageAttributeStarGiftAuction(TLObject):
    """TL type: webPageAttributeStarGiftAuction"""
    CONSTRUCTOR_ID = 0x01c641c2
    SUBCLASS_OF_ID = 0xafcfe9c7

    def __init__(self, gift: 'TypeStarGift', end_date: Optional[datetime]):
        self.gift = gift
        self.end_date = end_date

    def to_dict(self):
        return {
            '_': 'WebPageAttributeStarGiftAuction',
            'gift': self.gift,
            'end_date': self.end_date,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.gift))
        buf.write(struct.pack('<i', self.end_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_gift = reader.tgread_object()
        _args['gift'] = _val_gift
        _val_end_date = reader.read_int()
        _args['end_date'] = _val_end_date
        return cls(**_args)


class WebPageAttributeStarGiftCollection(TLObject):
    """TL type: webPageAttributeStarGiftCollection"""
    CONSTRUCTOR_ID = 0x31cad303
    SUBCLASS_OF_ID = 0xafcfe9c7

    def __init__(self, icons: List['TypeDocument']):
        self.icons = icons

    def to_dict(self):
        return {
            '_': 'WebPageAttributeStarGiftCollection',
            'icons': self.icons,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.icons)))
        for item in self.icons:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_icons = reader.read_int()
        _list_icons = []
        for _ in range(_count_icons):
            _item_icons = reader.tgread_object()
            _list_icons.append(_item_icons)
        _args['icons'] = _list_icons
        return cls(**_args)


class WebPageAttributeStickerSet(TLObject):
    """TL type: webPageAttributeStickerSet"""
    CONSTRUCTOR_ID = 0x50cc03d3
    SUBCLASS_OF_ID = 0xafcfe9c7

    def __init__(self, stickers: List['TypeDocument'], emojis: Optional[bool] = None, text_color: Optional[bool] = None):
        self.stickers = stickers
        self.emojis = emojis
        self.text_color = text_color

    def to_dict(self):
        return {
            '_': 'WebPageAttributeStickerSet',
            'stickers': self.stickers,
            'emojis': self.emojis,
            'text_color': self.text_color,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.emojis:
            flags |= (1 << 0)
        if self.text_color:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.stickers)))
        for item in self.stickers:
            buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['emojis'] = bool(flags & (1 << 0))
        _args['text_color'] = bool(flags & (1 << 1))
        reader.read_int(signed=False)  # skip vector id
        _count_stickers = reader.read_int()
        _list_stickers = []
        for _ in range(_count_stickers):
            _item_stickers = reader.tgread_object()
            _list_stickers.append(_item_stickers)
        _args['stickers'] = _list_stickers
        return cls(**_args)


class WebPageAttributeStory(TLObject):
    """TL type: webPageAttributeStory"""
    CONSTRUCTOR_ID = 0x2e94c3e7
    SUBCLASS_OF_ID = 0xafcfe9c7

    def __init__(self, peer: 'TypePeer', id: int, story: Optional['TypeStoryItem'] = None):
        self.peer = peer
        self.id = id
        self.story = story

    def to_dict(self):
        return {
            '_': 'WebPageAttributeStory',
            'peer': self.peer,
            'id': self.id,
            'story': self.story,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.story is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.id))
        if self.story is not None:
            buf.write(bytes(self.story))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_id = reader.read_int()
        _args['id'] = _val_id
        if flags & (1 << 0):
            _val_story = reader.tgread_object()
            _args['story'] = _val_story
        else:
            _args['story'] = None
        return cls(**_args)


class WebPageAttributeTheme(TLObject):
    """TL type: webPageAttributeTheme"""
    CONSTRUCTOR_ID = 0x54b56617
    SUBCLASS_OF_ID = 0xafcfe9c7

    def __init__(self, documents: Optional[List['TypeDocument']] = None, settings: Optional['TypeThemeSettings'] = None):
        self.documents = documents
        self.settings = settings

    def to_dict(self):
        return {
            '_': 'WebPageAttributeTheme',
            'documents': self.documents,
            'settings': self.settings,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.documents is not None:
            flags |= (1 << 0)
        if self.settings is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        if self.documents is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.documents)))
            for item in self.documents:
                buf.write(bytes(self.item))
        if self.settings is not None:
            buf.write(bytes(self.settings))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_documents = reader.read_int()
            _list_documents = []
            for _ in range(_count_documents):
                _item_documents = reader.tgread_object()
                _list_documents.append(_item_documents)
            _args['documents'] = _list_documents
        else:
            _args['documents'] = None
        if flags & (1 << 1):
            _val_settings = reader.tgread_object()
            _args['settings'] = _val_settings
        else:
            _args['settings'] = None
        return cls(**_args)


class WebPageAttributeUniqueStarGift(TLObject):
    """TL type: webPageAttributeUniqueStarGift"""
    CONSTRUCTOR_ID = 0xcf6f6db8
    SUBCLASS_OF_ID = 0xafcfe9c7

    def __init__(self, gift: 'TypeStarGift'):
        self.gift = gift

    def to_dict(self):
        return {
            '_': 'WebPageAttributeUniqueStarGift',
            'gift': self.gift,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.gift))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_gift = reader.tgread_object()
        _args['gift'] = _val_gift
        return cls(**_args)


class WebPageEmpty(TLObject):
    """TL type: webPageEmpty"""
    CONSTRUCTOR_ID = 0x211a1788
    SUBCLASS_OF_ID = 0x55a97481

    def __init__(self, id: int, url: Optional[str] = None):
        self.id = id
        self.url = url

    def to_dict(self):
        return {
            '_': 'WebPageEmpty',
            'id': self.id,
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.url is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        if self.url is not None:
            buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.read_long()
        _args['id'] = _val_id
        if flags & (1 << 0):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        return cls(**_args)


class WebPageNotModified(TLObject):
    """TL type: webPageNotModified"""
    CONSTRUCTOR_ID = 0x7311ca11
    SUBCLASS_OF_ID = 0x55a97481

    def __init__(self, cached_page_views: Optional[int] = None):
        self.cached_page_views = cached_page_views

    def to_dict(self):
        return {
            '_': 'WebPageNotModified',
            'cached_page_views': self.cached_page_views,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.cached_page_views is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        if self.cached_page_views is not None:
            buf.write(struct.pack('<i', self.cached_page_views))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_cached_page_views = reader.read_int()
            _args['cached_page_views'] = _val_cached_page_views
        else:
            _args['cached_page_views'] = None
        return cls(**_args)


class WebPagePending(TLObject):
    """TL type: webPagePending"""
    CONSTRUCTOR_ID = 0xb0d13e47
    SUBCLASS_OF_ID = 0x55a97481

    def __init__(self, id: int, date: Optional[datetime], url: Optional[str] = None):
        self.id = id
        self.date = date
        self.url = url

    def to_dict(self):
        return {
            '_': 'WebPagePending',
            'id': self.id,
            'date': self.date,
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.url is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.id))
        buf.write(struct.pack('<i', self.date))
        if self.url is not None:
            buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_id = reader.read_long()
        _args['id'] = _val_id
        if flags & (1 << 0):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        _val_date = reader.read_int()
        _args['date'] = _val_date
        return cls(**_args)


class WebPageUrlPending(TLObject):
    """TL type: webPageUrlPending"""
    CONSTRUCTOR_ID = 0xd41a5167
    SUBCLASS_OF_ID = 0x55a97481

    def __init__(self, url: str):
        self.url = url

    def to_dict(self):
        return {
            '_': 'WebPageUrlPending',
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)


class WebViewMessageSent(TLObject):
    """TL type: webViewMessageSent"""
    CONSTRUCTOR_ID = 0x0c94511c
    SUBCLASS_OF_ID = 0x75e49312

    def __init__(self, msg_id: Optional['TypeInputBotInlineMessageID'] = None):
        self.msg_id = msg_id

    def to_dict(self):
        return {
            '_': 'WebViewMessageSent',
            'msg_id': self.msg_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.msg_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        if self.msg_id is not None:
            buf.write(bytes(self.msg_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_msg_id = reader.tgread_object()
            _args['msg_id'] = _val_msg_id
        else:
            _args['msg_id'] = None
        return cls(**_args)


class WebViewResultUrl(TLObject):
    """TL type: webViewResultUrl"""
    CONSTRUCTOR_ID = 0x4d22ff98
    SUBCLASS_OF_ID = 0x93cea746

    def __init__(self, url: str, fullsize: Optional[bool] = None, fullscreen: Optional[bool] = None, query_id: Optional[int] = None):
        self.url = url
        self.fullsize = fullsize
        self.fullscreen = fullscreen
        self.query_id = query_id

    def to_dict(self):
        return {
            '_': 'WebViewResultUrl',
            'url': self.url,
            'fullsize': self.fullsize,
            'fullscreen': self.fullscreen,
            'query_id': self.query_id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.fullsize:
            flags |= (1 << 1)
        if self.fullscreen:
            flags |= (1 << 2)
        if self.query_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.url))
        if self.query_id is not None:
            buf.write(struct.pack('<q', self.query_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['fullsize'] = bool(flags & (1 << 1))
        _args['fullscreen'] = bool(flags & (1 << 2))
        if flags & (1 << 0):
            _val_query_id = reader.read_long()
            _args['query_id'] = _val_query_id
        else:
            _args['query_id'] = None
        _val_url = reader.tgread_string()
        _args['url'] = _val_url
        return cls(**_args)

