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


class AcceptEncryptionRequest(TLRequest):
    """TL type: messages.acceptEncryption"""
    CONSTRUCTOR_ID = 0x3dbc0415
    SUBCLASS_OF_ID = 0x6d28a37a

    def __init__(self, peer: 'TypeInputEncryptedChat', g_b: bytes, key_fingerprint: int):
        self.peer = peer
        self.g_b = g_b
        self.key_fingerprint = key_fingerprint

    def to_dict(self):
        return {
            '_': 'AcceptEncryptionRequest',
            'peer': self.peer,
            'g_b': self.g_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(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.g_b))
        buf.write(struct.pack('<q', self.key_fingerprint))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_g_b = reader.tgread_bytes()
        _args['g_b'] = _val_g_b
        _val_key_fingerprint = reader.read_long()
        _args['key_fingerprint'] = _val_key_fingerprint
        return cls(**_args)


class AcceptUrlAuthRequest(TLRequest):
    """TL type: messages.acceptUrlAuth"""
    CONSTRUCTOR_ID = 0xb12c7125
    SUBCLASS_OF_ID = 0x7765cb1e

    def __init__(self, write_allowed: Optional[bool] = None, share_phone_number: Optional[bool] = None, peer: Optional['TypeInputPeer'] = None, msg_id: Optional[int] = None, button_id: Optional[int] = None, url: Optional[str] = None):
        self.write_allowed = write_allowed
        self.share_phone_number = share_phone_number
        self.peer = peer
        self.msg_id = msg_id
        self.button_id = button_id
        self.url = url

    def to_dict(self):
        return {
            '_': 'AcceptUrlAuthRequest',
            'write_allowed': self.write_allowed,
            'share_phone_number': self.share_phone_number,
            'peer': self.peer,
            'msg_id': self.msg_id,
            'button_id': self.button_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.write_allowed:
            flags |= (1 << 0)
        if self.share_phone_number:
            flags |= (1 << 3)
        if self.button_id is not None:
            flags |= (1 << 1)
        if self.url is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.peer is not None:
            buf.write(bytes(self.peer))
        if self.msg_id is not None:
            buf.write(struct.pack('<i', self.msg_id))
        if self.button_id is not None:
            buf.write(struct.pack('<i', self.button_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)
        _args['write_allowed'] = bool(flags & (1 << 0))
        _args['share_phone_number'] = bool(flags & (1 << 3))
        if flags & (1 << 1):
            _val_peer = reader.tgread_object()
            _args['peer'] = _val_peer
        else:
            _args['peer'] = None
        if flags & (1 << 1):
            _val_msg_id = reader.read_int()
            _args['msg_id'] = _val_msg_id
        else:
            _args['msg_id'] = None
        if flags & (1 << 1):
            _val_button_id = reader.read_int()
            _args['button_id'] = _val_button_id
        else:
            _args['button_id'] = None
        if flags & (1 << 2):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        return cls(**_args)


class AddChatUserRequest(TLRequest):
    """TL type: messages.addChatUser"""
    CONSTRUCTOR_ID = 0xcbc6d107
    SUBCLASS_OF_ID = 0x3dbe90a1

    def __init__(self, chat_id: int, user_id: 'TypeInputUser', fwd_limit: int):
        self.chat_id = chat_id
        self.user_id = user_id
        self.fwd_limit = fwd_limit

    def to_dict(self):
        return {
            '_': 'AddChatUserRequest',
            'chat_id': self.chat_id,
            'user_id': self.user_id,
            'fwd_limit': self.fwd_limit,
        }

    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.user_id))
        buf.write(struct.pack('<i', self.fwd_limit))
        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.tgread_object()
        _args['user_id'] = _val_user_id
        _val_fwd_limit = reader.read_int()
        _args['fwd_limit'] = _val_fwd_limit
        return cls(**_args)


class AppendTodoListRequest(TLRequest):
    """TL type: messages.appendTodoList"""
    CONSTRUCTOR_ID = 0x21a61057
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, list: List['TypeTodoItem']):
        self.peer = peer
        self.msg_id = msg_id
        self.list = list

    def to_dict(self):
        return {
            '_': 'AppendTodoListRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'list': self.list,
        }

    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.list)))
        for item in self.list:
            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_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 CheckChatInviteRequest(TLRequest):
    """TL type: messages.checkChatInvite"""
    CONSTRUCTOR_ID = 0x3eadb1bb
    SUBCLASS_OF_ID = 0x04561736

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

    def to_dict(self):
        return {
            '_': 'CheckChatInviteRequest',
            '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 CheckHistoryImportRequest(TLRequest):
    """TL type: messages.checkHistoryImport"""
    CONSTRUCTOR_ID = 0x43fe19f3
    SUBCLASS_OF_ID = 0x5bb2720b

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

    def to_dict(self):
        return {
            '_': 'CheckHistoryImportRequest',
            'import_head': self.import_head,
        }

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

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


class CheckHistoryImportPeerRequest(TLRequest):
    """TL type: messages.checkHistoryImportPeer"""
    CONSTRUCTOR_ID = 0x5dc60f03
    SUBCLASS_OF_ID = 0xb84bb337

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

    def to_dict(self):
        return {
            '_': 'CheckHistoryImportPeerRequest',
            '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 CheckQuickReplyShortcutRequest(TLRequest):
    """TL type: messages.checkQuickReplyShortcut"""
    CONSTRUCTOR_ID = 0xf1d0fbd3
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'CheckQuickReplyShortcutRequest',
            '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 ClearAllDraftsRequest(TLRequest):
    """TL type: messages.clearAllDrafts"""
    CONSTRUCTOR_ID = 0x7e58ee9c
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self):
        pass

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

    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 ClearRecentReactionsRequest(TLRequest):
    """TL type: messages.clearRecentReactions"""
    CONSTRUCTOR_ID = 0x9dfeefb4
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self):
        pass

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

    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 ClearRecentStickersRequest(TLRequest):
    """TL type: messages.clearRecentStickers"""
    CONSTRUCTOR_ID = 0x8999602d
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, attached: Optional[bool] = None):
        self.attached = attached

    def to_dict(self):
        return {
            '_': 'ClearRecentStickersRequest',
            'attached': self.attached,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.attached:
            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['attached'] = bool(flags & (1 << 0))
        return cls(**_args)


class ClickSponsoredMessageRequest(TLRequest):
    """TL type: messages.clickSponsoredMessage"""
    CONSTRUCTOR_ID = 0x8235057e
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, media: Optional[bool] = None, fullscreen: Optional[bool] = None, random_id: bytes = None):
        self.media = media
        self.fullscreen = fullscreen
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'ClickSponsoredMessageRequest',
            'media': self.media,
            'fullscreen': self.fullscreen,
            '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.media:
            flags |= (1 << 0)
        if self.fullscreen:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['media'] = bool(flags & (1 << 0))
        _args['fullscreen'] = bool(flags & (1 << 1))
        _val_random_id = reader.tgread_bytes()
        _args['random_id'] = _val_random_id
        return cls(**_args)


class CreateChatRequest(TLRequest):
    """TL type: messages.createChat"""
    CONSTRUCTOR_ID = 0x92ceddd4
    SUBCLASS_OF_ID = 0x3dbe90a1

    def __init__(self, users: List['TypeInputUser'], title: str, ttl_period: Optional[int] = None):
        self.users = users
        self.title = title
        self.ttl_period = ttl_period

    def to_dict(self):
        return {
            '_': 'CreateChatRequest',
            'users': self.users,
            'title': self.title,
            '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(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.title))
        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)
        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
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        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 CreateForumTopicRequest(TLRequest):
    """TL type: messages.createForumTopic"""
    CONSTRUCTOR_ID = 0x2f98c3d5
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', title: str, title_missing: Optional[bool] = None, icon_color: Optional[int] = None, icon_emoji_id: Optional[int] = None, random_id: int = None, send_as: Optional['TypeInputPeer'] = None):
        self.peer = peer
        self.title = title
        self.title_missing = title_missing
        self.icon_color = icon_color
        self.icon_emoji_id = icon_emoji_id
        self.random_id = random_id
        self.send_as = send_as

    def to_dict(self):
        return {
            '_': 'CreateForumTopicRequest',
            'peer': self.peer,
            'title': self.title,
            'title_missing': self.title_missing,
            'icon_color': self.icon_color,
            'icon_emoji_id': self.icon_emoji_id,
            'random_id': self.random_id,
            'send_as': self.send_as,
        }

    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 << 4)
        if self.icon_color is not None:
            flags |= (1 << 0)
        if self.icon_emoji_id is not None:
            flags |= (1 << 3)
        if self.send_as is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.title))
        if self.icon_color is not None:
            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))
        buf.write(struct.pack('<q', self.random_id))
        if self.send_as is not None:
            buf.write(bytes(self.send_as))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['title_missing'] = bool(flags & (1 << 4))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        if flags & (1 << 0):
            _val_icon_color = reader.read_int()
            _args['icon_color'] = _val_icon_color
        else:
            _args['icon_color'] = None
        if flags & (1 << 3):
            _val_icon_emoji_id = reader.read_long()
            _args['icon_emoji_id'] = _val_icon_emoji_id
        else:
            _args['icon_emoji_id'] = None
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        if flags & (1 << 2):
            _val_send_as = reader.tgread_object()
            _args['send_as'] = _val_send_as
        else:
            _args['send_as'] = None
        return cls(**_args)


class DeleteChatRequest(TLRequest):
    """TL type: messages.deleteChat"""
    CONSTRUCTOR_ID = 0x5bd0ee50
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'DeleteChatRequest',
            '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 DeleteChatUserRequest(TLRequest):
    """TL type: messages.deleteChatUser"""
    CONSTRUCTOR_ID = 0xa2185cab
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, chat_id: int, user_id: 'TypeInputUser', revoke_history: Optional[bool] = None):
        self.chat_id = chat_id
        self.user_id = user_id
        self.revoke_history = revoke_history

    def to_dict(self):
        return {
            '_': 'DeleteChatUserRequest',
            'chat_id': self.chat_id,
            'user_id': self.user_id,
            'revoke_history': self.revoke_history,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['revoke_history'] = bool(flags & (1 << 0))
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class DeleteExportedChatInviteRequest(TLRequest):
    """TL type: messages.deleteExportedChatInvite"""
    CONSTRUCTOR_ID = 0xd464a42b
    SUBCLASS_OF_ID = 0xf5b399ac

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

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

    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.link))
        return buf.getvalue()

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


class DeleteFactCheckRequest(TLRequest):
    """TL type: messages.deleteFactCheck"""
    CONSTRUCTOR_ID = 0xd1da940c
    SUBCLASS_OF_ID = 0x8af52aac

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

    def to_dict(self):
        return {
            '_': 'DeleteFactCheckRequest',
            '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 DeleteHistoryRequest(TLRequest):
    """TL type: messages.deleteHistory"""
    CONSTRUCTOR_ID = 0xb08f922a
    SUBCLASS_OF_ID = 0x2c49c116

    def __init__(self, peer: 'TypeInputPeer', max_id: int, just_clear: Optional[bool] = None, revoke: Optional[bool] = None, min_date: Optional[datetime] = None, max_date: Optional[datetime] = None):
        self.peer = peer
        self.max_id = max_id
        self.just_clear = just_clear
        self.revoke = revoke
        self.min_date = min_date
        self.max_date = max_date

    def to_dict(self):
        return {
            '_': 'DeleteHistoryRequest',
            'peer': self.peer,
            'max_id': self.max_id,
            'just_clear': self.just_clear,
            'revoke': self.revoke,
            '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))
        flags = 0
        if self.just_clear:
            flags |= (1 << 0)
        if self.revoke:
            flags |= (1 << 1)
        if self.min_date is not None:
            flags |= (1 << 2)
        if self.max_date is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.max_id))
        if self.min_date is not None:
            buf.write(struct.pack('<i', self.min_date))
        if self.max_date is not None:
            buf.write(struct.pack('<i', self.max_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['just_clear'] = bool(flags & (1 << 0))
        _args['revoke'] = bool(flags & (1 << 1))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        if flags & (1 << 2):
            _val_min_date = reader.read_int()
            _args['min_date'] = _val_min_date
        else:
            _args['min_date'] = None
        if flags & (1 << 3):
            _val_max_date = reader.read_int()
            _args['max_date'] = _val_max_date
        else:
            _args['max_date'] = None
        return cls(**_args)


class DeleteMessagesRequest(TLRequest):
    """TL type: messages.deleteMessages"""
    CONSTRUCTOR_ID = 0xe58e95d2
    SUBCLASS_OF_ID = 0xced3c06e

    def __init__(self, id: List[int], revoke: Optional[bool] = None):
        self.id = id
        self.revoke = revoke

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

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['revoke'] = bool(flags & (1 << 0))
        reader.read_int(signed=False)  # skip vector id
        _count_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        return cls(**_args)


class DeletePhoneCallHistoryRequest(TLRequest):
    """TL type: messages.deletePhoneCallHistory"""
    CONSTRUCTOR_ID = 0xf9cbe409
    SUBCLASS_OF_ID = 0xf817652e

    def __init__(self, revoke: Optional[bool] = None):
        self.revoke = revoke

    def to_dict(self):
        return {
            '_': 'DeletePhoneCallHistoryRequest',
            'revoke': self.revoke,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.revoke:
            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['revoke'] = bool(flags & (1 << 0))
        return cls(**_args)


class DeleteQuickReplyMessagesRequest(TLRequest):
    """TL type: messages.deleteQuickReplyMessages"""
    CONSTRUCTOR_ID = 0xe105e910
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, shortcut_id: int, id: List[int]):
        self.shortcut_id = shortcut_id
        self.id = id

    def to_dict(self):
        return {
            '_': 'DeleteQuickReplyMessagesRequest',
            'shortcut_id': self.shortcut_id,
            '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.shortcut_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            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_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        return cls(**_args)


class DeleteQuickReplyShortcutRequest(TLRequest):
    """TL type: messages.deleteQuickReplyShortcut"""
    CONSTRUCTOR_ID = 0x3cc04740
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'DeleteQuickReplyShortcutRequest',
            '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 DeleteRevokedExportedChatInvitesRequest(TLRequest):
    """TL type: messages.deleteRevokedExportedChatInvites"""
    CONSTRUCTOR_ID = 0x56987bd5
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'DeleteRevokedExportedChatInvitesRequest',
            'peer': self.peer,
            'admin_id': self.admin_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.admin_id))
        return buf.getvalue()

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


class DeleteSavedHistoryRequest(TLRequest):
    """TL type: messages.deleteSavedHistory"""
    CONSTRUCTOR_ID = 0x4dc5085f
    SUBCLASS_OF_ID = 0x2c49c116

    def __init__(self, peer: 'TypeInputPeer', max_id: int, parent_peer: Optional['TypeInputPeer'] = None, min_date: Optional[datetime] = None, max_date: Optional[datetime] = None):
        self.peer = peer
        self.max_id = max_id
        self.parent_peer = parent_peer
        self.min_date = min_date
        self.max_date = max_date

    def to_dict(self):
        return {
            '_': 'DeleteSavedHistoryRequest',
            'peer': self.peer,
            'max_id': self.max_id,
            'parent_peer': self.parent_peer,
            '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))
        flags = 0
        if self.parent_peer is not None:
            flags |= (1 << 0)
        if self.min_date is not None:
            flags |= (1 << 2)
        if self.max_date is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.max_id))
        if self.parent_peer is not None:
            buf.write(bytes(self.parent_peer))
        if self.min_date is not None:
            buf.write(struct.pack('<i', self.min_date))
        if self.max_date is not None:
            buf.write(struct.pack('<i', self.max_date))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_parent_peer = reader.tgread_object()
            _args['parent_peer'] = _val_parent_peer
        else:
            _args['parent_peer'] = None
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        if flags & (1 << 2):
            _val_min_date = reader.read_int()
            _args['min_date'] = _val_min_date
        else:
            _args['min_date'] = None
        if flags & (1 << 3):
            _val_max_date = reader.read_int()
            _args['max_date'] = _val_max_date
        else:
            _args['max_date'] = None
        return cls(**_args)


class DeleteScheduledMessagesRequest(TLRequest):
    """TL type: messages.deleteScheduledMessages"""
    CONSTRUCTOR_ID = 0x59ae2b16
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', id: List[int]):
        self.peer = peer
        self.id = id

    def to_dict(self):
        return {
            '_': 'DeleteScheduledMessagesRequest',
            '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', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            buf.write(struct.pack('<i', self.item))
        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_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        return cls(**_args)


class DeleteTopicHistoryRequest(TLRequest):
    """TL type: messages.deleteTopicHistory"""
    CONSTRUCTOR_ID = 0xd2816f10
    SUBCLASS_OF_ID = 0x2c49c116

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

    def to_dict(self):
        return {
            '_': 'DeleteTopicHistoryRequest',
            '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 DiscardEncryptionRequest(TLRequest):
    """TL type: messages.discardEncryption"""
    CONSTRUCTOR_ID = 0xf393aea0
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, chat_id: int, delete_history: Optional[bool] = None):
        self.chat_id = chat_id
        self.delete_history = delete_history

    def to_dict(self):
        return {
            '_': 'DiscardEncryptionRequest',
            'chat_id': self.chat_id,
            'delete_history': self.delete_history,
        }

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

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


class EditChatAboutRequest(TLRequest):
    """TL type: messages.editChatAbout"""
    CONSTRUCTOR_ID = 0xdef60797
    SUBCLASS_OF_ID = 0xf5b399ac

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

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

    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.about))
        return buf.getvalue()

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


class EditChatAdminRequest(TLRequest):
    """TL type: messages.editChatAdmin"""
    CONSTRUCTOR_ID = 0xa85bd1c2
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, chat_id: int, user_id: 'TypeInputUser', is_admin: bool):
        self.chat_id = chat_id
        self.user_id = user_id
        self.is_admin = is_admin

    def to_dict(self):
        return {
            '_': 'EditChatAdminRequest',
            'chat_id': self.chat_id,
            'user_id': self.user_id,
            'is_admin': self.is_admin,
        }

    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.user_id))
        buf.write(struct.pack('<I', 0x997275b5 if self.is_admin else 0xbc799737))
        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.tgread_object()
        _args['user_id'] = _val_user_id
        _val_is_admin = reader.tgread_bool()
        _args['is_admin'] = _val_is_admin
        return cls(**_args)


class EditChatDefaultBannedRightsRequest(TLRequest):
    """TL type: messages.editChatDefaultBannedRights"""
    CONSTRUCTOR_ID = 0xa5866b41
    SUBCLASS_OF_ID = 0x8af52aac

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

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

    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.banned_rights))
        return buf.getvalue()

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


class EditChatPhotoRequest(TLRequest):
    """TL type: messages.editChatPhoto"""
    CONSTRUCTOR_ID = 0x35ddd674
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, chat_id: int, photo: 'TypeInputChatPhoto'):
        self.chat_id = chat_id
        self.photo = photo

    def to_dict(self):
        return {
            '_': 'EditChatPhotoRequest',
            'chat_id': self.chat_id,
            'photo': self.photo,
        }

    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.photo))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_chat_id = reader.read_long()
        _args['chat_id'] = _val_chat_id
        _val_photo = reader.tgread_object()
        _args['photo'] = _val_photo
        return cls(**_args)


class EditChatTitleRequest(TLRequest):
    """TL type: messages.editChatTitle"""
    CONSTRUCTOR_ID = 0x73783ffd
    SUBCLASS_OF_ID = 0x8af52aac

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

    def to_dict(self):
        return {
            '_': 'EditChatTitleRequest',
            'chat_id': self.chat_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.chat_id))
        buf.write(TLObject.serialize_bytes(self.title))
        return buf.getvalue()

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


class EditExportedChatInviteRequest(TLRequest):
    """TL type: messages.editExportedChatInvite"""
    CONSTRUCTOR_ID = 0xbdca2f75
    SUBCLASS_OF_ID = 0x82dcd4ca

    def __init__(self, peer: 'TypeInputPeer', link: str, revoked: Optional[bool] = None, expire_date: Optional[datetime] = None, usage_limit: Optional[int] = None, request_needed: Optional[bool] = None, title: Optional[str] = None):
        self.peer = peer
        self.link = link
        self.revoked = revoked
        self.expire_date = expire_date
        self.usage_limit = usage_limit
        self.request_needed = request_needed
        self.title = title

    def to_dict(self):
        return {
            '_': 'EditExportedChatInviteRequest',
            'peer': self.peer,
            'link': self.link,
            'revoked': self.revoked,
            'expire_date': self.expire_date,
            'usage_limit': self.usage_limit,
            'request_needed': self.request_needed,
            'title': self.title,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.revoked:
            flags |= (1 << 2)
        if self.expire_date is not None:
            flags |= (1 << 0)
        if self.usage_limit is not None:
            flags |= (1 << 1)
        if self.request_needed is not None:
            flags |= (1 << 3)
        if self.title is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.link))
        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.request_needed is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.request_needed else 0xbc799737))
        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)
        _args['revoked'] = bool(flags & (1 << 2))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_link = reader.tgread_string()
        _args['link'] = _val_link
        if flags & (1 << 0):
            _val_expire_date = reader.read_int()
            _args['expire_date'] = _val_expire_date
        else:
            _args['expire_date'] = None
        if flags & (1 << 1):
            _val_usage_limit = reader.read_int()
            _args['usage_limit'] = _val_usage_limit
        else:
            _args['usage_limit'] = None
        if flags & (1 << 3):
            _val_request_needed = reader.tgread_bool()
            _args['request_needed'] = _val_request_needed
        else:
            _args['request_needed'] = None
        if flags & (1 << 4):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        return cls(**_args)


class EditFactCheckRequest(TLRequest):
    """TL type: messages.editFactCheck"""
    CONSTRUCTOR_ID = 0x0589ee75
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, text: 'TypeTextWithEntities'):
        self.peer = peer
        self.msg_id = msg_id
        self.text = text

    def to_dict(self):
        return {
            '_': 'EditFactCheckRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'text': self.text,
        }

    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(bytes(self.text))
        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_text = reader.tgread_object()
        _args['text'] = _val_text
        return cls(**_args)


class EditForumTopicRequest(TLRequest):
    """TL type: messages.editForumTopic"""
    CONSTRUCTOR_ID = 0xcecc1134
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', topic_id: int, title: Optional[str] = None, icon_emoji_id: Optional[int] = None, closed: Optional[bool] = None, hidden: Optional[bool] = None):
        self.peer = peer
        self.topic_id = topic_id
        self.title = title
        self.icon_emoji_id = icon_emoji_id
        self.closed = closed
        self.hidden = hidden

    def to_dict(self):
        return {
            '_': 'EditForumTopicRequest',
            'peer': self.peer,
            'topic_id': self.topic_id,
            '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))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.topic_id))
        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)
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_topic_id = reader.read_int()
        _args['topic_id'] = _val_topic_id
        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 EditInlineBotMessageRequest(TLRequest):
    """TL type: messages.editInlineBotMessage"""
    CONSTRUCTOR_ID = 0x83557dba
    SUBCLASS_OF_ID = 0xf5b399ac

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

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

    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 << 16)
        if self.message is not None:
            flags |= (1 << 11)
        if self.media is not None:
            flags |= (1 << 14)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        if self.entities is not None:
            flags |= (1 << 3)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.id))
        if self.message is not None:
            buf.write(TLObject.serialize_bytes(self.message))
        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))
        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 << 16))
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        if flags & (1 << 11):
            _val_message = reader.tgread_string()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        if flags & (1 << 14):
            _val_media = reader.tgread_object()
            _args['media'] = _val_media
        else:
            _args['media'] = None
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        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
        return cls(**_args)


class EditMessageRequest(TLRequest):
    """TL type: messages.editMessage"""
    CONSTRUCTOR_ID = 0x51e842e1
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', id: int, no_webpage: Optional[bool] = None, invert_media: Optional[bool] = None, message: Optional[str] = None, media: Optional['TypeInputMedia'] = None, reply_markup: Optional['TypeReplyMarkup'] = None, entities: Optional[List['TypeMessageEntity']] = None, schedule_date: Optional[datetime] = None, schedule_repeat_period: Optional[int] = None, quick_reply_shortcut_id: Optional[int] = None):
        self.peer = peer
        self.id = id
        self.no_webpage = no_webpage
        self.invert_media = invert_media
        self.message = message
        self.media = media
        self.reply_markup = reply_markup
        self.entities = entities
        self.schedule_date = schedule_date
        self.schedule_repeat_period = schedule_repeat_period
        self.quick_reply_shortcut_id = quick_reply_shortcut_id

    def to_dict(self):
        return {
            '_': 'EditMessageRequest',
            'peer': self.peer,
            'id': self.id,
            'no_webpage': self.no_webpage,
            'invert_media': self.invert_media,
            'message': self.message,
            'media': self.media,
            'reply_markup': self.reply_markup,
            'entities': self.entities,
            'schedule_date': self.schedule_date,
            'schedule_repeat_period': self.schedule_repeat_period,
            'quick_reply_shortcut_id': self.quick_reply_shortcut_id,
        }

    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 << 16)
        if self.message is not None:
            flags |= (1 << 11)
        if self.media is not None:
            flags |= (1 << 14)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        if self.entities is not None:
            flags |= (1 << 3)
        if self.schedule_date is not None:
            flags |= (1 << 15)
        if self.schedule_repeat_period is not None:
            flags |= (1 << 18)
        if self.quick_reply_shortcut_id is not None:
            flags |= (1 << 17)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.id))
        if self.message is not None:
            buf.write(TLObject.serialize_bytes(self.message))
        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.schedule_date is not None:
            buf.write(struct.pack('<i', self.schedule_date))
        if self.schedule_repeat_period is not None:
            buf.write(struct.pack('<i', self.schedule_repeat_period))
        if self.quick_reply_shortcut_id is not None:
            buf.write(struct.pack('<i', self.quick_reply_shortcut_id))
        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 << 16))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_id = reader.read_int()
        _args['id'] = _val_id
        if flags & (1 << 11):
            _val_message = reader.tgread_string()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        if flags & (1 << 14):
            _val_media = reader.tgread_object()
            _args['media'] = _val_media
        else:
            _args['media'] = None
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        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 << 15):
            _val_schedule_date = reader.read_int()
            _args['schedule_date'] = _val_schedule_date
        else:
            _args['schedule_date'] = None
        if flags & (1 << 18):
            _val_schedule_repeat_period = reader.read_int()
            _args['schedule_repeat_period'] = _val_schedule_repeat_period
        else:
            _args['schedule_repeat_period'] = None
        if flags & (1 << 17):
            _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
        return cls(**_args)


class EditQuickReplyShortcutRequest(TLRequest):
    """TL type: messages.editQuickReplyShortcut"""
    CONSTRUCTOR_ID = 0x5c003cef
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, shortcut_id: int, shortcut: str):
        self.shortcut_id = shortcut_id
        self.shortcut = shortcut

    def to_dict(self):
        return {
            '_': 'EditQuickReplyShortcutRequest',
            'shortcut_id': self.shortcut_id,
            'shortcut': self.shortcut,
        }

    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))
        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
        return cls(**_args)


class ExportChatInviteRequest(TLRequest):
    """TL type: messages.exportChatInvite"""
    CONSTRUCTOR_ID = 0xa455de90
    SUBCLASS_OF_ID = 0xb4748a58

    def __init__(self, peer: 'TypeInputPeer', legacy_revoke_permanent: Optional[bool] = None, request_needed: Optional[bool] = None, expire_date: Optional[datetime] = None, usage_limit: Optional[int] = None, title: Optional[str] = None, subscription_pricing: Optional['TypeStarsSubscriptionPricing'] = None):
        self.peer = peer
        self.legacy_revoke_permanent = legacy_revoke_permanent
        self.request_needed = request_needed
        self.expire_date = expire_date
        self.usage_limit = usage_limit
        self.title = title
        self.subscription_pricing = subscription_pricing

    def to_dict(self):
        return {
            '_': 'ExportChatInviteRequest',
            'peer': self.peer,
            'legacy_revoke_permanent': self.legacy_revoke_permanent,
            'request_needed': self.request_needed,
            'expire_date': self.expire_date,
            'usage_limit': self.usage_limit,
            '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.legacy_revoke_permanent:
            flags |= (1 << 2)
        if self.request_needed:
            flags |= (1 << 3)
        if self.expire_date is not None:
            flags |= (1 << 0)
        if self.usage_limit is not None:
            flags |= (1 << 1)
        if self.title is not None:
            flags |= (1 << 4)
        if self.subscription_pricing is not None:
            flags |= (1 << 5)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        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.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['legacy_revoke_permanent'] = bool(flags & (1 << 2))
        _args['request_needed'] = bool(flags & (1 << 3))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _val_expire_date = reader.read_int()
            _args['expire_date'] = _val_expire_date
        else:
            _args['expire_date'] = None
        if flags & (1 << 1):
            _val_usage_limit = reader.read_int()
            _args['usage_limit'] = _val_usage_limit
        else:
            _args['usage_limit'] = None
        if flags & (1 << 4):
            _val_title = reader.tgread_string()
            _args['title'] = _val_title
        else:
            _args['title'] = None
        if flags & (1 << 5):
            _val_subscription_pricing = reader.tgread_object()
            _args['subscription_pricing'] = _val_subscription_pricing
        else:
            _args['subscription_pricing'] = None
        return cls(**_args)


class FaveStickerRequest(TLRequest):
    """TL type: messages.faveSticker"""
    CONSTRUCTOR_ID = 0xb9ffc55b
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, id: 'TypeInputDocument', unfave: bool):
        self.id = id
        self.unfave = unfave

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

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

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


class ForwardMessageRequest(TLRequest):
    """TL type: messages.forwardMessage"""
    CONSTRUCTOR_ID = 0x33963bf9
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', id: int, random_id: int = None):
        self.peer = peer
        self.id = id
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'ForwardMessageRequest',
            'peer': self.peer,
            '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(bytes(self.peer))
        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_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _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 ForwardMessagesRequest(TLRequest):
    """TL type: messages.forwardMessages"""
    CONSTRUCTOR_ID = 0x13704a7c
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, from_peer: 'TypeInputPeer', id: List[int], to_peer: 'TypeInputPeer', silent: Optional[bool] = None, background: Optional[bool] = None, with_my_score: Optional[bool] = None, drop_author: Optional[bool] = None, drop_media_captions: Optional[bool] = None, noforwards: Optional[bool] = None, allow_paid_floodskip: Optional[bool] = None, random_id: List[int] = None, top_msg_id: Optional[int] = None, reply_to: Optional['TypeInputReplyTo'] = None, schedule_date: Optional[datetime] = None, schedule_repeat_period: Optional[int] = None, send_as: Optional['TypeInputPeer'] = None, quick_reply_shortcut: Optional['TypeInputQuickReplyShortcut'] = None, effect: Optional[int] = None, video_timestamp: Optional[int] = None, allow_paid_stars: Optional[int] = None, suggested_post: Optional['TypeSuggestedPost'] = None):
        self.from_peer = from_peer
        self.id = id
        self.to_peer = to_peer
        self.silent = silent
        self.background = background
        self.with_my_score = with_my_score
        self.drop_author = drop_author
        self.drop_media_captions = drop_media_captions
        self.noforwards = noforwards
        self.allow_paid_floodskip = allow_paid_floodskip
        self.random_id = random_id
        self.top_msg_id = top_msg_id
        self.reply_to = reply_to
        self.schedule_date = schedule_date
        self.schedule_repeat_period = schedule_repeat_period
        self.send_as = send_as
        self.quick_reply_shortcut = quick_reply_shortcut
        self.effect = effect
        self.video_timestamp = video_timestamp
        self.allow_paid_stars = allow_paid_stars
        self.suggested_post = suggested_post

    def to_dict(self):
        return {
            '_': 'ForwardMessagesRequest',
            'from_peer': self.from_peer,
            'id': self.id,
            'to_peer': self.to_peer,
            'silent': self.silent,
            'background': self.background,
            'with_my_score': self.with_my_score,
            'drop_author': self.drop_author,
            'drop_media_captions': self.drop_media_captions,
            'noforwards': self.noforwards,
            'allow_paid_floodskip': self.allow_paid_floodskip,
            'random_id': self.random_id,
            'top_msg_id': self.top_msg_id,
            'reply_to': self.reply_to,
            'schedule_date': self.schedule_date,
            'schedule_repeat_period': self.schedule_repeat_period,
            'send_as': self.send_as,
            'quick_reply_shortcut': self.quick_reply_shortcut,
            'effect': self.effect,
            'video_timestamp': self.video_timestamp,
            'allow_paid_stars': self.allow_paid_stars,
            '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.silent:
            flags |= (1 << 5)
        if self.background:
            flags |= (1 << 6)
        if self.with_my_score:
            flags |= (1 << 8)
        if self.drop_author:
            flags |= (1 << 11)
        if self.drop_media_captions:
            flags |= (1 << 12)
        if self.noforwards:
            flags |= (1 << 14)
        if self.allow_paid_floodskip:
            flags |= (1 << 19)
        if self.top_msg_id is not None:
            flags |= (1 << 9)
        if self.reply_to is not None:
            flags |= (1 << 22)
        if self.schedule_date is not None:
            flags |= (1 << 10)
        if self.schedule_repeat_period is not None:
            flags |= (1 << 24)
        if self.send_as is not None:
            flags |= (1 << 13)
        if self.quick_reply_shortcut is not None:
            flags |= (1 << 17)
        if self.effect is not None:
            flags |= (1 << 18)
        if self.video_timestamp is not None:
            flags |= (1 << 20)
        if self.allow_paid_stars is not None:
            flags |= (1 << 21)
        if self.suggested_post is not None:
            flags |= (1 << 23)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.from_peer))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            buf.write(struct.pack('<i', self.item))
        buf.write(bytes(self.to_peer))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.random_id)))
        for item in self.random_id:
            buf.write(struct.pack('<q', self.item))
        if self.top_msg_id is not None:
            buf.write(struct.pack('<i', self.top_msg_id))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        if self.schedule_date is not None:
            buf.write(struct.pack('<i', self.schedule_date))
        if self.schedule_repeat_period is not None:
            buf.write(struct.pack('<i', self.schedule_repeat_period))
        if self.send_as is not None:
            buf.write(bytes(self.send_as))
        if self.quick_reply_shortcut is not None:
            buf.write(bytes(self.quick_reply_shortcut))
        if self.effect is not None:
            buf.write(struct.pack('<q', self.effect))
        if self.video_timestamp is not None:
            buf.write(struct.pack('<i', self.video_timestamp))
        if self.allow_paid_stars is not None:
            buf.write(struct.pack('<q', self.allow_paid_stars))
        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['silent'] = bool(flags & (1 << 5))
        _args['background'] = bool(flags & (1 << 6))
        _args['with_my_score'] = bool(flags & (1 << 8))
        _args['drop_author'] = bool(flags & (1 << 11))
        _args['drop_media_captions'] = bool(flags & (1 << 12))
        _args['noforwards'] = bool(flags & (1 << 14))
        _args['allow_paid_floodskip'] = bool(flags & (1 << 19))
        _val_from_peer = reader.tgread_object()
        _args['from_peer'] = _val_from_peer
        reader.read_int(signed=False)  # skip vector id
        _count_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        reader.read_int(signed=False)  # skip vector id
        _count_random_id = reader.read_int()
        _list_random_id = []
        for _ in range(_count_random_id):
            _item_random_id = reader.read_long()
            _list_random_id.append(_item_random_id)
        _args['random_id'] = _list_random_id
        _val_to_peer = reader.tgread_object()
        _args['to_peer'] = _val_to_peer
        if flags & (1 << 9):
            _val_top_msg_id = reader.read_int()
            _args['top_msg_id'] = _val_top_msg_id
        else:
            _args['top_msg_id'] = None
        if flags & (1 << 22):
            _val_reply_to = reader.tgread_object()
            _args['reply_to'] = _val_reply_to
        else:
            _args['reply_to'] = None
        if flags & (1 << 10):
            _val_schedule_date = reader.read_int()
            _args['schedule_date'] = _val_schedule_date
        else:
            _args['schedule_date'] = None
        if flags & (1 << 24):
            _val_schedule_repeat_period = reader.read_int()
            _args['schedule_repeat_period'] = _val_schedule_repeat_period
        else:
            _args['schedule_repeat_period'] = None
        if flags & (1 << 13):
            _val_send_as = reader.tgread_object()
            _args['send_as'] = _val_send_as
        else:
            _args['send_as'] = None
        if flags & (1 << 17):
            _val_quick_reply_shortcut = reader.tgread_object()
            _args['quick_reply_shortcut'] = _val_quick_reply_shortcut
        else:
            _args['quick_reply_shortcut'] = None
        if flags & (1 << 18):
            _val_effect = reader.read_long()
            _args['effect'] = _val_effect
        else:
            _args['effect'] = None
        if flags & (1 << 20):
            _val_video_timestamp = reader.read_int()
            _args['video_timestamp'] = _val_video_timestamp
        else:
            _args['video_timestamp'] = None
        if flags & (1 << 21):
            _val_allow_paid_stars = reader.read_long()
            _args['allow_paid_stars'] = _val_allow_paid_stars
        else:
            _args['allow_paid_stars'] = None
        if flags & (1 << 23):
            _val_suggested_post = reader.tgread_object()
            _args['suggested_post'] = _val_suggested_post
        else:
            _args['suggested_post'] = None
        return cls(**_args)


class GetAdminsWithInvitesRequest(TLRequest):
    """TL type: messages.getAdminsWithInvites"""
    CONSTRUCTOR_ID = 0x3920e6ef
    SUBCLASS_OF_ID = 0x8f5bad2b

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

    def to_dict(self):
        return {
            '_': 'GetAdminsWithInvitesRequest',
            '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 GetAllChatsRequest(TLRequest):
    """TL type: messages.getAllChats"""
    CONSTRUCTOR_ID = 0x875f74be
    SUBCLASS_OF_ID = 0x99d5cb14

    def __init__(self, except_ids: List[int]):
        self.except_ids = except_ids

    def to_dict(self):
        return {
            '_': 'GetAllChatsRequest',
            'except_ids': self.except_ids,
        }

    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.except_ids)))
        for item in self.except_ids:
            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_except_ids = reader.read_int()
        _list_except_ids = []
        for _ in range(_count_except_ids):
            _item_except_ids = reader.read_long()
            _list_except_ids.append(_item_except_ids)
        _args['except_ids'] = _list_except_ids
        return cls(**_args)


class GetAllDraftsRequest(TLRequest):
    """TL type: messages.getAllDrafts"""
    CONSTRUCTOR_ID = 0x6a3f8d65
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self):
        pass

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

    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 GetAllStickersRequest(TLRequest):
    """TL type: messages.getAllStickers"""
    CONSTRUCTOR_ID = 0xb8a0a1a8
    SUBCLASS_OF_ID = 0x45834829

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

    def to_dict(self):
        return {
            '_': 'GetAllStickersRequest',
            '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.hash))
        return buf.getvalue()

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


class GetArchivedStickersRequest(TLRequest):
    """TL type: messages.getArchivedStickers"""
    CONSTRUCTOR_ID = 0x57f17692
    SUBCLASS_OF_ID = 0x7296d771

    def __init__(self, offset_id: int, limit: int, masks: Optional[bool] = None, emojis: Optional[bool] = None):
        self.offset_id = offset_id
        self.limit = limit
        self.masks = masks
        self.emojis = emojis

    def to_dict(self):
        return {
            '_': 'GetArchivedStickersRequest',
            'offset_id': self.offset_id,
            'limit': self.limit,
            '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.offset_id))
        buf.write(struct.pack('<i', self.limit))
        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_offset_id = reader.read_long()
        _args['offset_id'] = _val_offset_id
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetAttachMenuBotRequest(TLRequest):
    """TL type: messages.getAttachMenuBot"""
    CONSTRUCTOR_ID = 0x77216192
    SUBCLASS_OF_ID = 0xdb33883d

    def __init__(self, bot: 'TypeInputUser'):
        self.bot = bot

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

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

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


class GetAttachMenuBotsRequest(TLRequest):
    """TL type: messages.getAttachMenuBots"""
    CONSTRUCTOR_ID = 0x16fcc2cb
    SUBCLASS_OF_ID = 0x842e23da

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

    def to_dict(self):
        return {
            '_': 'GetAttachMenuBotsRequest',
            '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.hash))
        return buf.getvalue()

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


class GetAttachedStickersRequest(TLRequest):
    """TL type: messages.getAttachedStickers"""
    CONSTRUCTOR_ID = 0xcc5b67cc
    SUBCLASS_OF_ID = 0xcc125f6b

    def __init__(self, media: 'TypeInputStickeredMedia'):
        self.media = media

    def to_dict(self):
        return {
            '_': 'GetAttachedStickersRequest',
            '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 GetAvailableEffectsRequest(TLRequest):
    """TL type: messages.getAvailableEffects"""
    CONSTRUCTOR_ID = 0xdea20a39
    SUBCLASS_OF_ID = 0x4470d5bd

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

    def to_dict(self):
        return {
            '_': 'GetAvailableEffectsRequest',
            'hash': self.hash,
        }

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

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


class GetAvailableReactionsRequest(TLRequest):
    """TL type: messages.getAvailableReactions"""
    CONSTRUCTOR_ID = 0x18dea0ac
    SUBCLASS_OF_ID = 0xe426ad82

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

    def to_dict(self):
        return {
            '_': 'GetAvailableReactionsRequest',
            'hash': self.hash,
        }

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

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


class GetBotAppRequest(TLRequest):
    """TL type: messages.getBotApp"""
    CONSTRUCTOR_ID = 0x34fdc5c3
    SUBCLASS_OF_ID = 0x8f7243a7

    def __init__(self, app: 'TypeInputBotApp', hash: int):
        self.app = app
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'GetBotAppRequest',
            'app': self.app,
            'hash': self.hash,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_app = reader.tgread_object()
        _args['app'] = _val_app
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetBotCallbackAnswerRequest(TLRequest):
    """TL type: messages.getBotCallbackAnswer"""
    CONSTRUCTOR_ID = 0x9342ca07
    SUBCLASS_OF_ID = 0x6c4dd18c

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, game: Optional[bool] = None, data: Optional[bytes] = None, password: Optional['TypeInputCheckPasswordSRP'] = None):
        self.peer = peer
        self.msg_id = msg_id
        self.game = game
        self.data = data
        self.password = password

    def to_dict(self):
        return {
            '_': 'GetBotCallbackAnswerRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'game': self.game,
            'data': self.data,
            'password': self.password,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['game'] = bool(flags & (1 << 1))
        _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_data = reader.tgread_bytes()
            _args['data'] = _val_data
        else:
            _args['data'] = None
        if flags & (1 << 2):
            _val_password = reader.tgread_object()
            _args['password'] = _val_password
        else:
            _args['password'] = None
        return cls(**_args)


class GetChatInviteImportersRequest(TLRequest):
    """TL type: messages.getChatInviteImporters"""
    CONSTRUCTOR_ID = 0xdf04dd4e
    SUBCLASS_OF_ID = 0xd9bc8aa6

    def __init__(self, peer: 'TypeInputPeer', offset_date: Optional[datetime], offset_user: 'TypeInputUser', limit: int, requested: Optional[bool] = None, subscription_expired: Optional[bool] = None, link: Optional[str] = None, q: Optional[str] = None):
        self.peer = peer
        self.offset_date = offset_date
        self.offset_user = offset_user
        self.limit = limit
        self.requested = requested
        self.subscription_expired = subscription_expired
        self.link = link
        self.q = q

    def to_dict(self):
        return {
            '_': 'GetChatInviteImportersRequest',
            'peer': self.peer,
            'offset_date': self.offset_date,
            'offset_user': self.offset_user,
            'limit': self.limit,
            'requested': self.requested,
            'subscription_expired': self.subscription_expired,
            'link': self.link,
            'q': self.q,
        }

    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.subscription_expired:
            flags |= (1 << 3)
        if self.link is not None:
            flags |= (1 << 1)
        if self.q is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.offset_date))
        buf.write(bytes(self.offset_user))
        buf.write(struct.pack('<i', self.limit))
        if self.link is not None:
            buf.write(TLObject.serialize_bytes(self.link))
        if self.q is not None:
            buf.write(TLObject.serialize_bytes(self.q))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['requested'] = bool(flags & (1 << 0))
        _args['subscription_expired'] = bool(flags & (1 << 3))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 1):
            _val_link = reader.tgread_string()
            _args['link'] = _val_link
        else:
            _args['link'] = None
        if flags & (1 << 2):
            _val_q = reader.tgread_string()
            _args['q'] = _val_q
        else:
            _args['q'] = None
        _val_offset_date = reader.read_int()
        _args['offset_date'] = _val_offset_date
        _val_offset_user = reader.tgread_object()
        _args['offset_user'] = _val_offset_user
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetChatsRequest(TLRequest):
    """TL type: messages.getChats"""
    CONSTRUCTOR_ID = 0x49e9528f
    SUBCLASS_OF_ID = 0x99d5cb14

    def __init__(self, id: List[int]):
        self.id = id

    def to_dict(self):
        return {
            '_': 'GetChatsRequest',
            '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', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            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_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_long()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        return cls(**_args)


class GetCommonChatsRequest(TLRequest):
    """TL type: messages.getCommonChats"""
    CONSTRUCTOR_ID = 0xe40ca104
    SUBCLASS_OF_ID = 0x99d5cb14

    def __init__(self, user_id: 'TypeInputUser', max_id: int, limit: int):
        self.user_id = user_id
        self.max_id = max_id
        self.limit = limit

    def to_dict(self):
        return {
            '_': 'GetCommonChatsRequest',
            'user_id': self.user_id,
            'max_id': self.max_id,
            'limit': self.limit,
        }

    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.max_id))
        buf.write(struct.pack('<i', self.limit))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        _val_max_id = reader.read_long()
        _args['max_id'] = _val_max_id
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetCustomEmojiDocumentsRequest(TLRequest):
    """TL type: messages.getCustomEmojiDocuments"""
    CONSTRUCTOR_ID = 0xd9ab0f54
    SUBCLASS_OF_ID = 0xcc590e08

    def __init__(self, document_id: List[int]):
        self.document_id = document_id

    def to_dict(self):
        return {
            '_': 'GetCustomEmojiDocumentsRequest',
            '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', 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 = {}
        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 GetDefaultHistoryTtlRequest(TLRequest):
    """TL type: messages.getDefaultHistoryTTL"""
    CONSTRUCTOR_ID = 0x658b7188
    SUBCLASS_OF_ID = 0xf00d3367

    def __init__(self):
        pass

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

    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 GetDefaultTagReactionsRequest(TLRequest):
    """TL type: messages.getDefaultTagReactions"""
    CONSTRUCTOR_ID = 0xbdf93428
    SUBCLASS_OF_ID = 0xadc38324

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

    def to_dict(self):
        return {
            '_': 'GetDefaultTagReactionsRequest',
            '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.hash))
        return buf.getvalue()

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


class GetDhConfigRequest(TLRequest):
    """TL type: messages.getDhConfig"""
    CONSTRUCTOR_ID = 0x26cf8950
    SUBCLASS_OF_ID = 0xe488ed8b

    def __init__(self, version: int, random_length: int):
        self.version = version
        self.random_length = random_length

    def to_dict(self):
        return {
            '_': 'GetDhConfigRequest',
            'version': self.version,
            'random_length': self.random_length,
        }

    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.random_length))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_version = reader.read_int()
        _args['version'] = _val_version
        _val_random_length = reader.read_int()
        _args['random_length'] = _val_random_length
        return cls(**_args)


class GetDialogFiltersRequest(TLRequest):
    """TL type: messages.getDialogFilters"""
    CONSTRUCTOR_ID = 0xefd48c89
    SUBCLASS_OF_ID = 0xa5fff1b7

    def __init__(self):
        pass

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

    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 GetDialogUnreadMarksRequest(TLRequest):
    """TL type: messages.getDialogUnreadMarks"""
    CONSTRUCTOR_ID = 0x21202222
    SUBCLASS_OF_ID = 0xbec64ad9

    def __init__(self, parent_peer: Optional['TypeInputPeer'] = None):
        self.parent_peer = parent_peer

    def to_dict(self):
        return {
            '_': 'GetDialogUnreadMarksRequest',
            'parent_peer': self.parent_peer,
        }

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

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


class GetDialogsRequest(TLRequest):
    """TL type: messages.getDialogs"""
    CONSTRUCTOR_ID = 0xa0f4cb4f
    SUBCLASS_OF_ID = 0x0e1b52ee

    def __init__(self, offset_date: Optional[datetime], offset_id: int, offset_peer: 'TypeInputPeer', limit: int, hash: int, exclude_pinned: Optional[bool] = None, folder_id: Optional[int] = None):
        self.offset_date = offset_date
        self.offset_id = offset_id
        self.offset_peer = offset_peer
        self.limit = limit
        self.hash = hash
        self.exclude_pinned = exclude_pinned
        self.folder_id = folder_id

    def to_dict(self):
        return {
            '_': 'GetDialogsRequest',
            'offset_date': self.offset_date,
            'offset_id': self.offset_id,
            'offset_peer': self.offset_peer,
            'limit': self.limit,
            'hash': self.hash,
            'exclude_pinned': self.exclude_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.exclude_pinned:
            flags |= (1 << 0)
        if self.folder_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.offset_date))
        buf.write(struct.pack('<i', self.offset_id))
        buf.write(bytes(self.offset_peer))
        buf.write(struct.pack('<i', self.limit))
        buf.write(struct.pack('<q', self.hash))
        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['exclude_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_offset_date = reader.read_int()
        _args['offset_date'] = _val_offset_date
        _val_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_offset_peer = reader.tgread_object()
        _args['offset_peer'] = _val_offset_peer
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetDiscussionMessageRequest(TLRequest):
    """TL type: messages.getDiscussionMessage"""
    CONSTRUCTOR_ID = 0x446972fd
    SUBCLASS_OF_ID = 0x53f8e3e8

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

    def to_dict(self):
        return {
            '_': 'GetDiscussionMessageRequest',
            '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 GetDocumentByHashRequest(TLRequest):
    """TL type: messages.getDocumentByHash"""
    CONSTRUCTOR_ID = 0xb1f2061f
    SUBCLASS_OF_ID = 0x211fe820

    def __init__(self, sha256: bytes, size: int, mime_type: str):
        self.sha256 = sha256
        self.size = size
        self.mime_type = mime_type

    def to_dict(self):
        return {
            '_': 'GetDocumentByHashRequest',
            'sha256': self.sha256,
            'size': self.size,
            'mime_type': self.mime_type,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_sha256 = reader.tgread_bytes()
        _args['sha256'] = _val_sha256
        _val_size = reader.read_long()
        _args['size'] = _val_size
        _val_mime_type = reader.tgread_string()
        _args['mime_type'] = _val_mime_type
        return cls(**_args)


class GetEmojiGameInfoRequest(TLRequest):
    """TL type: messages.getEmojiGameInfo"""
    CONSTRUCTOR_ID = 0xfb7e8ca7
    SUBCLASS_OF_ID = 0x064b3022

    def __init__(self):
        pass

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

    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 GetEmojiGroupsRequest(TLRequest):
    """TL type: messages.getEmojiGroups"""
    CONSTRUCTOR_ID = 0x7488ce5b
    SUBCLASS_OF_ID = 0x7eca55d9

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

    def to_dict(self):
        return {
            '_': 'GetEmojiGroupsRequest',
            'hash': self.hash,
        }

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

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


class GetEmojiKeywordsRequest(TLRequest):
    """TL type: messages.getEmojiKeywords"""
    CONSTRUCTOR_ID = 0x35a0e062
    SUBCLASS_OF_ID = 0xd279c672

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

    def to_dict(self):
        return {
            '_': 'GetEmojiKeywordsRequest',
            '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 GetEmojiKeywordsDifferenceRequest(TLRequest):
    """TL type: messages.getEmojiKeywordsDifference"""
    CONSTRUCTOR_ID = 0x1508b6af
    SUBCLASS_OF_ID = 0xd279c672

    def __init__(self, lang_code: str, from_version: int):
        self.lang_code = lang_code
        self.from_version = from_version

    def to_dict(self):
        return {
            '_': 'GetEmojiKeywordsDifferenceRequest',
            'lang_code': self.lang_code,
            'from_version': self.from_version,
        }

    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))
        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
        return cls(**_args)


class GetEmojiKeywordsLanguagesRequest(TLRequest):
    """TL type: messages.getEmojiKeywordsLanguages"""
    CONSTRUCTOR_ID = 0x4e9963b2
    SUBCLASS_OF_ID = 0xe795d387

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

    def to_dict(self):
        return {
            '_': 'GetEmojiKeywordsLanguagesRequest',
            'lang_codes': self.lang_codes,
        }

    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.lang_codes)))
        for item in self.lang_codes:
            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_lang_codes = reader.read_int()
        _list_lang_codes = []
        for _ in range(_count_lang_codes):
            _item_lang_codes = reader.tgread_string()
            _list_lang_codes.append(_item_lang_codes)
        _args['lang_codes'] = _list_lang_codes
        return cls(**_args)


class GetEmojiProfilePhotoGroupsRequest(TLRequest):
    """TL type: messages.getEmojiProfilePhotoGroups"""
    CONSTRUCTOR_ID = 0x21a548f3
    SUBCLASS_OF_ID = 0x7eca55d9

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

    def to_dict(self):
        return {
            '_': 'GetEmojiProfilePhotoGroupsRequest',
            'hash': self.hash,
        }

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

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


class GetEmojiStatusGroupsRequest(TLRequest):
    """TL type: messages.getEmojiStatusGroups"""
    CONSTRUCTOR_ID = 0x2ecd56cd
    SUBCLASS_OF_ID = 0x7eca55d9

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

    def to_dict(self):
        return {
            '_': 'GetEmojiStatusGroupsRequest',
            'hash': self.hash,
        }

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

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


class GetEmojiStickerGroupsRequest(TLRequest):
    """TL type: messages.getEmojiStickerGroups"""
    CONSTRUCTOR_ID = 0x1dd840f5
    SUBCLASS_OF_ID = 0x7eca55d9

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

    def to_dict(self):
        return {
            '_': 'GetEmojiStickerGroupsRequest',
            'hash': self.hash,
        }

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

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


class GetEmojiStickersRequest(TLRequest):
    """TL type: messages.getEmojiStickers"""
    CONSTRUCTOR_ID = 0xfbfca18f
    SUBCLASS_OF_ID = 0x45834829

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

    def to_dict(self):
        return {
            '_': 'GetEmojiStickersRequest',
            '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.hash))
        return buf.getvalue()

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


class GetEmojiUrlRequest(TLRequest):
    """TL type: messages.getEmojiURL"""
    CONSTRUCTOR_ID = 0xd5b10c26
    SUBCLASS_OF_ID = 0x1fa08a19

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

    def to_dict(self):
        return {
            '_': 'GetEmojiUrlRequest',
            '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 GetExportedChatInviteRequest(TLRequest):
    """TL type: messages.getExportedChatInvite"""
    CONSTRUCTOR_ID = 0x73746f5c
    SUBCLASS_OF_ID = 0x82dcd4ca

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

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

    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.link))
        return buf.getvalue()

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


class GetExportedChatInvitesRequest(TLRequest):
    """TL type: messages.getExportedChatInvites"""
    CONSTRUCTOR_ID = 0xa2b5a3f6
    SUBCLASS_OF_ID = 0x603d3871

    def __init__(self, peer: 'TypeInputPeer', admin_id: 'TypeInputUser', limit: int, revoked: Optional[bool] = None, offset_date: Optional[datetime] = None, offset_link: Optional[str] = None):
        self.peer = peer
        self.admin_id = admin_id
        self.limit = limit
        self.revoked = revoked
        self.offset_date = offset_date
        self.offset_link = offset_link

    def to_dict(self):
        return {
            '_': 'GetExportedChatInvitesRequest',
            'peer': self.peer,
            'admin_id': self.admin_id,
            'limit': self.limit,
            'revoked': self.revoked,
            'offset_date': self.offset_date,
            'offset_link': self.offset_link,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.revoked:
            flags |= (1 << 3)
        if self.offset_link is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.admin_id))
        buf.write(struct.pack('<i', self.limit))
        if self.offset_date is not None:
            buf.write(struct.pack('<i', self.offset_date))
        if self.offset_link is not None:
            buf.write(TLObject.serialize_bytes(self.offset_link))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['revoked'] = bool(flags & (1 << 3))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_admin_id = reader.tgread_object()
        _args['admin_id'] = _val_admin_id
        if flags & (1 << 2):
            _val_offset_date = reader.read_int()
            _args['offset_date'] = _val_offset_date
        else:
            _args['offset_date'] = None
        if flags & (1 << 2):
            _val_offset_link = reader.tgread_string()
            _args['offset_link'] = _val_offset_link
        else:
            _args['offset_link'] = None
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetExtendedMediaRequest(TLRequest):
    """TL type: messages.getExtendedMedia"""
    CONSTRUCTOR_ID = 0x84f80814
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', id: List[int]):
        self.peer = peer
        self.id = id

    def to_dict(self):
        return {
            '_': 'GetExtendedMediaRequest',
            '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', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            buf.write(struct.pack('<i', self.item))
        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_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        return cls(**_args)


class GetFactCheckRequest(TLRequest):
    """TL type: messages.getFactCheck"""
    CONSTRUCTOR_ID = 0xb9cdc5ee
    SUBCLASS_OF_ID = 0xbba61813

    def __init__(self, peer: 'TypeInputPeer', msg_id: List[int]):
        self.peer = peer
        self.msg_id = msg_id

    def to_dict(self):
        return {
            '_': 'GetFactCheckRequest',
            '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', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.msg_id)))
        for item in self.msg_id:
            buf.write(struct.pack('<i', self.item))
        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_msg_id = reader.read_int()
        _list_msg_id = []
        for _ in range(_count_msg_id):
            _item_msg_id = reader.read_int()
            _list_msg_id.append(_item_msg_id)
        _args['msg_id'] = _list_msg_id
        return cls(**_args)


class GetFavedStickersRequest(TLRequest):
    """TL type: messages.getFavedStickers"""
    CONSTRUCTOR_ID = 0x04f1aaa9
    SUBCLASS_OF_ID = 0x8e736fb9

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

    def to_dict(self):
        return {
            '_': 'GetFavedStickersRequest',
            '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.hash))
        return buf.getvalue()

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


class GetFeaturedEmojiStickersRequest(TLRequest):
    """TL type: messages.getFeaturedEmojiStickers"""
    CONSTRUCTOR_ID = 0x0ecf6736
    SUBCLASS_OF_ID = 0x2614b722

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

    def to_dict(self):
        return {
            '_': 'GetFeaturedEmojiStickersRequest',
            '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.hash))
        return buf.getvalue()

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


class GetFeaturedStickersRequest(TLRequest):
    """TL type: messages.getFeaturedStickers"""
    CONSTRUCTOR_ID = 0x64780b14
    SUBCLASS_OF_ID = 0x2614b722

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

    def to_dict(self):
        return {
            '_': 'GetFeaturedStickersRequest',
            '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.hash))
        return buf.getvalue()

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


class GetForumTopicsRequest(TLRequest):
    """TL type: messages.getForumTopics"""
    CONSTRUCTOR_ID = 0x3ba47bff
    SUBCLASS_OF_ID = 0x8e1d3e1e

    def __init__(self, peer: 'TypeInputPeer', offset_date: Optional[datetime], offset_id: int, offset_topic: int, limit: int, q: Optional[str] = None):
        self.peer = peer
        self.offset_date = offset_date
        self.offset_id = offset_id
        self.offset_topic = offset_topic
        self.limit = limit
        self.q = q

    def to_dict(self):
        return {
            '_': 'GetForumTopicsRequest',
            'peer': self.peer,
            'offset_date': self.offset_date,
            'offset_id': self.offset_id,
            'offset_topic': self.offset_topic,
            'limit': self.limit,
            'q': self.q,
        }

    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)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.offset_date))
        buf.write(struct.pack('<i', self.offset_id))
        buf.write(struct.pack('<i', self.offset_topic))
        buf.write(struct.pack('<i', self.limit))
        if self.q is not None:
            buf.write(TLObject.serialize_bytes(self.q))
        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_q = reader.tgread_string()
            _args['q'] = _val_q
        else:
            _args['q'] = None
        _val_offset_date = reader.read_int()
        _args['offset_date'] = _val_offset_date
        _val_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_offset_topic = reader.read_int()
        _args['offset_topic'] = _val_offset_topic
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetForumTopicsByIdRequest(TLRequest):
    """TL type: messages.getForumTopicsByID"""
    CONSTRUCTOR_ID = 0xaf0a4a08
    SUBCLASS_OF_ID = 0x8e1d3e1e

    def __init__(self, peer: 'TypeInputPeer', topics: List[int]):
        self.peer = peer
        self.topics = topics

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

    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.topics)))
        for item in self.topics:
            buf.write(struct.pack('<i', self.item))
        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_topics = reader.read_int()
        _list_topics = []
        for _ in range(_count_topics):
            _item_topics = reader.read_int()
            _list_topics.append(_item_topics)
        _args['topics'] = _list_topics
        return cls(**_args)


class GetFullChatRequest(TLRequest):
    """TL type: messages.getFullChat"""
    CONSTRUCTOR_ID = 0xaeb00b34
    SUBCLASS_OF_ID = 0x225a5109

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

    def to_dict(self):
        return {
            '_': 'GetFullChatRequest',
            '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 GetGameHighScoresRequest(TLRequest):
    """TL type: messages.getGameHighScores"""
    CONSTRUCTOR_ID = 0xe822649d
    SUBCLASS_OF_ID = 0x6ccd95fd

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

    def to_dict(self):
        return {
            '_': 'GetGameHighScoresRequest',
            'peer': self.peer,
            'id': self.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.id))
        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_id = reader.read_int()
        _args['id'] = _val_id
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        return cls(**_args)


class GetHistoryRequest(TLRequest):
    """TL type: messages.getHistory"""
    CONSTRUCTOR_ID = 0x4423e6c5
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, peer: 'TypeInputPeer', offset_id: int, offset_date: Optional[datetime], add_offset: int, limit: int, max_id: int, min_id: int, hash: int):
        self.peer = peer
        self.offset_id = offset_id
        self.offset_date = offset_date
        self.add_offset = add_offset
        self.limit = limit
        self.max_id = max_id
        self.min_id = min_id
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'GetHistoryRequest',
            'peer': self.peer,
            'offset_id': self.offset_id,
            'offset_date': self.offset_date,
            'add_offset': self.add_offset,
            'limit': self.limit,
            'max_id': self.max_id,
            'min_id': self.min_id,
            '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(struct.pack('<i', self.offset_id))
        buf.write(struct.pack('<i', self.offset_date))
        buf.write(struct.pack('<i', self.add_offset))
        buf.write(struct.pack('<i', self.limit))
        buf.write(struct.pack('<i', self.max_id))
        buf.write(struct.pack('<i', self.min_id))
        buf.write(struct.pack('<q', self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_offset_date = reader.read_int()
        _args['offset_date'] = _val_offset_date
        _val_add_offset = reader.read_int()
        _args['add_offset'] = _val_add_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        _val_min_id = reader.read_int()
        _args['min_id'] = _val_min_id
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetInlineBotResultsRequest(TLRequest):
    """TL type: messages.getInlineBotResults"""
    CONSTRUCTOR_ID = 0x514e999d
    SUBCLASS_OF_ID = 0x3ed4d9c9

    def __init__(self, bot: 'TypeInputUser', peer: 'TypeInputPeer', query: str, offset: str, geo_point: Optional['TypeInputGeoPoint'] = None):
        self.bot = bot
        self.peer = peer
        self.query = query
        self.offset = offset
        self.geo_point = geo_point

    def to_dict(self):
        return {
            '_': 'GetInlineBotResultsRequest',
            'bot': self.bot,
            'peer': self.peer,
            'query': self.query,
            'offset': self.offset,
            '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(bytes(self.bot))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.query))
        buf.write(TLObject.serialize_bytes(self.offset))
        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)
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _val_geo_point = reader.tgread_object()
            _args['geo_point'] = _val_geo_point
        else:
            _args['geo_point'] = None
        _val_query = reader.tgread_string()
        _args['query'] = _val_query
        _val_offset = reader.tgread_string()
        _args['offset'] = _val_offset
        return cls(**_args)


class GetInlineGameHighScoresRequest(TLRequest):
    """TL type: messages.getInlineGameHighScores"""
    CONSTRUCTOR_ID = 0x0f635e1b
    SUBCLASS_OF_ID = 0x6ccd95fd

    def __init__(self, id: 'TypeInputBotInlineMessageID', user_id: 'TypeInputUser'):
        self.id = id
        self.user_id = user_id

    def to_dict(self):
        return {
            '_': 'GetInlineGameHighScoresRequest',
            'id': self.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.id))
        buf.write(bytes(self.user_id))
        return buf.getvalue()

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


class GetMaskStickersRequest(TLRequest):
    """TL type: messages.getMaskStickers"""
    CONSTRUCTOR_ID = 0x640f82b8
    SUBCLASS_OF_ID = 0x45834829

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

    def to_dict(self):
        return {
            '_': 'GetMaskStickersRequest',
            '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.hash))
        return buf.getvalue()

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


class GetMessageEditDataRequest(TLRequest):
    """TL type: messages.getMessageEditData"""
    CONSTRUCTOR_ID = 0xfda68d36
    SUBCLASS_OF_ID = 0xfb47949d

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

    def to_dict(self):
        return {
            '_': 'GetMessageEditDataRequest',
            '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 GetMessageReactionsListRequest(TLRequest):
    """TL type: messages.getMessageReactionsList"""
    CONSTRUCTOR_ID = 0x461b3f48
    SUBCLASS_OF_ID = 0x60fce5e6

    def __init__(self, peer: 'TypeInputPeer', id: int, limit: int, reaction: Optional['TypeReaction'] = None, offset: Optional[str] = None):
        self.peer = peer
        self.id = id
        self.limit = limit
        self.reaction = reaction
        self.offset = offset

    def to_dict(self):
        return {
            '_': 'GetMessageReactionsListRequest',
            'peer': self.peer,
            'id': self.id,
            'limit': self.limit,
            'reaction': self.reaction,
            'offset': self.offset,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reaction is not None:
            flags |= (1 << 0)
        if self.offset is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<i', self.limit))
        if self.reaction is not None:
            buf.write(bytes(self.reaction))
        if self.offset is not None:
            buf.write(TLObject.serialize_bytes(self.offset))
        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_reaction = reader.tgread_object()
            _args['reaction'] = _val_reaction
        else:
            _args['reaction'] = None
        if flags & (1 << 1):
            _val_offset = reader.tgread_string()
            _args['offset'] = _val_offset
        else:
            _args['offset'] = None
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetMessageReadParticipantsRequest(TLRequest):
    """TL type: messages.getMessageReadParticipants"""
    CONSTRUCTOR_ID = 0x31c1c44f
    SUBCLASS_OF_ID = 0x21ca455b

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

    def to_dict(self):
        return {
            '_': 'GetMessageReadParticipantsRequest',
            '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 GetMessagesRequest(TLRequest):
    """TL type: messages.getMessages"""
    CONSTRUCTOR_ID = 0x63c66506
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, id: List['TypeInputMessage']):
        self.id = id

    def to_dict(self):
        return {
            '_': 'GetMessagesRequest',
            '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', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            buf.write(bytes(self.item))
        return buf.getvalue()

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


class GetMessagesReactionsRequest(TLRequest):
    """TL type: messages.getMessagesReactions"""
    CONSTRUCTOR_ID = 0x8bba90e6
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', id: List[int]):
        self.peer = peer
        self.id = id

    def to_dict(self):
        return {
            '_': 'GetMessagesReactionsRequest',
            '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', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            buf.write(struct.pack('<i', self.item))
        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_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        return cls(**_args)


class GetMessagesViewsRequest(TLRequest):
    """TL type: messages.getMessagesViews"""
    CONSTRUCTOR_ID = 0x5784d3e1
    SUBCLASS_OF_ID = 0xafb5eb9c

    def __init__(self, peer: 'TypeInputPeer', id: List[int], increment: bool):
        self.peer = peer
        self.id = id
        self.increment = increment

    def to_dict(self):
        return {
            '_': 'GetMessagesViewsRequest',
            'peer': self.peer,
            'id': self.id,
            'increment': self.increment,
        }

    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.id)))
        for item in self.id:
            buf.write(struct.pack('<i', self.item))
        buf.write(struct.pack('<I', 0x997275b5 if self.increment else 0xbc799737))
        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_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        _val_increment = reader.tgread_bool()
        _args['increment'] = _val_increment
        return cls(**_args)


class GetMyStickersRequest(TLRequest):
    """TL type: messages.getMyStickers"""
    CONSTRUCTOR_ID = 0xd0b5e1fc
    SUBCLASS_OF_ID = 0xb1b4350a

    def __init__(self, offset_id: int, limit: int):
        self.offset_id = offset_id
        self.limit = limit

    def to_dict(self):
        return {
            '_': 'GetMyStickersRequest',
            'offset_id': self.offset_id,
            'limit': self.limit,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset_id = reader.read_long()
        _args['offset_id'] = _val_offset_id
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetOldFeaturedStickersRequest(TLRequest):
    """TL type: messages.getOldFeaturedStickers"""
    CONSTRUCTOR_ID = 0x7ed094a1
    SUBCLASS_OF_ID = 0x2614b722

    def __init__(self, offset: int, limit: int, hash: int):
        self.offset = offset
        self.limit = limit
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'GetOldFeaturedStickersRequest',
            '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('<i', self.offset))
        buf.write(struct.pack('<i', self.limit))
        buf.write(struct.pack('<q', self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetOnlinesRequest(TLRequest):
    """TL type: messages.getOnlines"""
    CONSTRUCTOR_ID = 0x6e2be050
    SUBCLASS_OF_ID = 0x8c81903a

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

    def to_dict(self):
        return {
            '_': 'GetOnlinesRequest',
            '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 GetOutboxReadDateRequest(TLRequest):
    """TL type: messages.getOutboxReadDate"""
    CONSTRUCTOR_ID = 0x8c4bfe5d
    SUBCLASS_OF_ID = 0x6f5183c6

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

    def to_dict(self):
        return {
            '_': 'GetOutboxReadDateRequest',
            '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 GetPaidReactionPrivacyRequest(TLRequest):
    """TL type: messages.getPaidReactionPrivacy"""
    CONSTRUCTOR_ID = 0x472455aa
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self):
        pass

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

    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 GetPeerDialogsRequest(TLRequest):
    """TL type: messages.getPeerDialogs"""
    CONSTRUCTOR_ID = 0xe470bcfd
    SUBCLASS_OF_ID = 0x3ac70132

    def __init__(self, peers: List['TypeInputDialogPeer']):
        self.peers = peers

    def to_dict(self):
        return {
            '_': 'GetPeerDialogsRequest',
            '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 GetPeerSettingsRequest(TLRequest):
    """TL type: messages.getPeerSettings"""
    CONSTRUCTOR_ID = 0xefd9a6a2
    SUBCLASS_OF_ID = 0x65a2f7a1

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

    def to_dict(self):
        return {
            '_': 'GetPeerSettingsRequest',
            '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 GetPinnedDialogsRequest(TLRequest):
    """TL type: messages.getPinnedDialogs"""
    CONSTRUCTOR_ID = 0xd6b94df2
    SUBCLASS_OF_ID = 0x3ac70132

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

    def to_dict(self):
        return {
            '_': 'GetPinnedDialogsRequest',
            '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 GetPinnedSavedDialogsRequest(TLRequest):
    """TL type: messages.getPinnedSavedDialogs"""
    CONSTRUCTOR_ID = 0xd63d94e0
    SUBCLASS_OF_ID = 0x614bb87e

    def __init__(self):
        pass

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

    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 GetPollResultsRequest(TLRequest):
    """TL type: messages.getPollResults"""
    CONSTRUCTOR_ID = 0x73bb643b
    SUBCLASS_OF_ID = 0x8af52aac

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

    def to_dict(self):
        return {
            '_': 'GetPollResultsRequest',
            '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 GetPollVotesRequest(TLRequest):
    """TL type: messages.getPollVotes"""
    CONSTRUCTOR_ID = 0xb86e380e
    SUBCLASS_OF_ID = 0xc2199885

    def __init__(self, peer: 'TypeInputPeer', id: int, limit: int, option: Optional[bytes] = None, offset: Optional[str] = None):
        self.peer = peer
        self.id = id
        self.limit = limit
        self.option = option
        self.offset = offset

    def to_dict(self):
        return {
            '_': 'GetPollVotesRequest',
            'peer': self.peer,
            'id': self.id,
            'limit': self.limit,
            'option': self.option,
            'offset': self.offset,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.option is not None:
            flags |= (1 << 0)
        if self.offset is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.id))
        buf.write(struct.pack('<i', self.limit))
        if self.option is not None:
            buf.write(TLObject.serialize_bytes(self.option))
        if self.offset is not None:
            buf.write(TLObject.serialize_bytes(self.offset))
        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_option = reader.tgread_bytes()
            _args['option'] = _val_option
        else:
            _args['option'] = None
        if flags & (1 << 1):
            _val_offset = reader.tgread_string()
            _args['offset'] = _val_offset
        else:
            _args['offset'] = None
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetPreparedInlineMessageRequest(TLRequest):
    """TL type: messages.getPreparedInlineMessage"""
    CONSTRUCTOR_ID = 0x857ebdb8
    SUBCLASS_OF_ID = 0x490ddf4d

    def __init__(self, bot: 'TypeInputUser', id: str):
        self.bot = bot
        self.id = id

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

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

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


class GetQuickRepliesRequest(TLRequest):
    """TL type: messages.getQuickReplies"""
    CONSTRUCTOR_ID = 0xd483f2a8
    SUBCLASS_OF_ID = 0xf737e966

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

    def to_dict(self):
        return {
            '_': 'GetQuickRepliesRequest',
            '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.hash))
        return buf.getvalue()

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


class GetQuickReplyMessagesRequest(TLRequest):
    """TL type: messages.getQuickReplyMessages"""
    CONSTRUCTOR_ID = 0x94a495c3
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, shortcut_id: int, hash: int, id: Optional[List[int]] = None):
        self.shortcut_id = shortcut_id
        self.hash = hash
        self.id = id

    def to_dict(self):
        return {
            '_': 'GetQuickReplyMessagesRequest',
            'shortcut_id': self.shortcut_id,
            'hash': self.hash,
            'id': self.id,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_shortcut_id = reader.read_int()
        _args['shortcut_id'] = _val_shortcut_id
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_id = reader.read_int()
            _list_id = []
            for _ in range(_count_id):
                _item_id = reader.read_int()
                _list_id.append(_item_id)
            _args['id'] = _list_id
        else:
            _args['id'] = None
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetRecentLocationsRequest(TLRequest):
    """TL type: messages.getRecentLocations"""
    CONSTRUCTOR_ID = 0x702a40e0
    SUBCLASS_OF_ID = 0xd4b40b5e

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

    def to_dict(self):
        return {
            '_': 'GetRecentLocationsRequest',
            'peer': self.peer,
            '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(bytes(self.peer))
        buf.write(struct.pack('<i', self.limit))
        buf.write(struct.pack('<q', self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetRecentReactionsRequest(TLRequest):
    """TL type: messages.getRecentReactions"""
    CONSTRUCTOR_ID = 0x39461db2
    SUBCLASS_OF_ID = 0xadc38324

    def __init__(self, limit: int, hash: int):
        self.limit = limit
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'GetRecentReactionsRequest',
            '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('<i', self.limit))
        buf.write(struct.pack('<q', self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetRecentStickersRequest(TLRequest):
    """TL type: messages.getRecentStickers"""
    CONSTRUCTOR_ID = 0x9da9403b
    SUBCLASS_OF_ID = 0xf76f8683

    def __init__(self, hash: int, attached: Optional[bool] = None):
        self.hash = hash
        self.attached = attached

    def to_dict(self):
        return {
            '_': 'GetRecentStickersRequest',
            'hash': self.hash,
            'attached': self.attached,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['attached'] = bool(flags & (1 << 0))
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetRepliesRequest(TLRequest):
    """TL type: messages.getReplies"""
    CONSTRUCTOR_ID = 0x22ddd30c
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, offset_id: int, offset_date: Optional[datetime], add_offset: int, limit: int, max_id: int, min_id: int, hash: int):
        self.peer = peer
        self.msg_id = msg_id
        self.offset_id = offset_id
        self.offset_date = offset_date
        self.add_offset = add_offset
        self.limit = limit
        self.max_id = max_id
        self.min_id = min_id
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'GetRepliesRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'offset_id': self.offset_id,
            'offset_date': self.offset_date,
            'add_offset': self.add_offset,
            'limit': self.limit,
            'max_id': self.max_id,
            'min_id': self.min_id,
            '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(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<i', self.offset_id))
        buf.write(struct.pack('<i', self.offset_date))
        buf.write(struct.pack('<i', self.add_offset))
        buf.write(struct.pack('<i', self.limit))
        buf.write(struct.pack('<i', self.max_id))
        buf.write(struct.pack('<i', self.min_id))
        buf.write(struct.pack('<q', self.hash))
        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_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_offset_date = reader.read_int()
        _args['offset_date'] = _val_offset_date
        _val_add_offset = reader.read_int()
        _args['add_offset'] = _val_add_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        _val_min_id = reader.read_int()
        _args['min_id'] = _val_min_id
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetSavedDialogsRequest(TLRequest):
    """TL type: messages.getSavedDialogs"""
    CONSTRUCTOR_ID = 0x1e91fc99
    SUBCLASS_OF_ID = 0x614bb87e

    def __init__(self, offset_date: Optional[datetime], offset_id: int, offset_peer: 'TypeInputPeer', limit: int, hash: int, exclude_pinned: Optional[bool] = None, parent_peer: Optional['TypeInputPeer'] = None):
        self.offset_date = offset_date
        self.offset_id = offset_id
        self.offset_peer = offset_peer
        self.limit = limit
        self.hash = hash
        self.exclude_pinned = exclude_pinned
        self.parent_peer = parent_peer

    def to_dict(self):
        return {
            '_': 'GetSavedDialogsRequest',
            'offset_date': self.offset_date,
            'offset_id': self.offset_id,
            'offset_peer': self.offset_peer,
            'limit': self.limit,
            'hash': self.hash,
            'exclude_pinned': self.exclude_pinned,
            'parent_peer': self.parent_peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.exclude_pinned:
            flags |= (1 << 0)
        if self.parent_peer is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.offset_date))
        buf.write(struct.pack('<i', self.offset_id))
        buf.write(bytes(self.offset_peer))
        buf.write(struct.pack('<i', self.limit))
        buf.write(struct.pack('<q', self.hash))
        if self.parent_peer is not None:
            buf.write(bytes(self.parent_peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['exclude_pinned'] = bool(flags & (1 << 0))
        if flags & (1 << 1):
            _val_parent_peer = reader.tgread_object()
            _args['parent_peer'] = _val_parent_peer
        else:
            _args['parent_peer'] = None
        _val_offset_date = reader.read_int()
        _args['offset_date'] = _val_offset_date
        _val_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_offset_peer = reader.tgread_object()
        _args['offset_peer'] = _val_offset_peer
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetSavedDialogsByIdRequest(TLRequest):
    """TL type: messages.getSavedDialogsByID"""
    CONSTRUCTOR_ID = 0x6f6f9c96
    SUBCLASS_OF_ID = 0x614bb87e

    def __init__(self, ids: List['TypeInputPeer'], parent_peer: Optional['TypeInputPeer'] = None):
        self.ids = ids
        self.parent_peer = parent_peer

    def to_dict(self):
        return {
            '_': 'GetSavedDialogsByIdRequest',
            'ids': self.ids,
            'parent_peer': self.parent_peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.parent_peer 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.ids)))
        for item in self.ids:
            buf.write(bytes(self.item))
        if self.parent_peer is not None:
            buf.write(bytes(self.parent_peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 1):
            _val_parent_peer = reader.tgread_object()
            _args['parent_peer'] = _val_parent_peer
        else:
            _args['parent_peer'] = None
        reader.read_int(signed=False)  # skip vector id
        _count_ids = reader.read_int()
        _list_ids = []
        for _ in range(_count_ids):
            _item_ids = reader.tgread_object()
            _list_ids.append(_item_ids)
        _args['ids'] = _list_ids
        return cls(**_args)


class GetSavedGifsRequest(TLRequest):
    """TL type: messages.getSavedGifs"""
    CONSTRUCTOR_ID = 0x5cf09635
    SUBCLASS_OF_ID = 0xa68b61f5

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

    def to_dict(self):
        return {
            '_': 'GetSavedGifsRequest',
            '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.hash))
        return buf.getvalue()

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


class GetSavedHistoryRequest(TLRequest):
    """TL type: messages.getSavedHistory"""
    CONSTRUCTOR_ID = 0x998ab009
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, peer: 'TypeInputPeer', offset_id: int, offset_date: Optional[datetime], add_offset: int, limit: int, max_id: int, min_id: int, hash: int, parent_peer: Optional['TypeInputPeer'] = None):
        self.peer = peer
        self.offset_id = offset_id
        self.offset_date = offset_date
        self.add_offset = add_offset
        self.limit = limit
        self.max_id = max_id
        self.min_id = min_id
        self.hash = hash
        self.parent_peer = parent_peer

    def to_dict(self):
        return {
            '_': 'GetSavedHistoryRequest',
            'peer': self.peer,
            'offset_id': self.offset_id,
            'offset_date': self.offset_date,
            'add_offset': self.add_offset,
            'limit': self.limit,
            'max_id': self.max_id,
            'min_id': self.min_id,
            'hash': self.hash,
            'parent_peer': self.parent_peer,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.parent_peer is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.offset_id))
        buf.write(struct.pack('<i', self.offset_date))
        buf.write(struct.pack('<i', self.add_offset))
        buf.write(struct.pack('<i', self.limit))
        buf.write(struct.pack('<i', self.max_id))
        buf.write(struct.pack('<i', self.min_id))
        buf.write(struct.pack('<q', self.hash))
        if self.parent_peer is not None:
            buf.write(bytes(self.parent_peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_parent_peer = reader.tgread_object()
            _args['parent_peer'] = _val_parent_peer
        else:
            _args['parent_peer'] = None
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_offset_date = reader.read_int()
        _args['offset_date'] = _val_offset_date
        _val_add_offset = reader.read_int()
        _args['add_offset'] = _val_add_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        _val_min_id = reader.read_int()
        _args['min_id'] = _val_min_id
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetSavedReactionTagsRequest(TLRequest):
    """TL type: messages.getSavedReactionTags"""
    CONSTRUCTOR_ID = 0x3637e05b
    SUBCLASS_OF_ID = 0xa39b5be3

    def __init__(self, hash: int, peer: Optional['TypeInputPeer'] = None):
        self.hash = hash
        self.peer = peer

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

    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)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.hash))
        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)
        if flags & (1 << 0):
            _val_peer = reader.tgread_object()
            _args['peer'] = _val_peer
        else:
            _args['peer'] = None
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetScheduledHistoryRequest(TLRequest):
    """TL type: messages.getScheduledHistory"""
    CONSTRUCTOR_ID = 0xf516760b
    SUBCLASS_OF_ID = 0xd4b40b5e

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

    def to_dict(self):
        return {
            '_': 'GetScheduledHistoryRequest',
            '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(struct.pack('<q', self.hash))
        return buf.getvalue()

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


class GetScheduledMessagesRequest(TLRequest):
    """TL type: messages.getScheduledMessages"""
    CONSTRUCTOR_ID = 0xbdbb0464
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, peer: 'TypeInputPeer', id: List[int]):
        self.peer = peer
        self.id = id

    def to_dict(self):
        return {
            '_': 'GetScheduledMessagesRequest',
            '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', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            buf.write(struct.pack('<i', self.item))
        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_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        return cls(**_args)


class GetSearchCountersRequest(TLRequest):
    """TL type: messages.getSearchCounters"""
    CONSTRUCTOR_ID = 0x1bbcf300
    SUBCLASS_OF_ID = 0x6bde3c6e

    def __init__(self, peer: 'TypeInputPeer', filters: List['TypeMessagesFilter'], saved_peer_id: Optional['TypeInputPeer'] = None, top_msg_id: Optional[int] = None):
        self.peer = peer
        self.filters = filters
        self.saved_peer_id = saved_peer_id
        self.top_msg_id = top_msg_id

    def to_dict(self):
        return {
            '_': 'GetSearchCountersRequest',
            'peer': self.peer,
            'filters': self.filters,
            'saved_peer_id': self.saved_peer_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.saved_peer_id is not None:
            flags |= (1 << 2)
        if self.top_msg_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.filters)))
        for item in self.filters:
            buf.write(bytes(self.item))
        if self.saved_peer_id is not None:
            buf.write(bytes(self.saved_peer_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)
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 2):
            _val_saved_peer_id = reader.tgread_object()
            _args['saved_peer_id'] = _val_saved_peer_id
        else:
            _args['saved_peer_id'] = None
        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
        reader.read_int(signed=False)  # skip vector id
        _count_filters = reader.read_int()
        _list_filters = []
        for _ in range(_count_filters):
            _item_filters = reader.tgread_object()
            _list_filters.append(_item_filters)
        _args['filters'] = _list_filters
        return cls(**_args)


class GetSearchResultsCalendarRequest(TLRequest):
    """TL type: messages.getSearchResultsCalendar"""
    CONSTRUCTOR_ID = 0x6aa3f6bd
    SUBCLASS_OF_ID = 0x92c5640f

    def __init__(self, peer: 'TypeInputPeer', filter: 'TypeMessagesFilter', offset_id: int, offset_date: Optional[datetime], saved_peer_id: Optional['TypeInputPeer'] = None):
        self.peer = peer
        self.filter = filter
        self.offset_id = offset_id
        self.offset_date = offset_date
        self.saved_peer_id = saved_peer_id

    def to_dict(self):
        return {
            '_': 'GetSearchResultsCalendarRequest',
            'peer': self.peer,
            'filter': self.filter,
            'offset_id': self.offset_id,
            'offset_date': self.offset_date,
            '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.saved_peer_id is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.filter))
        buf.write(struct.pack('<i', self.offset_id))
        buf.write(struct.pack('<i', self.offset_date))
        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 << 2):
            _val_saved_peer_id = reader.tgread_object()
            _args['saved_peer_id'] = _val_saved_peer_id
        else:
            _args['saved_peer_id'] = None
        _val_filter = reader.tgread_object()
        _args['filter'] = _val_filter
        _val_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_offset_date = reader.read_int()
        _args['offset_date'] = _val_offset_date
        return cls(**_args)


class GetSearchResultsPositionsRequest(TLRequest):
    """TL type: messages.getSearchResultsPositions"""
    CONSTRUCTOR_ID = 0x9c7f2f10
    SUBCLASS_OF_ID = 0xd963708d

    def __init__(self, peer: 'TypeInputPeer', filter: 'TypeMessagesFilter', offset_id: int, limit: int, saved_peer_id: Optional['TypeInputPeer'] = None):
        self.peer = peer
        self.filter = filter
        self.offset_id = offset_id
        self.limit = limit
        self.saved_peer_id = saved_peer_id

    def to_dict(self):
        return {
            '_': 'GetSearchResultsPositionsRequest',
            'peer': self.peer,
            'filter': self.filter,
            'offset_id': self.offset_id,
            'limit': self.limit,
            '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.saved_peer_id is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.filter))
        buf.write(struct.pack('<i', self.offset_id))
        buf.write(struct.pack('<i', self.limit))
        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 << 2):
            _val_saved_peer_id = reader.tgread_object()
            _args['saved_peer_id'] = _val_saved_peer_id
        else:
            _args['saved_peer_id'] = None
        _val_filter = reader.tgread_object()
        _args['filter'] = _val_filter
        _val_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetSplitRangesRequest(TLRequest):
    """TL type: messages.getSplitRanges"""
    CONSTRUCTOR_ID = 0x1cff7e08
    SUBCLASS_OF_ID = 0x5ba52504

    def __init__(self):
        pass

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

    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 GetSponsoredMessagesRequest(TLRequest):
    """TL type: messages.getSponsoredMessages"""
    CONSTRUCTOR_ID = 0x3d6ce850
    SUBCLASS_OF_ID = 0x7f4169e0

    def __init__(self, peer: 'TypeInputPeer', msg_id: Optional[int] = None):
        self.peer = peer
        self.msg_id = msg_id

    def to_dict(self):
        return {
            '_': 'GetSponsoredMessagesRequest',
            '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))
        flags = 0
        if self.msg_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        if self.msg_id is not None:
            buf.write(struct.pack('<i', self.msg_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_msg_id = reader.read_int()
            _args['msg_id'] = _val_msg_id
        else:
            _args['msg_id'] = None
        return cls(**_args)


class GetStatsUrlRequest(TLRequest):
    """TL type: messages.getStatsURL"""
    CONSTRUCTOR_ID = 0x812c2ae6
    SUBCLASS_OF_ID = 0x8d4c94c0

    def __init__(self, peer: 'TypeInputPeer', params: str, dark: Optional[bool] = None):
        self.peer = peer
        self.params = params
        self.dark = dark

    def to_dict(self):
        return {
            '_': 'GetStatsUrlRequest',
            'peer': self.peer,
            'params': self.params,
            'dark': self.dark,
        }

    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)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.params))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['dark'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_params = reader.tgread_string()
        _args['params'] = _val_params
        return cls(**_args)


class GetStickerSetRequest(TLRequest):
    """TL type: messages.getStickerSet"""
    CONSTRUCTOR_ID = 0xc8a0ec74
    SUBCLASS_OF_ID = 0x9b704a5a

    def __init__(self, stickerset: 'TypeInputStickerSet', hash: int):
        self.stickerset = stickerset
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'GetStickerSetRequest',
            'stickerset': self.stickerset,
            'hash': self.hash,
        }

    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.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_stickerset = reader.tgread_object()
        _args['stickerset'] = _val_stickerset
        _val_hash = reader.read_int()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetStickersRequest(TLRequest):
    """TL type: messages.getStickers"""
    CONSTRUCTOR_ID = 0xd5a5d3a1
    SUBCLASS_OF_ID = 0xd73bb9de

    def __init__(self, emoticon: str, hash: int):
        self.emoticon = emoticon
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'GetStickersRequest',
            'emoticon': self.emoticon,
            '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.emoticon))
        buf.write(struct.pack('<q', self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetSuggestedDialogFiltersRequest(TLRequest):
    """TL type: messages.getSuggestedDialogFilters"""
    CONSTRUCTOR_ID = 0xa29cd42c
    SUBCLASS_OF_ID = 0x7b296c39

    def __init__(self):
        pass

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

    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 GetTopReactionsRequest(TLRequest):
    """TL type: messages.getTopReactions"""
    CONSTRUCTOR_ID = 0xbb8125ba
    SUBCLASS_OF_ID = 0xadc38324

    def __init__(self, limit: int, hash: int):
        self.limit = limit
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'GetTopReactionsRequest',
            '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('<i', self.limit))
        buf.write(struct.pack('<q', self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class GetUnreadMentionsRequest(TLRequest):
    """TL type: messages.getUnreadMentions"""
    CONSTRUCTOR_ID = 0xf107e790
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, peer: 'TypeInputPeer', offset_id: int, add_offset: int, limit: int, max_id: int, min_id: int, top_msg_id: Optional[int] = None):
        self.peer = peer
        self.offset_id = offset_id
        self.add_offset = add_offset
        self.limit = limit
        self.max_id = max_id
        self.min_id = min_id
        self.top_msg_id = top_msg_id

    def to_dict(self):
        return {
            '_': 'GetUnreadMentionsRequest',
            'peer': self.peer,
            'offset_id': self.offset_id,
            'add_offset': self.add_offset,
            'limit': self.limit,
            'max_id': self.max_id,
            'min_id': self.min_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.top_msg_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.offset_id))
        buf.write(struct.pack('<i', self.add_offset))
        buf.write(struct.pack('<i', self.limit))
        buf.write(struct.pack('<i', self.max_id))
        buf.write(struct.pack('<i', self.min_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)
        _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
        _val_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_add_offset = reader.read_int()
        _args['add_offset'] = _val_add_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        _val_min_id = reader.read_int()
        _args['min_id'] = _val_min_id
        return cls(**_args)


class GetUnreadReactionsRequest(TLRequest):
    """TL type: messages.getUnreadReactions"""
    CONSTRUCTOR_ID = 0xbd7f90ac
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, peer: 'TypeInputPeer', offset_id: int, add_offset: int, limit: int, max_id: int, min_id: int, top_msg_id: Optional[int] = None, saved_peer_id: Optional['TypeInputPeer'] = None):
        self.peer = peer
        self.offset_id = offset_id
        self.add_offset = add_offset
        self.limit = limit
        self.max_id = max_id
        self.min_id = min_id
        self.top_msg_id = top_msg_id
        self.saved_peer_id = saved_peer_id

    def to_dict(self):
        return {
            '_': 'GetUnreadReactionsRequest',
            'peer': self.peer,
            'offset_id': self.offset_id,
            'add_offset': self.add_offset,
            'limit': self.limit,
            'max_id': self.max_id,
            'min_id': self.min_id,
            '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.offset_id))
        buf.write(struct.pack('<i', self.add_offset))
        buf.write(struct.pack('<i', self.limit))
        buf.write(struct.pack('<i', self.max_id))
        buf.write(struct.pack('<i', self.min_id))
        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_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_add_offset = reader.read_int()
        _args['add_offset'] = _val_add_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        _val_min_id = reader.read_int()
        _args['min_id'] = _val_min_id
        return cls(**_args)


class GetWebPageRequest(TLRequest):
    """TL type: messages.getWebPage"""
    CONSTRUCTOR_ID = 0x8d9692a3
    SUBCLASS_OF_ID = 0x2cf8b154

    def __init__(self, url: str, hash: int):
        self.url = url
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'GetWebPageRequest',
            'url': self.url,
            '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.url))
        buf.write(struct.pack('<i', self.hash))
        return buf.getvalue()

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


class GetWebPagePreviewRequest(TLRequest):
    """TL type: messages.getWebPagePreview"""
    CONSTRUCTOR_ID = 0x570d6f6f
    SUBCLASS_OF_ID = 0xe29410c2

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

    def to_dict(self):
        return {
            '_': 'GetWebPagePreviewRequest',
            'message': self.message,
            '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 << 3)
        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))
        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 << 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
        return cls(**_args)


class GetWebViewResultRequest(TLRequest):
    """TL type: messages.getWebViewResult"""
    CONSTRUCTOR_ID = 0x22b6c214
    SUBCLASS_OF_ID = 0xd8597669

    def __init__(self, peer: 'TypeInputPeer', bot: 'TypeInputUser', query_id: int):
        self.peer = peer
        self.bot = bot
        self.query_id = query_id

    def to_dict(self):
        return {
            '_': 'GetWebViewResultRequest',
            'peer': self.peer,
            'bot': self.bot,
            'query_id': self.query_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.bot))
        buf.write(struct.pack('<q', self.query_id))
        return buf.getvalue()

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


class HideAllChatJoinRequestsRequest(TLRequest):
    """TL type: messages.hideAllChatJoinRequests"""
    CONSTRUCTOR_ID = 0xe085f4ea
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', approved: Optional[bool] = None, link: Optional[str] = None):
        self.peer = peer
        self.approved = approved
        self.link = link

    def to_dict(self):
        return {
            '_': 'HideAllChatJoinRequestsRequest',
            'peer': self.peer,
            'approved': self.approved,
            'link': self.link,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['approved'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 1):
            _val_link = reader.tgread_string()
            _args['link'] = _val_link
        else:
            _args['link'] = None
        return cls(**_args)


class HideChatJoinRequestRequest(TLRequest):
    """TL type: messages.hideChatJoinRequest"""
    CONSTRUCTOR_ID = 0x7fe7e815
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', user_id: 'TypeInputUser', approved: Optional[bool] = None):
        self.peer = peer
        self.user_id = user_id
        self.approved = approved

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

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['approved'] = bool(flags & (1 << 0))
        _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 HidePeerSettingsBarRequest(TLRequest):
    """TL type: messages.hidePeerSettingsBar"""
    CONSTRUCTOR_ID = 0x4facb138
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'HidePeerSettingsBarRequest',
            '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 ImportChatInviteRequest(TLRequest):
    """TL type: messages.importChatInvite"""
    CONSTRUCTOR_ID = 0x6c50051c
    SUBCLASS_OF_ID = 0x8af52aac

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

    def to_dict(self):
        return {
            '_': 'ImportChatInviteRequest',
            '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 InitHistoryImportRequest(TLRequest):
    """TL type: messages.initHistoryImport"""
    CONSTRUCTOR_ID = 0x34090c3b
    SUBCLASS_OF_ID = 0xb18bb50a

    def __init__(self, peer: 'TypeInputPeer', file: 'TypeInputFile', media_count: int):
        self.peer = peer
        self.file = file
        self.media_count = media_count

    def to_dict(self):
        return {
            '_': 'InitHistoryImportRequest',
            'peer': self.peer,
            'file': self.file,
            'media_count': self.media_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(bytes(self.file))
        buf.write(struct.pack('<i', self.media_count))
        return buf.getvalue()

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


class InstallStickerSetRequest(TLRequest):
    """TL type: messages.installStickerSet"""
    CONSTRUCTOR_ID = 0xc78fe460
    SUBCLASS_OF_ID = 0x67cb3fe8

    def __init__(self, stickerset: 'TypeInputStickerSet', archived: bool):
        self.stickerset = stickerset
        self.archived = archived

    def to_dict(self):
        return {
            '_': 'InstallStickerSetRequest',
            'stickerset': self.stickerset,
            'archived': self.archived,
        }

    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', 0x997275b5 if self.archived else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_stickerset = reader.tgread_object()
        _args['stickerset'] = _val_stickerset
        _val_archived = reader.tgread_bool()
        _args['archived'] = _val_archived
        return cls(**_args)


class MarkDialogUnreadRequest(TLRequest):
    """TL type: messages.markDialogUnread"""
    CONSTRUCTOR_ID = 0x8c5006f8
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputDialogPeer', unread: Optional[bool] = None, parent_peer: Optional['TypeInputPeer'] = None):
        self.peer = peer
        self.unread = unread
        self.parent_peer = parent_peer

    def to_dict(self):
        return {
            '_': 'MarkDialogUnreadRequest',
            'peer': self.peer,
            'unread': self.unread,
            'parent_peer': self.parent_peer,
        }

    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.parent_peer is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        if self.parent_peer is not None:
            buf.write(bytes(self.parent_peer))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['unread'] = bool(flags & (1 << 0))
        if flags & (1 << 1):
            _val_parent_peer = reader.tgread_object()
            _args['parent_peer'] = _val_parent_peer
        else:
            _args['parent_peer'] = None
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class MigrateChatRequest(TLRequest):
    """TL type: messages.migrateChat"""
    CONSTRUCTOR_ID = 0xa2875319
    SUBCLASS_OF_ID = 0x8af52aac

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

    def to_dict(self):
        return {
            '_': 'MigrateChatRequest',
            '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 ProlongWebViewRequest(TLRequest):
    """TL type: messages.prolongWebView"""
    CONSTRUCTOR_ID = 0xb0d81a83
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPeer', bot: 'TypeInputUser', query_id: int, silent: Optional[bool] = None, reply_to: Optional['TypeInputReplyTo'] = None, send_as: Optional['TypeInputPeer'] = None):
        self.peer = peer
        self.bot = bot
        self.query_id = query_id
        self.silent = silent
        self.reply_to = reply_to
        self.send_as = send_as

    def to_dict(self):
        return {
            '_': 'ProlongWebViewRequest',
            'peer': self.peer,
            'bot': self.bot,
            'query_id': self.query_id,
            'silent': self.silent,
            'reply_to': self.reply_to,
            'send_as': self.send_as,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.silent:
            flags |= (1 << 5)
        if self.reply_to is not None:
            flags |= (1 << 0)
        if self.send_as is not None:
            flags |= (1 << 13)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.bot))
        buf.write(struct.pack('<q', self.query_id))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        if self.send_as is not None:
            buf.write(bytes(self.send_as))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['silent'] = bool(flags & (1 << 5))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        if flags & (1 << 0):
            _val_reply_to = reader.tgread_object()
            _args['reply_to'] = _val_reply_to
        else:
            _args['reply_to'] = None
        if flags & (1 << 13):
            _val_send_as = reader.tgread_object()
            _args['send_as'] = _val_send_as
        else:
            _args['send_as'] = None
        return cls(**_args)


class RateTranscribedAudioRequest(TLRequest):
    """TL type: messages.rateTranscribedAudio"""
    CONSTRUCTOR_ID = 0x7f1d072f
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, transcription_id: int, good: bool):
        self.peer = peer
        self.msg_id = msg_id
        self.transcription_id = transcription_id
        self.good = good

    def to_dict(self):
        return {
            '_': 'RateTranscribedAudioRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'transcription_id': self.transcription_id,
            'good': self.good,
        }

    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.transcription_id))
        buf.write(struct.pack('<I', 0x997275b5 if self.good else 0xbc799737))
        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_transcription_id = reader.read_long()
        _args['transcription_id'] = _val_transcription_id
        _val_good = reader.tgread_bool()
        _args['good'] = _val_good
        return cls(**_args)


class ReadDiscussionRequest(TLRequest):
    """TL type: messages.readDiscussion"""
    CONSTRUCTOR_ID = 0xf731a9f4
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'ReadDiscussionRequest',
            'peer': self.peer,
            'msg_id': self.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(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        buf.write(struct.pack('<i', self.read_max_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_read_max_id = reader.read_int()
        _args['read_max_id'] = _val_read_max_id
        return cls(**_args)


class ReadEncryptedHistoryRequest(TLRequest):
    """TL type: messages.readEncryptedHistory"""
    CONSTRUCTOR_ID = 0x7f4b690a
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputEncryptedChat', max_date: Optional[datetime]):
        self.peer = peer
        self.max_date = max_date

    def to_dict(self):
        return {
            '_': 'ReadEncryptedHistoryRequest',
            'peer': self.peer,
            'max_date': self.max_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.max_date))
        return buf.getvalue()

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


class ReadFeaturedStickersRequest(TLRequest):
    """TL type: messages.readFeaturedStickers"""
    CONSTRUCTOR_ID = 0x5b118126
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, id: List[int]):
        self.id = id

    def to_dict(self):
        return {
            '_': 'ReadFeaturedStickersRequest',
            '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', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            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_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_long()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        return cls(**_args)


class ReadHistoryRequest(TLRequest):
    """TL type: messages.readHistory"""
    CONSTRUCTOR_ID = 0x0e306d3a
    SUBCLASS_OF_ID = 0xced3c06e

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

    def to_dict(self):
        return {
            '_': 'ReadHistoryRequest',
            '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 ReadMentionsRequest(TLRequest):
    """TL type: messages.readMentions"""
    CONSTRUCTOR_ID = 0x36e5bf4d
    SUBCLASS_OF_ID = 0x2c49c116

    def __init__(self, peer: 'TypeInputPeer', top_msg_id: Optional[int] = None):
        self.peer = peer
        self.top_msg_id = top_msg_id

    def to_dict(self):
        return {
            '_': 'ReadMentionsRequest',
            '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))
        flags = 0
        if self.top_msg_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        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_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
        return cls(**_args)


class ReadMessageContentsRequest(TLRequest):
    """TL type: messages.readMessageContents"""
    CONSTRUCTOR_ID = 0x36a73f77
    SUBCLASS_OF_ID = 0xced3c06e

    def __init__(self, id: List[int]):
        self.id = id

    def to_dict(self):
        return {
            '_': 'ReadMessageContentsRequest',
            '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', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            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_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        return cls(**_args)


class ReadReactionsRequest(TLRequest):
    """TL type: messages.readReactions"""
    CONSTRUCTOR_ID = 0x9ec44f93
    SUBCLASS_OF_ID = 0x2c49c116

    def __init__(self, peer: 'TypeInputPeer', top_msg_id: Optional[int] = None, saved_peer_id: Optional['TypeInputPeer'] = None):
        self.peer = peer
        self.top_msg_id = top_msg_id
        self.saved_peer_id = saved_peer_id

    def to_dict(self):
        return {
            '_': 'ReadReactionsRequest',
            'peer': self.peer,
            '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))
        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
        return cls(**_args)


class ReadSavedHistoryRequest(TLRequest):
    """TL type: messages.readSavedHistory"""
    CONSTRUCTOR_ID = 0xba4a3b5b
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'ReadSavedHistoryRequest',
            'parent_peer': self.parent_peer,
            '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.parent_peer))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.max_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_parent_peer = reader.tgread_object()
        _args['parent_peer'] = _val_parent_peer
        _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 ReceivedMessagesRequest(TLRequest):
    """TL type: messages.receivedMessages"""
    CONSTRUCTOR_ID = 0x05a954c0
    SUBCLASS_OF_ID = 0x8565f897

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

    def to_dict(self):
        return {
            '_': 'ReceivedMessagesRequest',
            '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.max_id))
        return buf.getvalue()

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


class ReceivedQueueRequest(TLRequest):
    """TL type: messages.receivedQueue"""
    CONSTRUCTOR_ID = 0x55a5bb66
    SUBCLASS_OF_ID = 0x8918e168

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

    def to_dict(self):
        return {
            '_': 'ReceivedQueueRequest',
            'max_qts': self.max_qts,
        }

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

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


class ReorderPinnedDialogsRequest(TLRequest):
    """TL type: messages.reorderPinnedDialogs"""
    CONSTRUCTOR_ID = 0x3b1adf37
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, folder_id: int, order: List['TypeInputDialogPeer'], force: Optional[bool] = None):
        self.folder_id = folder_id
        self.order = order
        self.force = force

    def to_dict(self):
        return {
            '_': 'ReorderPinnedDialogsRequest',
            'folder_id': self.folder_id,
            'order': self.order,
            'force': self.force,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.force:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<i', self.folder_id))
        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)
        _args['force'] = bool(flags & (1 << 0))
        _val_folder_id = reader.read_int()
        _args['folder_id'] = _val_folder_id
        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
        return cls(**_args)


class ReorderPinnedForumTopicsRequest(TLRequest):
    """TL type: messages.reorderPinnedForumTopics"""
    CONSTRUCTOR_ID = 0x0e7841f0
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', order: List[int], force: Optional[bool] = None):
        self.peer = peer
        self.order = order
        self.force = force

    def to_dict(self):
        return {
            '_': 'ReorderPinnedForumTopicsRequest',
            'peer': self.peer,
            'order': self.order,
            'force': self.force,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.force:
            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.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)
        _args['force'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        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 ReorderPinnedSavedDialogsRequest(TLRequest):
    """TL type: messages.reorderPinnedSavedDialogs"""
    CONSTRUCTOR_ID = 0x8b716587
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, order: List['TypeInputDialogPeer'], force: Optional[bool] = None):
        self.order = order
        self.force = force

    def to_dict(self):
        return {
            '_': 'ReorderPinnedSavedDialogsRequest',
            'order': self.order,
            'force': self.force,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.force:
            flags |= (1 << 0)
        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(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['force'] = bool(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
        return cls(**_args)


class ReorderQuickRepliesRequest(TLRequest):
    """TL type: messages.reorderQuickReplies"""
    CONSTRUCTOR_ID = 0x60331907
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, order: List[int]):
        self.order = order

    def to_dict(self):
        return {
            '_': 'ReorderQuickRepliesRequest',
            '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 ReorderStickerSetsRequest(TLRequest):
    """TL type: messages.reorderStickerSets"""
    CONSTRUCTOR_ID = 0x78337739
    SUBCLASS_OF_ID = 0xf5b399ac

    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 {
            '_': 'ReorderStickerSetsRequest',
            '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 ReportRequest(TLRequest):
    """TL type: messages.report"""
    CONSTRUCTOR_ID = 0xfc78af9b
    SUBCLASS_OF_ID = 0xacd3f438

    def __init__(self, peer: 'TypeInputPeer', id: List[int], option: bytes, message: str):
        self.peer = peer
        self.id = id
        self.option = option
        self.message = message

    def to_dict(self):
        return {
            '_': 'ReportRequest',
            'peer': self.peer,
            'id': self.id,
            'option': self.option,
            'message': self.message,
        }

    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.id)))
        for item in self.id:
            buf.write(struct.pack('<i', self.item))
        buf.write(TLObject.serialize_bytes(self.option))
        buf.write(TLObject.serialize_bytes(self.message))
        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_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        _val_option = reader.tgread_bytes()
        _args['option'] = _val_option
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        return cls(**_args)


class ReportEncryptedSpamRequest(TLRequest):
    """TL type: messages.reportEncryptedSpam"""
    CONSTRUCTOR_ID = 0x4b0c8c0f
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'ReportEncryptedSpamRequest',
            '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 ReportMessagesDeliveryRequest(TLRequest):
    """TL type: messages.reportMessagesDelivery"""
    CONSTRUCTOR_ID = 0x5a6d7395
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPeer', id: List[int], push: Optional[bool] = None):
        self.peer = peer
        self.id = id
        self.push = push

    def to_dict(self):
        return {
            '_': 'ReportMessagesDeliveryRequest',
            'peer': self.peer,
            'id': self.id,
            'push': self.push,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.push:
            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.id)))
        for item in self.id:
            buf.write(struct.pack('<i', self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['push'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        reader.read_int(signed=False)  # skip vector id
        _count_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        return cls(**_args)


class ReportReactionRequest(TLRequest):
    """TL type: messages.reportReaction"""
    CONSTRUCTOR_ID = 0x3f64c076
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'ReportReactionRequest',
            'peer': self.peer,
            'id': self.id,
            'reaction_peer': self.reaction_peer,
        }

    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))
        buf.write(bytes(self.reaction_peer))
        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
        _val_reaction_peer = reader.tgread_object()
        _args['reaction_peer'] = _val_reaction_peer
        return cls(**_args)


class ReportSpamRequest(TLRequest):
    """TL type: messages.reportSpam"""
    CONSTRUCTOR_ID = 0xcf1592db
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'ReportSpamRequest',
            '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 ReportSponsoredMessageRequest(TLRequest):
    """TL type: messages.reportSponsoredMessage"""
    CONSTRUCTOR_ID = 0x12cbf0c4
    SUBCLASS_OF_ID = 0x26231822

    def __init__(self, option: bytes, random_id: bytes = None):
        self.option = option
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'ReportSponsoredMessageRequest',
            'option': self.option,
            'random_id': self.random_id,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_random_id = reader.tgread_bytes()
        _args['random_id'] = _val_random_id
        _val_option = reader.tgread_bytes()
        _args['option'] = _val_option
        return cls(**_args)


class RequestAppWebViewRequest(TLRequest):
    """TL type: messages.requestAppWebView"""
    CONSTRUCTOR_ID = 0x53618bce
    SUBCLASS_OF_ID = 0x93cea746

    def __init__(self, peer: 'TypeInputPeer', app: 'TypeInputBotApp', platform: str, write_allowed: Optional[bool] = None, compact: Optional[bool] = None, fullscreen: Optional[bool] = None, start_param: Optional[str] = None, theme_params: Optional['TypeDataJSON'] = None):
        self.peer = peer
        self.app = app
        self.platform = platform
        self.write_allowed = write_allowed
        self.compact = compact
        self.fullscreen = fullscreen
        self.start_param = start_param
        self.theme_params = theme_params

    def to_dict(self):
        return {
            '_': 'RequestAppWebViewRequest',
            'peer': self.peer,
            'app': self.app,
            'platform': self.platform,
            'write_allowed': self.write_allowed,
            'compact': self.compact,
            'fullscreen': self.fullscreen,
            'start_param': self.start_param,
            'theme_params': self.theme_params,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.write_allowed:
            flags |= (1 << 0)
        if self.compact:
            flags |= (1 << 7)
        if self.fullscreen:
            flags |= (1 << 8)
        if self.start_param is not None:
            flags |= (1 << 1)
        if self.theme_params is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.app))
        buf.write(TLObject.serialize_bytes(self.platform))
        if self.start_param is not None:
            buf.write(TLObject.serialize_bytes(self.start_param))
        if self.theme_params is not None:
            buf.write(bytes(self.theme_params))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['write_allowed'] = bool(flags & (1 << 0))
        _args['compact'] = bool(flags & (1 << 7))
        _args['fullscreen'] = bool(flags & (1 << 8))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_app = reader.tgread_object()
        _args['app'] = _val_app
        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_theme_params = reader.tgread_object()
            _args['theme_params'] = _val_theme_params
        else:
            _args['theme_params'] = None
        _val_platform = reader.tgread_string()
        _args['platform'] = _val_platform
        return cls(**_args)


class RequestEncryptionRequest(TLRequest):
    """TL type: messages.requestEncryption"""
    CONSTRUCTOR_ID = 0xf64daf43
    SUBCLASS_OF_ID = 0x6d28a37a

    def __init__(self, user_id: 'TypeInputUser', g_a: bytes, random_id: int = None):
        self.user_id = user_id
        self.g_a = g_a
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'RequestEncryptionRequest',
            'user_id': self.user_id,
            'g_a': self.g_a,
            '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.user_id))
        buf.write(TLObject.serialize_bytes(self.g_a))
        buf.write(struct.pack('<i', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        _val_random_id = reader.read_int()
        _args['random_id'] = _val_random_id
        _val_g_a = reader.tgread_bytes()
        _args['g_a'] = _val_g_a
        return cls(**_args)


class RequestMainWebViewRequest(TLRequest):
    """TL type: messages.requestMainWebView"""
    CONSTRUCTOR_ID = 0xc9e01e7b
    SUBCLASS_OF_ID = 0x93cea746

    def __init__(self, peer: 'TypeInputPeer', bot: 'TypeInputUser', platform: str, compact: Optional[bool] = None, fullscreen: Optional[bool] = None, start_param: Optional[str] = None, theme_params: Optional['TypeDataJSON'] = None):
        self.peer = peer
        self.bot = bot
        self.platform = platform
        self.compact = compact
        self.fullscreen = fullscreen
        self.start_param = start_param
        self.theme_params = theme_params

    def to_dict(self):
        return {
            '_': 'RequestMainWebViewRequest',
            'peer': self.peer,
            'bot': self.bot,
            'platform': self.platform,
            'compact': self.compact,
            'fullscreen': self.fullscreen,
            'start_param': self.start_param,
            'theme_params': self.theme_params,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.compact:
            flags |= (1 << 7)
        if self.fullscreen:
            flags |= (1 << 8)
        if self.start_param is not None:
            flags |= (1 << 1)
        if self.theme_params is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.bot))
        buf.write(TLObject.serialize_bytes(self.platform))
        if self.start_param is not None:
            buf.write(TLObject.serialize_bytes(self.start_param))
        if self.theme_params is not None:
            buf.write(bytes(self.theme_params))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['compact'] = bool(flags & (1 << 7))
        _args['fullscreen'] = bool(flags & (1 << 8))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        if flags & (1 << 1):
            _val_start_param = reader.tgread_string()
            _args['start_param'] = _val_start_param
        else:
            _args['start_param'] = None
        if flags & (1 << 0):
            _val_theme_params = reader.tgread_object()
            _args['theme_params'] = _val_theme_params
        else:
            _args['theme_params'] = None
        _val_platform = reader.tgread_string()
        _args['platform'] = _val_platform
        return cls(**_args)


class RequestSimpleWebViewRequest(TLRequest):
    """TL type: messages.requestSimpleWebView"""
    CONSTRUCTOR_ID = 0x413a3e73
    SUBCLASS_OF_ID = 0x93cea746

    def __init__(self, bot: 'TypeInputUser', platform: str, from_switch_webview: Optional[bool] = None, from_side_menu: Optional[bool] = None, compact: Optional[bool] = None, fullscreen: Optional[bool] = None, url: Optional[str] = None, start_param: Optional[str] = None, theme_params: Optional['TypeDataJSON'] = None):
        self.bot = bot
        self.platform = platform
        self.from_switch_webview = from_switch_webview
        self.from_side_menu = from_side_menu
        self.compact = compact
        self.fullscreen = fullscreen
        self.url = url
        self.start_param = start_param
        self.theme_params = theme_params

    def to_dict(self):
        return {
            '_': 'RequestSimpleWebViewRequest',
            'bot': self.bot,
            'platform': self.platform,
            'from_switch_webview': self.from_switch_webview,
            'from_side_menu': self.from_side_menu,
            'compact': self.compact,
            'fullscreen': self.fullscreen,
            'url': self.url,
            'start_param': self.start_param,
            'theme_params': self.theme_params,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.from_switch_webview:
            flags |= (1 << 1)
        if self.from_side_menu:
            flags |= (1 << 2)
        if self.compact:
            flags |= (1 << 7)
        if self.fullscreen:
            flags |= (1 << 8)
        if self.url is not None:
            flags |= (1 << 3)
        if self.start_param is not None:
            flags |= (1 << 4)
        if self.theme_params is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.bot))
        buf.write(TLObject.serialize_bytes(self.platform))
        if self.url is not None:
            buf.write(TLObject.serialize_bytes(self.url))
        if self.start_param is not None:
            buf.write(TLObject.serialize_bytes(self.start_param))
        if self.theme_params is not None:
            buf.write(bytes(self.theme_params))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['from_switch_webview'] = bool(flags & (1 << 1))
        _args['from_side_menu'] = bool(flags & (1 << 2))
        _args['compact'] = bool(flags & (1 << 7))
        _args['fullscreen'] = bool(flags & (1 << 8))
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        if flags & (1 << 3):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        if flags & (1 << 4):
            _val_start_param = reader.tgread_string()
            _args['start_param'] = _val_start_param
        else:
            _args['start_param'] = None
        if flags & (1 << 0):
            _val_theme_params = reader.tgread_object()
            _args['theme_params'] = _val_theme_params
        else:
            _args['theme_params'] = None
        _val_platform = reader.tgread_string()
        _args['platform'] = _val_platform
        return cls(**_args)


class RequestUrlAuthRequest(TLRequest):
    """TL type: messages.requestUrlAuth"""
    CONSTRUCTOR_ID = 0x198fb446
    SUBCLASS_OF_ID = 0x7765cb1e

    def __init__(self, peer: Optional['TypeInputPeer'] = None, msg_id: Optional[int] = None, button_id: Optional[int] = None, url: Optional[str] = None):
        self.peer = peer
        self.msg_id = msg_id
        self.button_id = button_id
        self.url = url

    def to_dict(self):
        return {
            '_': 'RequestUrlAuthRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'button_id': self.button_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.button_id is not None:
            flags |= (1 << 1)
        if self.url is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        if self.peer is not None:
            buf.write(bytes(self.peer))
        if self.msg_id is not None:
            buf.write(struct.pack('<i', self.msg_id))
        if self.button_id is not None:
            buf.write(struct.pack('<i', self.button_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)
        if flags & (1 << 1):
            _val_peer = reader.tgread_object()
            _args['peer'] = _val_peer
        else:
            _args['peer'] = None
        if flags & (1 << 1):
            _val_msg_id = reader.read_int()
            _args['msg_id'] = _val_msg_id
        else:
            _args['msg_id'] = None
        if flags & (1 << 1):
            _val_button_id = reader.read_int()
            _args['button_id'] = _val_button_id
        else:
            _args['button_id'] = None
        if flags & (1 << 2):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        return cls(**_args)


class RequestWebViewRequest(TLRequest):
    """TL type: messages.requestWebView"""
    CONSTRUCTOR_ID = 0x269dc2c1
    SUBCLASS_OF_ID = 0x93cea746

    def __init__(self, peer: 'TypeInputPeer', bot: 'TypeInputUser', platform: str, from_bot_menu: Optional[bool] = None, silent: Optional[bool] = None, compact: Optional[bool] = None, fullscreen: Optional[bool] = None, url: Optional[str] = None, start_param: Optional[str] = None, theme_params: Optional['TypeDataJSON'] = None, reply_to: Optional['TypeInputReplyTo'] = None, send_as: Optional['TypeInputPeer'] = None):
        self.peer = peer
        self.bot = bot
        self.platform = platform
        self.from_bot_menu = from_bot_menu
        self.silent = silent
        self.compact = compact
        self.fullscreen = fullscreen
        self.url = url
        self.start_param = start_param
        self.theme_params = theme_params
        self.reply_to = reply_to
        self.send_as = send_as

    def to_dict(self):
        return {
            '_': 'RequestWebViewRequest',
            'peer': self.peer,
            'bot': self.bot,
            'platform': self.platform,
            'from_bot_menu': self.from_bot_menu,
            'silent': self.silent,
            'compact': self.compact,
            'fullscreen': self.fullscreen,
            'url': self.url,
            'start_param': self.start_param,
            'theme_params': self.theme_params,
            'reply_to': self.reply_to,
            'send_as': self.send_as,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.from_bot_menu:
            flags |= (1 << 4)
        if self.silent:
            flags |= (1 << 5)
        if self.compact:
            flags |= (1 << 7)
        if self.fullscreen:
            flags |= (1 << 8)
        if self.url is not None:
            flags |= (1 << 1)
        if self.start_param is not None:
            flags |= (1 << 3)
        if self.theme_params is not None:
            flags |= (1 << 2)
        if self.reply_to is not None:
            flags |= (1 << 0)
        if self.send_as is not None:
            flags |= (1 << 13)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.bot))
        buf.write(TLObject.serialize_bytes(self.platform))
        if self.url is not None:
            buf.write(TLObject.serialize_bytes(self.url))
        if self.start_param is not None:
            buf.write(TLObject.serialize_bytes(self.start_param))
        if self.theme_params is not None:
            buf.write(bytes(self.theme_params))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        if self.send_as is not None:
            buf.write(bytes(self.send_as))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['from_bot_menu'] = bool(flags & (1 << 4))
        _args['silent'] = bool(flags & (1 << 5))
        _args['compact'] = bool(flags & (1 << 7))
        _args['fullscreen'] = bool(flags & (1 << 8))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        if flags & (1 << 1):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        if flags & (1 << 3):
            _val_start_param = reader.tgread_string()
            _args['start_param'] = _val_start_param
        else:
            _args['start_param'] = None
        if flags & (1 << 2):
            _val_theme_params = reader.tgread_object()
            _args['theme_params'] = _val_theme_params
        else:
            _args['theme_params'] = None
        _val_platform = reader.tgread_string()
        _args['platform'] = _val_platform
        if flags & (1 << 0):
            _val_reply_to = reader.tgread_object()
            _args['reply_to'] = _val_reply_to
        else:
            _args['reply_to'] = None
        if flags & (1 << 13):
            _val_send_as = reader.tgread_object()
            _args['send_as'] = _val_send_as
        else:
            _args['send_as'] = None
        return cls(**_args)


class SaveDefaultSendAsRequest(TLRequest):
    """TL type: messages.saveDefaultSendAs"""
    CONSTRUCTOR_ID = 0xccfddf96
    SUBCLASS_OF_ID = 0xf5b399ac

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

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

    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.send_as))
        return buf.getvalue()

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


class SaveDraftRequest(TLRequest):
    """TL type: messages.saveDraft"""
    CONSTRUCTOR_ID = 0x54ae308e
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPeer', message: str, 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.peer = peer
        self.message = message
        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 {
            '_': 'SaveDraftRequest',
            'peer': self.peer,
            'message': self.message,
            '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(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.message))
        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_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _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
        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 SaveGifRequest(TLRequest):
    """TL type: messages.saveGif"""
    CONSTRUCTOR_ID = 0x327a30cb
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, id: 'TypeInputDocument', unsave: bool):
        self.id = id
        self.unsave = unsave

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

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

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


class SavePreparedInlineMessageRequest(TLRequest):
    """TL type: messages.savePreparedInlineMessage"""
    CONSTRUCTOR_ID = 0xf21f7f2f
    SUBCLASS_OF_ID = 0xef9119bb

    def __init__(self, result: 'TypeInputBotInlineResult', user_id: 'TypeInputUser', peer_types: Optional[List['TypeInlineQueryPeerType']] = None):
        self.result = result
        self.user_id = user_id
        self.peer_types = peer_types

    def to_dict(self):
        return {
            '_': 'SavePreparedInlineMessageRequest',
            'result': self.result,
            'user_id': self.user_id,
            '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.peer_types is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.result))
        buf.write(bytes(self.user_id))
        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)
        _val_result = reader.tgread_object()
        _args['result'] = _val_result
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        if flags & (1 << 0):
            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 SaveRecentStickerRequest(TLRequest):
    """TL type: messages.saveRecentSticker"""
    CONSTRUCTOR_ID = 0x392718f8
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, id: 'TypeInputDocument', unsave: bool, attached: Optional[bool] = None):
        self.id = id
        self.unsave = unsave
        self.attached = attached

    def to_dict(self):
        return {
            '_': 'SaveRecentStickerRequest',
            'id': self.id,
            'unsave': self.unsave,
            'attached': self.attached,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['attached'] = bool(flags & (1 << 0))
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        _val_unsave = reader.tgread_bool()
        _args['unsave'] = _val_unsave
        return cls(**_args)


class SearchRequest(TLRequest):
    """TL type: messages.search"""
    CONSTRUCTOR_ID = 0x29ee847a
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, peer: 'TypeInputPeer', q: str, filter: 'TypeMessagesFilter', min_date: Optional[datetime], max_date: Optional[datetime], offset_id: int, add_offset: int, limit: int, max_id: int, min_id: int, hash: int, from_id: Optional['TypeInputPeer'] = None, saved_peer_id: Optional['TypeInputPeer'] = None, saved_reaction: Optional[List['TypeReaction']] = None, top_msg_id: Optional[int] = None):
        self.peer = peer
        self.q = q
        self.filter = filter
        self.min_date = min_date
        self.max_date = max_date
        self.offset_id = offset_id
        self.add_offset = add_offset
        self.limit = limit
        self.max_id = max_id
        self.min_id = min_id
        self.hash = hash
        self.from_id = from_id
        self.saved_peer_id = saved_peer_id
        self.saved_reaction = saved_reaction
        self.top_msg_id = top_msg_id

    def to_dict(self):
        return {
            '_': 'SearchRequest',
            'peer': self.peer,
            'q': self.q,
            'filter': self.filter,
            'min_date': self.min_date,
            'max_date': self.max_date,
            'offset_id': self.offset_id,
            'add_offset': self.add_offset,
            'limit': self.limit,
            'max_id': self.max_id,
            'min_id': self.min_id,
            'hash': self.hash,
            'from_id': self.from_id,
            'saved_peer_id': self.saved_peer_id,
            'saved_reaction': self.saved_reaction,
            '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.from_id is not None:
            flags |= (1 << 0)
        if self.saved_peer_id is not None:
            flags |= (1 << 2)
        if self.saved_reaction is not None:
            flags |= (1 << 3)
        if self.top_msg_id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.q))
        buf.write(bytes(self.filter))
        buf.write(struct.pack('<i', self.min_date))
        buf.write(struct.pack('<i', self.max_date))
        buf.write(struct.pack('<i', self.offset_id))
        buf.write(struct.pack('<i', self.add_offset))
        buf.write(struct.pack('<i', self.limit))
        buf.write(struct.pack('<i', self.max_id))
        buf.write(struct.pack('<i', self.min_id))
        buf.write(struct.pack('<q', self.hash))
        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.saved_reaction is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.saved_reaction)))
            for item in self.saved_reaction:
                buf.write(bytes(self.item))
        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_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_q = reader.tgread_string()
        _args['q'] = _val_q
        if flags & (1 << 0):
            _val_from_id = reader.tgread_object()
            _args['from_id'] = _val_from_id
        else:
            _args['from_id'] = None
        if flags & (1 << 2):
            _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):
            reader.read_int(signed=False)  # skip vector id
            _count_saved_reaction = reader.read_int()
            _list_saved_reaction = []
            for _ in range(_count_saved_reaction):
                _item_saved_reaction = reader.tgread_object()
                _list_saved_reaction.append(_item_saved_reaction)
            _args['saved_reaction'] = _list_saved_reaction
        else:
            _args['saved_reaction'] = 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
        _val_filter = reader.tgread_object()
        _args['filter'] = _val_filter
        _val_min_date = reader.read_int()
        _args['min_date'] = _val_min_date
        _val_max_date = reader.read_int()
        _args['max_date'] = _val_max_date
        _val_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_add_offset = reader.read_int()
        _args['add_offset'] = _val_add_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        _val_min_id = reader.read_int()
        _args['min_id'] = _val_min_id
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class SearchCustomEmojiRequest(TLRequest):
    """TL type: messages.searchCustomEmoji"""
    CONSTRUCTOR_ID = 0x2c11c0d7
    SUBCLASS_OF_ID = 0xbcef6aba

    def __init__(self, emoticon: str, hash: int):
        self.emoticon = emoticon
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'SearchCustomEmojiRequest',
            'emoticon': self.emoticon,
            '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.emoticon))
        buf.write(struct.pack('<q', self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class SearchEmojiStickerSetsRequest(TLRequest):
    """TL type: messages.searchEmojiStickerSets"""
    CONSTRUCTOR_ID = 0x92b4494c
    SUBCLASS_OF_ID = 0x040df361

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

    def to_dict(self):
        return {
            '_': 'SearchEmojiStickerSetsRequest',
            'q': self.q,
            'hash': self.hash,
            'exclude_featured': self.exclude_featured,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['exclude_featured'] = bool(flags & (1 << 0))
        _val_q = reader.tgread_string()
        _args['q'] = _val_q
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class SearchGlobalRequest(TLRequest):
    """TL type: messages.searchGlobal"""
    CONSTRUCTOR_ID = 0x4bc6589a
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, q: str, filter: 'TypeMessagesFilter', min_date: Optional[datetime], max_date: Optional[datetime], offset_rate: int, offset_peer: 'TypeInputPeer', offset_id: int, limit: int, broadcasts_only: Optional[bool] = None, groups_only: Optional[bool] = None, users_only: Optional[bool] = None, folder_id: Optional[int] = None):
        self.q = q
        self.filter = filter
        self.min_date = min_date
        self.max_date = max_date
        self.offset_rate = offset_rate
        self.offset_peer = offset_peer
        self.offset_id = offset_id
        self.limit = limit
        self.broadcasts_only = broadcasts_only
        self.groups_only = groups_only
        self.users_only = users_only
        self.folder_id = folder_id

    def to_dict(self):
        return {
            '_': 'SearchGlobalRequest',
            'q': self.q,
            'filter': self.filter,
            'min_date': self.min_date,
            'max_date': self.max_date,
            'offset_rate': self.offset_rate,
            'offset_peer': self.offset_peer,
            'offset_id': self.offset_id,
            'limit': self.limit,
            'broadcasts_only': self.broadcasts_only,
            'groups_only': self.groups_only,
            'users_only': self.users_only,
            '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.broadcasts_only:
            flags |= (1 << 1)
        if self.groups_only:
            flags |= (1 << 2)
        if self.users_only:
            flags |= (1 << 3)
        if self.folder_id is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.q))
        buf.write(bytes(self.filter))
        buf.write(struct.pack('<i', self.min_date))
        buf.write(struct.pack('<i', self.max_date))
        buf.write(struct.pack('<i', self.offset_rate))
        buf.write(bytes(self.offset_peer))
        buf.write(struct.pack('<i', self.offset_id))
        buf.write(struct.pack('<i', self.limit))
        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['broadcasts_only'] = bool(flags & (1 << 1))
        _args['groups_only'] = bool(flags & (1 << 2))
        _args['users_only'] = bool(flags & (1 << 3))
        if flags & (1 << 0):
            _val_folder_id = reader.read_int()
            _args['folder_id'] = _val_folder_id
        else:
            _args['folder_id'] = None
        _val_q = reader.tgread_string()
        _args['q'] = _val_q
        _val_filter = reader.tgread_object()
        _args['filter'] = _val_filter
        _val_min_date = reader.read_int()
        _args['min_date'] = _val_min_date
        _val_max_date = reader.read_int()
        _args['max_date'] = _val_max_date
        _val_offset_rate = reader.read_int()
        _args['offset_rate'] = _val_offset_rate
        _val_offset_peer = reader.tgread_object()
        _args['offset_peer'] = _val_offset_peer
        _val_offset_id = reader.read_int()
        _args['offset_id'] = _val_offset_id
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class SearchSentMediaRequest(TLRequest):
    """TL type: messages.searchSentMedia"""
    CONSTRUCTOR_ID = 0x107e31a0
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, q: str, filter: 'TypeMessagesFilter', limit: int):
        self.q = q
        self.filter = filter
        self.limit = limit

    def to_dict(self):
        return {
            '_': 'SearchSentMediaRequest',
            'q': self.q,
            'filter': self.filter,
            'limit': self.limit,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_q = reader.tgread_string()
        _args['q'] = _val_q
        _val_filter = reader.tgread_object()
        _args['filter'] = _val_filter
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class SearchStickerSetsRequest(TLRequest):
    """TL type: messages.searchStickerSets"""
    CONSTRUCTOR_ID = 0x35705b8a
    SUBCLASS_OF_ID = 0x040df361

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

    def to_dict(self):
        return {
            '_': 'SearchStickerSetsRequest',
            'q': self.q,
            'hash': self.hash,
            'exclude_featured': self.exclude_featured,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['exclude_featured'] = bool(flags & (1 << 0))
        _val_q = reader.tgread_string()
        _args['q'] = _val_q
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class SearchStickersRequest(TLRequest):
    """TL type: messages.searchStickers"""
    CONSTRUCTOR_ID = 0x29b1c66a
    SUBCLASS_OF_ID = 0x06402151

    def __init__(self, q: str, emoticon: str, lang_code: List[str], offset: int, limit: int, hash: int, emojis: Optional[bool] = None):
        self.q = q
        self.emoticon = emoticon
        self.lang_code = lang_code
        self.offset = offset
        self.limit = limit
        self.hash = hash
        self.emojis = emojis

    def to_dict(self):
        return {
            '_': 'SearchStickersRequest',
            'q': self.q,
            'emoticon': self.emoticon,
            'lang_code': self.lang_code,
            'offset': self.offset,
            'limit': self.limit,
            'hash': self.hash,
            'emojis': self.emojis,
        }

    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)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.q))
        buf.write(TLObject.serialize_bytes(self.emoticon))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.lang_code)))
        for item in self.lang_code:
            buf.write(TLObject.serialize_bytes(self.item))
        buf.write(struct.pack('<i', self.offset))
        buf.write(struct.pack('<i', self.limit))
        buf.write(struct.pack('<q', self.hash))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['emojis'] = bool(flags & (1 << 0))
        _val_q = reader.tgread_string()
        _args['q'] = _val_q
        _val_emoticon = reader.tgread_string()
        _args['emoticon'] = _val_emoticon
        reader.read_int(signed=False)  # skip vector id
        _count_lang_code = reader.read_int()
        _list_lang_code = []
        for _ in range(_count_lang_code):
            _item_lang_code = reader.tgread_string()
            _list_lang_code.append(_item_lang_code)
        _args['lang_code'] = _list_lang_code
        _val_offset = reader.read_int()
        _args['offset'] = _val_offset
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        _val_hash = reader.read_long()
        _args['hash'] = _val_hash
        return cls(**_args)


class SendBotRequestedPeerRequest(TLRequest):
    """TL type: messages.sendBotRequestedPeer"""
    CONSTRUCTOR_ID = 0x91b2d060
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, button_id: int, requested_peers: List['TypeInputPeer']):
        self.peer = peer
        self.msg_id = msg_id
        self.button_id = button_id
        self.requested_peers = requested_peers

    def to_dict(self):
        return {
            '_': 'SendBotRequestedPeerRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'button_id': self.button_id,
            'requested_peers': self.requested_peers,
        }

    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.button_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.requested_peers)))
        for item in self.requested_peers:
            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
        _val_button_id = reader.read_int()
        _args['button_id'] = _val_button_id
        reader.read_int(signed=False)  # skip vector id
        _count_requested_peers = reader.read_int()
        _list_requested_peers = []
        for _ in range(_count_requested_peers):
            _item_requested_peers = reader.tgread_object()
            _list_requested_peers.append(_item_requested_peers)
        _args['requested_peers'] = _list_requested_peers
        return cls(**_args)


class SendEncryptedRequest(TLRequest):
    """TL type: messages.sendEncrypted"""
    CONSTRUCTOR_ID = 0x44fa7a15
    SUBCLASS_OF_ID = 0xc99e3e50

    def __init__(self, peer: 'TypeInputEncryptedChat', data: bytes, silent: Optional[bool] = None, random_id: int = None):
        self.peer = peer
        self.data = data
        self.silent = silent
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'SendEncryptedRequest',
            'peer': self.peer,
            'data': self.data,
            'silent': self.silent,
            '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.silent:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.data))
        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['silent'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_data = reader.tgread_bytes()
        _args['data'] = _val_data
        return cls(**_args)


class SendEncryptedFileRequest(TLRequest):
    """TL type: messages.sendEncryptedFile"""
    CONSTRUCTOR_ID = 0x5559481d
    SUBCLASS_OF_ID = 0xc99e3e50

    def __init__(self, peer: 'TypeInputEncryptedChat', data: bytes, file: 'TypeInputEncryptedFile', silent: Optional[bool] = None, random_id: int = None):
        self.peer = peer
        self.data = data
        self.file = file
        self.silent = silent
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'SendEncryptedFileRequest',
            'peer': self.peer,
            'data': self.data,
            'file': self.file,
            'silent': self.silent,
            '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.silent:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.data))
        buf.write(bytes(self.file))
        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['silent'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_data = reader.tgread_bytes()
        _args['data'] = _val_data
        _val_file = reader.tgread_object()
        _args['file'] = _val_file
        return cls(**_args)


class SendEncryptedServiceRequest(TLRequest):
    """TL type: messages.sendEncryptedService"""
    CONSTRUCTOR_ID = 0x32d439a4
    SUBCLASS_OF_ID = 0xc99e3e50

    def __init__(self, peer: 'TypeInputEncryptedChat', data: bytes, random_id: int = None):
        self.peer = peer
        self.data = data
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'SendEncryptedServiceRequest',
            'peer': self.peer,
            'data': self.data,
            '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.peer))
        buf.write(TLObject.serialize_bytes(self.data))
        buf.write(struct.pack('<q', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_data = reader.tgread_bytes()
        _args['data'] = _val_data
        return cls(**_args)


class SendInlineBotResultRequest(TLRequest):
    """TL type: messages.sendInlineBotResult"""
    CONSTRUCTOR_ID = 0xc0cf7646
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', query_id: int, id: str, silent: Optional[bool] = None, background: Optional[bool] = None, clear_draft: Optional[bool] = None, hide_via: Optional[bool] = None, reply_to: Optional['TypeInputReplyTo'] = None, random_id: int = None, schedule_date: Optional[datetime] = None, send_as: Optional['TypeInputPeer'] = None, quick_reply_shortcut: Optional['TypeInputQuickReplyShortcut'] = None, allow_paid_stars: Optional[int] = None):
        self.peer = peer
        self.query_id = query_id
        self.id = id
        self.silent = silent
        self.background = background
        self.clear_draft = clear_draft
        self.hide_via = hide_via
        self.reply_to = reply_to
        self.random_id = random_id
        self.schedule_date = schedule_date
        self.send_as = send_as
        self.quick_reply_shortcut = quick_reply_shortcut
        self.allow_paid_stars = allow_paid_stars

    def to_dict(self):
        return {
            '_': 'SendInlineBotResultRequest',
            'peer': self.peer,
            'query_id': self.query_id,
            'id': self.id,
            'silent': self.silent,
            'background': self.background,
            'clear_draft': self.clear_draft,
            'hide_via': self.hide_via,
            'reply_to': self.reply_to,
            'random_id': self.random_id,
            'schedule_date': self.schedule_date,
            'send_as': self.send_as,
            'quick_reply_shortcut': self.quick_reply_shortcut,
            'allow_paid_stars': self.allow_paid_stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.silent:
            flags |= (1 << 5)
        if self.background:
            flags |= (1 << 6)
        if self.clear_draft:
            flags |= (1 << 7)
        if self.hide_via:
            flags |= (1 << 11)
        if self.reply_to is not None:
            flags |= (1 << 0)
        if self.schedule_date is not None:
            flags |= (1 << 10)
        if self.send_as is not None:
            flags |= (1 << 13)
        if self.quick_reply_shortcut is not None:
            flags |= (1 << 17)
        if self.allow_paid_stars is not None:
            flags |= (1 << 21)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<q', self.query_id))
        buf.write(TLObject.serialize_bytes(self.id))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        buf.write(struct.pack('<q', self.random_id))
        if self.schedule_date is not None:
            buf.write(struct.pack('<i', self.schedule_date))
        if self.send_as is not None:
            buf.write(bytes(self.send_as))
        if self.quick_reply_shortcut is not None:
            buf.write(bytes(self.quick_reply_shortcut))
        if self.allow_paid_stars is not None:
            buf.write(struct.pack('<q', self.allow_paid_stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['silent'] = bool(flags & (1 << 5))
        _args['background'] = bool(flags & (1 << 6))
        _args['clear_draft'] = bool(flags & (1 << 7))
        _args['hide_via'] = bool(flags & (1 << 11))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _val_reply_to = reader.tgread_object()
            _args['reply_to'] = _val_reply_to
        else:
            _args['reply_to'] = None
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        _val_id = reader.tgread_string()
        _args['id'] = _val_id
        if flags & (1 << 10):
            _val_schedule_date = reader.read_int()
            _args['schedule_date'] = _val_schedule_date
        else:
            _args['schedule_date'] = None
        if flags & (1 << 13):
            _val_send_as = reader.tgread_object()
            _args['send_as'] = _val_send_as
        else:
            _args['send_as'] = None
        if flags & (1 << 17):
            _val_quick_reply_shortcut = reader.tgread_object()
            _args['quick_reply_shortcut'] = _val_quick_reply_shortcut
        else:
            _args['quick_reply_shortcut'] = None
        if flags & (1 << 21):
            _val_allow_paid_stars = reader.read_long()
            _args['allow_paid_stars'] = _val_allow_paid_stars
        else:
            _args['allow_paid_stars'] = None
        return cls(**_args)


class SendMediaRequest(TLRequest):
    """TL type: messages.sendMedia"""
    CONSTRUCTOR_ID = 0x0330e77f
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', media: 'TypeInputMedia', message: str, silent: Optional[bool] = None, background: Optional[bool] = None, clear_draft: Optional[bool] = None, noforwards: Optional[bool] = None, update_stickersets_order: Optional[bool] = None, invert_media: Optional[bool] = None, allow_paid_floodskip: Optional[bool] = None, reply_to: Optional['TypeInputReplyTo'] = None, random_id: int = None, reply_markup: Optional['TypeReplyMarkup'] = None, entities: Optional[List['TypeMessageEntity']] = None, schedule_date: Optional[datetime] = None, schedule_repeat_period: Optional[int] = None, send_as: Optional['TypeInputPeer'] = None, quick_reply_shortcut: Optional['TypeInputQuickReplyShortcut'] = None, effect: Optional[int] = None, allow_paid_stars: Optional[int] = None, suggested_post: Optional['TypeSuggestedPost'] = None):
        self.peer = peer
        self.media = media
        self.message = message
        self.silent = silent
        self.background = background
        self.clear_draft = clear_draft
        self.noforwards = noforwards
        self.update_stickersets_order = update_stickersets_order
        self.invert_media = invert_media
        self.allow_paid_floodskip = allow_paid_floodskip
        self.reply_to = reply_to
        self.random_id = random_id
        self.reply_markup = reply_markup
        self.entities = entities
        self.schedule_date = schedule_date
        self.schedule_repeat_period = schedule_repeat_period
        self.send_as = send_as
        self.quick_reply_shortcut = quick_reply_shortcut
        self.effect = effect
        self.allow_paid_stars = allow_paid_stars
        self.suggested_post = suggested_post

    def to_dict(self):
        return {
            '_': 'SendMediaRequest',
            'peer': self.peer,
            'media': self.media,
            'message': self.message,
            'silent': self.silent,
            'background': self.background,
            'clear_draft': self.clear_draft,
            'noforwards': self.noforwards,
            'update_stickersets_order': self.update_stickersets_order,
            'invert_media': self.invert_media,
            'allow_paid_floodskip': self.allow_paid_floodskip,
            'reply_to': self.reply_to,
            'random_id': self.random_id,
            'reply_markup': self.reply_markup,
            'entities': self.entities,
            'schedule_date': self.schedule_date,
            'schedule_repeat_period': self.schedule_repeat_period,
            'send_as': self.send_as,
            'quick_reply_shortcut': self.quick_reply_shortcut,
            'effect': self.effect,
            'allow_paid_stars': self.allow_paid_stars,
            '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.silent:
            flags |= (1 << 5)
        if self.background:
            flags |= (1 << 6)
        if self.clear_draft:
            flags |= (1 << 7)
        if self.noforwards:
            flags |= (1 << 14)
        if self.update_stickersets_order:
            flags |= (1 << 15)
        if self.invert_media:
            flags |= (1 << 16)
        if self.allow_paid_floodskip:
            flags |= (1 << 19)
        if self.reply_to is not None:
            flags |= (1 << 0)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        if self.entities is not None:
            flags |= (1 << 3)
        if self.schedule_date is not None:
            flags |= (1 << 10)
        if self.schedule_repeat_period is not None:
            flags |= (1 << 24)
        if self.send_as is not None:
            flags |= (1 << 13)
        if self.quick_reply_shortcut is not None:
            flags |= (1 << 17)
        if self.effect is not None:
            flags |= (1 << 18)
        if self.allow_paid_stars is not None:
            flags |= (1 << 21)
        if self.suggested_post is not None:
            flags |= (1 << 22)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.media))
        buf.write(TLObject.serialize_bytes(self.message))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        buf.write(struct.pack('<q', self.random_id))
        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.schedule_date is not None:
            buf.write(struct.pack('<i', self.schedule_date))
        if self.schedule_repeat_period is not None:
            buf.write(struct.pack('<i', self.schedule_repeat_period))
        if self.send_as is not None:
            buf.write(bytes(self.send_as))
        if self.quick_reply_shortcut is not None:
            buf.write(bytes(self.quick_reply_shortcut))
        if self.effect is not None:
            buf.write(struct.pack('<q', self.effect))
        if self.allow_paid_stars is not None:
            buf.write(struct.pack('<q', self.allow_paid_stars))
        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['silent'] = bool(flags & (1 << 5))
        _args['background'] = bool(flags & (1 << 6))
        _args['clear_draft'] = bool(flags & (1 << 7))
        _args['noforwards'] = bool(flags & (1 << 14))
        _args['update_stickersets_order'] = bool(flags & (1 << 15))
        _args['invert_media'] = bool(flags & (1 << 16))
        _args['allow_paid_floodskip'] = bool(flags & (1 << 19))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _val_reply_to = reader.tgread_object()
            _args['reply_to'] = _val_reply_to
        else:
            _args['reply_to'] = None
        _val_media = reader.tgread_object()
        _args['media'] = _val_media
        _val_message = reader.tgread_string()
        _args['message'] = _val_message
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        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 << 10):
            _val_schedule_date = reader.read_int()
            _args['schedule_date'] = _val_schedule_date
        else:
            _args['schedule_date'] = None
        if flags & (1 << 24):
            _val_schedule_repeat_period = reader.read_int()
            _args['schedule_repeat_period'] = _val_schedule_repeat_period
        else:
            _args['schedule_repeat_period'] = None
        if flags & (1 << 13):
            _val_send_as = reader.tgread_object()
            _args['send_as'] = _val_send_as
        else:
            _args['send_as'] = None
        if flags & (1 << 17):
            _val_quick_reply_shortcut = reader.tgread_object()
            _args['quick_reply_shortcut'] = _val_quick_reply_shortcut
        else:
            _args['quick_reply_shortcut'] = None
        if flags & (1 << 18):
            _val_effect = reader.read_long()
            _args['effect'] = _val_effect
        else:
            _args['effect'] = None
        if flags & (1 << 21):
            _val_allow_paid_stars = reader.read_long()
            _args['allow_paid_stars'] = _val_allow_paid_stars
        else:
            _args['allow_paid_stars'] = None
        if flags & (1 << 22):
            _val_suggested_post = reader.tgread_object()
            _args['suggested_post'] = _val_suggested_post
        else:
            _args['suggested_post'] = None
        return cls(**_args)


class SendMessageRequest(TLRequest):
    """TL type: messages.sendMessage"""
    CONSTRUCTOR_ID = 0x545cd15a
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', message: str, no_webpage: Optional[bool] = None, silent: Optional[bool] = None, background: Optional[bool] = None, clear_draft: Optional[bool] = None, noforwards: Optional[bool] = None, update_stickersets_order: Optional[bool] = None, invert_media: Optional[bool] = None, allow_paid_floodskip: Optional[bool] = None, reply_to: Optional['TypeInputReplyTo'] = None, random_id: int = None, reply_markup: Optional['TypeReplyMarkup'] = None, entities: Optional[List['TypeMessageEntity']] = None, schedule_date: Optional[datetime] = None, schedule_repeat_period: Optional[int] = None, send_as: Optional['TypeInputPeer'] = None, quick_reply_shortcut: Optional['TypeInputQuickReplyShortcut'] = None, effect: Optional[int] = None, allow_paid_stars: Optional[int] = None, suggested_post: Optional['TypeSuggestedPost'] = None):
        self.peer = peer
        self.message = message
        self.no_webpage = no_webpage
        self.silent = silent
        self.background = background
        self.clear_draft = clear_draft
        self.noforwards = noforwards
        self.update_stickersets_order = update_stickersets_order
        self.invert_media = invert_media
        self.allow_paid_floodskip = allow_paid_floodskip
        self.reply_to = reply_to
        self.random_id = random_id
        self.reply_markup = reply_markup
        self.entities = entities
        self.schedule_date = schedule_date
        self.schedule_repeat_period = schedule_repeat_period
        self.send_as = send_as
        self.quick_reply_shortcut = quick_reply_shortcut
        self.effect = effect
        self.allow_paid_stars = allow_paid_stars
        self.suggested_post = suggested_post

    def to_dict(self):
        return {
            '_': 'SendMessageRequest',
            'peer': self.peer,
            'message': self.message,
            'no_webpage': self.no_webpage,
            'silent': self.silent,
            'background': self.background,
            'clear_draft': self.clear_draft,
            'noforwards': self.noforwards,
            'update_stickersets_order': self.update_stickersets_order,
            'invert_media': self.invert_media,
            'allow_paid_floodskip': self.allow_paid_floodskip,
            'reply_to': self.reply_to,
            'random_id': self.random_id,
            'reply_markup': self.reply_markup,
            'entities': self.entities,
            'schedule_date': self.schedule_date,
            'schedule_repeat_period': self.schedule_repeat_period,
            'send_as': self.send_as,
            'quick_reply_shortcut': self.quick_reply_shortcut,
            'effect': self.effect,
            'allow_paid_stars': self.allow_paid_stars,
            '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.silent:
            flags |= (1 << 5)
        if self.background:
            flags |= (1 << 6)
        if self.clear_draft:
            flags |= (1 << 7)
        if self.noforwards:
            flags |= (1 << 14)
        if self.update_stickersets_order:
            flags |= (1 << 15)
        if self.invert_media:
            flags |= (1 << 16)
        if self.allow_paid_floodskip:
            flags |= (1 << 19)
        if self.reply_to is not None:
            flags |= (1 << 0)
        if self.reply_markup is not None:
            flags |= (1 << 2)
        if self.entities is not None:
            flags |= (1 << 3)
        if self.schedule_date is not None:
            flags |= (1 << 10)
        if self.schedule_repeat_period is not None:
            flags |= (1 << 24)
        if self.send_as is not None:
            flags |= (1 << 13)
        if self.quick_reply_shortcut is not None:
            flags |= (1 << 17)
        if self.effect is not None:
            flags |= (1 << 18)
        if self.allow_paid_stars is not None:
            flags |= (1 << 21)
        if self.suggested_post is not None:
            flags |= (1 << 22)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.message))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        buf.write(struct.pack('<q', self.random_id))
        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.schedule_date is not None:
            buf.write(struct.pack('<i', self.schedule_date))
        if self.schedule_repeat_period is not None:
            buf.write(struct.pack('<i', self.schedule_repeat_period))
        if self.send_as is not None:
            buf.write(bytes(self.send_as))
        if self.quick_reply_shortcut is not None:
            buf.write(bytes(self.quick_reply_shortcut))
        if self.effect is not None:
            buf.write(struct.pack('<q', self.effect))
        if self.allow_paid_stars is not None:
            buf.write(struct.pack('<q', self.allow_paid_stars))
        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['silent'] = bool(flags & (1 << 5))
        _args['background'] = bool(flags & (1 << 6))
        _args['clear_draft'] = bool(flags & (1 << 7))
        _args['noforwards'] = bool(flags & (1 << 14))
        _args['update_stickersets_order'] = bool(flags & (1 << 15))
        _args['invert_media'] = bool(flags & (1 << 16))
        _args['allow_paid_floodskip'] = bool(flags & (1 << 19))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _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
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        if flags & (1 << 2):
            _val_reply_markup = reader.tgread_object()
            _args['reply_markup'] = _val_reply_markup
        else:
            _args['reply_markup'] = None
        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 << 10):
            _val_schedule_date = reader.read_int()
            _args['schedule_date'] = _val_schedule_date
        else:
            _args['schedule_date'] = None
        if flags & (1 << 24):
            _val_schedule_repeat_period = reader.read_int()
            _args['schedule_repeat_period'] = _val_schedule_repeat_period
        else:
            _args['schedule_repeat_period'] = None
        if flags & (1 << 13):
            _val_send_as = reader.tgread_object()
            _args['send_as'] = _val_send_as
        else:
            _args['send_as'] = None
        if flags & (1 << 17):
            _val_quick_reply_shortcut = reader.tgread_object()
            _args['quick_reply_shortcut'] = _val_quick_reply_shortcut
        else:
            _args['quick_reply_shortcut'] = None
        if flags & (1 << 18):
            _val_effect = reader.read_long()
            _args['effect'] = _val_effect
        else:
            _args['effect'] = None
        if flags & (1 << 21):
            _val_allow_paid_stars = reader.read_long()
            _args['allow_paid_stars'] = _val_allow_paid_stars
        else:
            _args['allow_paid_stars'] = None
        if flags & (1 << 22):
            _val_suggested_post = reader.tgread_object()
            _args['suggested_post'] = _val_suggested_post
        else:
            _args['suggested_post'] = None
        return cls(**_args)


class SendMultiMediaRequest(TLRequest):
    """TL type: messages.sendMultiMedia"""
    CONSTRUCTOR_ID = 0x1bf89d74
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', multi_media: List['TypeInputSingleMedia'], silent: Optional[bool] = None, background: Optional[bool] = None, clear_draft: Optional[bool] = None, noforwards: Optional[bool] = None, update_stickersets_order: Optional[bool] = None, invert_media: Optional[bool] = None, allow_paid_floodskip: Optional[bool] = None, reply_to: Optional['TypeInputReplyTo'] = None, schedule_date: Optional[datetime] = None, send_as: Optional['TypeInputPeer'] = None, quick_reply_shortcut: Optional['TypeInputQuickReplyShortcut'] = None, effect: Optional[int] = None, allow_paid_stars: Optional[int] = None):
        self.peer = peer
        self.multi_media = multi_media
        self.silent = silent
        self.background = background
        self.clear_draft = clear_draft
        self.noforwards = noforwards
        self.update_stickersets_order = update_stickersets_order
        self.invert_media = invert_media
        self.allow_paid_floodskip = allow_paid_floodskip
        self.reply_to = reply_to
        self.schedule_date = schedule_date
        self.send_as = send_as
        self.quick_reply_shortcut = quick_reply_shortcut
        self.effect = effect
        self.allow_paid_stars = allow_paid_stars

    def to_dict(self):
        return {
            '_': 'SendMultiMediaRequest',
            'peer': self.peer,
            'multi_media': self.multi_media,
            'silent': self.silent,
            'background': self.background,
            'clear_draft': self.clear_draft,
            'noforwards': self.noforwards,
            'update_stickersets_order': self.update_stickersets_order,
            'invert_media': self.invert_media,
            'allow_paid_floodskip': self.allow_paid_floodskip,
            'reply_to': self.reply_to,
            'schedule_date': self.schedule_date,
            'send_as': self.send_as,
            'quick_reply_shortcut': self.quick_reply_shortcut,
            'effect': self.effect,
            'allow_paid_stars': self.allow_paid_stars,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.silent:
            flags |= (1 << 5)
        if self.background:
            flags |= (1 << 6)
        if self.clear_draft:
            flags |= (1 << 7)
        if self.noforwards:
            flags |= (1 << 14)
        if self.update_stickersets_order:
            flags |= (1 << 15)
        if self.invert_media:
            flags |= (1 << 16)
        if self.allow_paid_floodskip:
            flags |= (1 << 19)
        if self.reply_to is not None:
            flags |= (1 << 0)
        if self.schedule_date is not None:
            flags |= (1 << 10)
        if self.send_as is not None:
            flags |= (1 << 13)
        if self.quick_reply_shortcut is not None:
            flags |= (1 << 17)
        if self.effect is not None:
            flags |= (1 << 18)
        if self.allow_paid_stars is not None:
            flags |= (1 << 21)
        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.multi_media)))
        for item in self.multi_media:
            buf.write(bytes(self.item))
        if self.reply_to is not None:
            buf.write(bytes(self.reply_to))
        if self.schedule_date is not None:
            buf.write(struct.pack('<i', self.schedule_date))
        if self.send_as is not None:
            buf.write(bytes(self.send_as))
        if self.quick_reply_shortcut is not None:
            buf.write(bytes(self.quick_reply_shortcut))
        if self.effect is not None:
            buf.write(struct.pack('<q', self.effect))
        if self.allow_paid_stars is not None:
            buf.write(struct.pack('<q', self.allow_paid_stars))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['silent'] = bool(flags & (1 << 5))
        _args['background'] = bool(flags & (1 << 6))
        _args['clear_draft'] = bool(flags & (1 << 7))
        _args['noforwards'] = bool(flags & (1 << 14))
        _args['update_stickersets_order'] = bool(flags & (1 << 15))
        _args['invert_media'] = bool(flags & (1 << 16))
        _args['allow_paid_floodskip'] = bool(flags & (1 << 19))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        if flags & (1 << 0):
            _val_reply_to = reader.tgread_object()
            _args['reply_to'] = _val_reply_to
        else:
            _args['reply_to'] = None
        reader.read_int(signed=False)  # skip vector id
        _count_multi_media = reader.read_int()
        _list_multi_media = []
        for _ in range(_count_multi_media):
            _item_multi_media = reader.tgread_object()
            _list_multi_media.append(_item_multi_media)
        _args['multi_media'] = _list_multi_media
        if flags & (1 << 10):
            _val_schedule_date = reader.read_int()
            _args['schedule_date'] = _val_schedule_date
        else:
            _args['schedule_date'] = None
        if flags & (1 << 13):
            _val_send_as = reader.tgread_object()
            _args['send_as'] = _val_send_as
        else:
            _args['send_as'] = None
        if flags & (1 << 17):
            _val_quick_reply_shortcut = reader.tgread_object()
            _args['quick_reply_shortcut'] = _val_quick_reply_shortcut
        else:
            _args['quick_reply_shortcut'] = None
        if flags & (1 << 18):
            _val_effect = reader.read_long()
            _args['effect'] = _val_effect
        else:
            _args['effect'] = None
        if flags & (1 << 21):
            _val_allow_paid_stars = reader.read_long()
            _args['allow_paid_stars'] = _val_allow_paid_stars
        else:
            _args['allow_paid_stars'] = None
        return cls(**_args)


class SendPaidReactionRequest(TLRequest):
    """TL type: messages.sendPaidReaction"""
    CONSTRUCTOR_ID = 0x58bbcb50
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, count: int, random_id: int = None, private: Optional['TypePaidReactionPrivacy'] = None):
        self.peer = peer
        self.msg_id = msg_id
        self.count = count
        self.random_id = random_id
        self.private = private

    def to_dict(self):
        return {
            '_': 'SendPaidReactionRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'count': self.count,
            'random_id': self.random_id,
            'private': self.private,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.private is not None:
            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('<i', self.count))
        buf.write(struct.pack('<q', self.random_id))
        if self.private is not None:
            buf.write(bytes(self.private))
        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
        _val_count = reader.read_int()
        _args['count'] = _val_count
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        if flags & (1 << 0):
            _val_private = reader.tgread_object()
            _args['private'] = _val_private
        else:
            _args['private'] = None
        return cls(**_args)


class SendQuickReplyMessagesRequest(TLRequest):
    """TL type: messages.sendQuickReplyMessages"""
    CONSTRUCTOR_ID = 0x6c750de1
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', shortcut_id: int, id: List[int], random_id: List[int] = None):
        self.peer = peer
        self.shortcut_id = shortcut_id
        self.id = id
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'SendQuickReplyMessagesRequest',
            'peer': self.peer,
            'shortcut_id': self.shortcut_id,
            '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(bytes(self.peer))
        buf.write(struct.pack('<i', self.shortcut_id))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            buf.write(struct.pack('<i', self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.random_id)))
        for item in self.random_id:
            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_shortcut_id = reader.read_int()
        _args['shortcut_id'] = _val_shortcut_id
        reader.read_int(signed=False)  # skip vector id
        _count_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        reader.read_int(signed=False)  # skip vector id
        _count_random_id = reader.read_int()
        _list_random_id = []
        for _ in range(_count_random_id):
            _item_random_id = reader.read_long()
            _list_random_id.append(_item_random_id)
        _args['random_id'] = _list_random_id
        return cls(**_args)


class SendReactionRequest(TLRequest):
    """TL type: messages.sendReaction"""
    CONSTRUCTOR_ID = 0xd30d78d4
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, big: Optional[bool] = None, add_to_recent: Optional[bool] = None, reaction: Optional[List['TypeReaction']] = None):
        self.peer = peer
        self.msg_id = msg_id
        self.big = big
        self.add_to_recent = add_to_recent
        self.reaction = reaction

    def to_dict(self):
        return {
            '_': 'SendReactionRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'big': self.big,
            'add_to_recent': self.add_to_recent,
            'reaction': self.reaction,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.big:
            flags |= (1 << 1)
        if self.add_to_recent:
            flags |= (1 << 2)
        if self.reaction is not None:
            flags |= (1 << 0)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.msg_id))
        if self.reaction is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.reaction)))
            for item in self.reaction:
                buf.write(bytes(self.item))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['big'] = bool(flags & (1 << 1))
        _args['add_to_recent'] = bool(flags & (1 << 2))
        _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):
            reader.read_int(signed=False)  # skip vector id
            _count_reaction = reader.read_int()
            _list_reaction = []
            for _ in range(_count_reaction):
                _item_reaction = reader.tgread_object()
                _list_reaction.append(_item_reaction)
            _args['reaction'] = _list_reaction
        else:
            _args['reaction'] = None
        return cls(**_args)


class SendScheduledMessagesRequest(TLRequest):
    """TL type: messages.sendScheduledMessages"""
    CONSTRUCTOR_ID = 0xbd38850a
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', id: List[int]):
        self.peer = peer
        self.id = id

    def to_dict(self):
        return {
            '_': 'SendScheduledMessagesRequest',
            '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', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.id)))
        for item in self.id:
            buf.write(struct.pack('<i', self.item))
        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_id = reader.read_int()
        _list_id = []
        for _ in range(_count_id):
            _item_id = reader.read_int()
            _list_id.append(_item_id)
        _args['id'] = _list_id
        return cls(**_args)


class SendScreenshotNotificationRequest(TLRequest):
    """TL type: messages.sendScreenshotNotification"""
    CONSTRUCTOR_ID = 0xa1405817
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', reply_to: 'TypeInputReplyTo', random_id: int = None):
        self.peer = peer
        self.reply_to = reply_to
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'SendScreenshotNotificationRequest',
            'peer': self.peer,
            'reply_to': self.reply_to,
            '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.peer))
        buf.write(bytes(self.reply_to))
        buf.write(struct.pack('<q', self.random_id))
        return buf.getvalue()

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


class SendVoteRequest(TLRequest):
    """TL type: messages.sendVote"""
    CONSTRUCTOR_ID = 0x10ea6184
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, options: List[bytes]):
        self.peer = peer
        self.msg_id = msg_id
        self.options = options

    def to_dict(self):
        return {
            '_': 'SendVoteRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'options': self.options,
        }

    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.options)))
        for item in self.options:
            buf.write(TLObject.serialize_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_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
        return cls(**_args)


class SendWebViewDataRequest(TLRequest):
    """TL type: messages.sendWebViewData"""
    CONSTRUCTOR_ID = 0xdc0242c8
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, bot: 'TypeInputUser', button_text: str, data: str, random_id: int = None):
        self.bot = bot
        self.button_text = button_text
        self.data = data
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'SendWebViewDataRequest',
            'bot': self.bot,
            'button_text': self.button_text,
            'data': self.data,
            '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.bot))
        buf.write(TLObject.serialize_bytes(self.button_text))
        buf.write(TLObject.serialize_bytes(self.data))
        buf.write(struct.pack('<q', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_button_text = reader.tgread_string()
        _args['button_text'] = _val_button_text
        _val_data = reader.tgread_string()
        _args['data'] = _val_data
        return cls(**_args)


class SendWebViewResultMessageRequest(TLRequest):
    """TL type: messages.sendWebViewResultMessage"""
    CONSTRUCTOR_ID = 0x0a4314f5
    SUBCLASS_OF_ID = 0x75e49312

    def __init__(self, bot_query_id: str, result: 'TypeInputBotInlineResult'):
        self.bot_query_id = bot_query_id
        self.result = result

    def to_dict(self):
        return {
            '_': 'SendWebViewResultMessageRequest',
            'bot_query_id': self.bot_query_id,
            'result': self.result,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot_query_id = reader.tgread_string()
        _args['bot_query_id'] = _val_bot_query_id
        _val_result = reader.tgread_object()
        _args['result'] = _val_result
        return cls(**_args)


class SetBotCallbackAnswerRequest(TLRequest):
    """TL type: messages.setBotCallbackAnswer"""
    CONSTRUCTOR_ID = 0xd58f130a
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, query_id: int, cache_time: int, alert: Optional[bool] = None, message: Optional[str] = None, url: Optional[str] = None):
        self.query_id = query_id
        self.cache_time = cache_time
        self.alert = alert
        self.message = message
        self.url = url

    def to_dict(self):
        return {
            '_': 'SetBotCallbackAnswerRequest',
            'query_id': self.query_id,
            'cache_time': self.cache_time,
            'alert': self.alert,
            'message': self.message,
            'url': self.url,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.alert:
            flags |= (1 << 1)
        if self.message is not None:
            flags |= (1 << 0)
        if self.url is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.query_id))
        buf.write(struct.pack('<i', self.cache_time))
        if self.message is not None:
            buf.write(TLObject.serialize_bytes(self.message))
        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)
        _args['alert'] = bool(flags & (1 << 1))
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        if flags & (1 << 0):
            _val_message = reader.tgread_string()
            _args['message'] = _val_message
        else:
            _args['message'] = None
        if flags & (1 << 2):
            _val_url = reader.tgread_string()
            _args['url'] = _val_url
        else:
            _args['url'] = None
        _val_cache_time = reader.read_int()
        _args['cache_time'] = _val_cache_time
        return cls(**_args)


class SetBotPrecheckoutResultsRequest(TLRequest):
    """TL type: messages.setBotPrecheckoutResults"""
    CONSTRUCTOR_ID = 0x09c2dd95
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, query_id: int, success: Optional[bool] = None, error: Optional[str] = None):
        self.query_id = query_id
        self.success = success
        self.error = error

    def to_dict(self):
        return {
            '_': 'SetBotPrecheckoutResultsRequest',
            'query_id': self.query_id,
            'success': self.success,
            'error': self.error,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['success'] = bool(flags & (1 << 1))
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        if flags & (1 << 0):
            _val_error = reader.tgread_string()
            _args['error'] = _val_error
        else:
            _args['error'] = None
        return cls(**_args)


class SetBotShippingResultsRequest(TLRequest):
    """TL type: messages.setBotShippingResults"""
    CONSTRUCTOR_ID = 0xe5f672fa
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, query_id: int, error: Optional[str] = None, shipping_options: Optional[List['TypeShippingOption']] = None):
        self.query_id = query_id
        self.error = error
        self.shipping_options = shipping_options

    def to_dict(self):
        return {
            '_': 'SetBotShippingResultsRequest',
            'query_id': self.query_id,
            'error': self.error,
            'shipping_options': self.shipping_options,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.error is not None:
            flags |= (1 << 0)
        if self.shipping_options is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.query_id))
        if self.error is not None:
            buf.write(TLObject.serialize_bytes(self.error))
        if self.shipping_options is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.shipping_options)))
            for item in self.shipping_options:
                buf.write(bytes(self.item))
        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
        if flags & (1 << 0):
            _val_error = reader.tgread_string()
            _args['error'] = _val_error
        else:
            _args['error'] = None
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_shipping_options = reader.read_int()
            _list_shipping_options = []
            for _ in range(_count_shipping_options):
                _item_shipping_options = reader.tgread_object()
                _list_shipping_options.append(_item_shipping_options)
            _args['shipping_options'] = _list_shipping_options
        else:
            _args['shipping_options'] = None
        return cls(**_args)


class SetChatAvailableReactionsRequest(TLRequest):
    """TL type: messages.setChatAvailableReactions"""
    CONSTRUCTOR_ID = 0x864b2581
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', available_reactions: 'TypeChatReactions', reactions_limit: Optional[int] = None, paid_enabled: Optional[bool] = None):
        self.peer = peer
        self.available_reactions = available_reactions
        self.reactions_limit = reactions_limit
        self.paid_enabled = paid_enabled

    def to_dict(self):
        return {
            '_': 'SetChatAvailableReactionsRequest',
            'peer': self.peer,
            'available_reactions': self.available_reactions,
            'reactions_limit': self.reactions_limit,
            'paid_enabled': self.paid_enabled,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.reactions_limit is not None:
            flags |= (1 << 0)
        if self.paid_enabled is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(bytes(self.available_reactions))
        if self.reactions_limit is not None:
            buf.write(struct.pack('<i', self.reactions_limit))
        if self.paid_enabled is not None:
            buf.write(struct.pack('<I', 0x997275b5 if self.paid_enabled else 0xbc799737))
        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_available_reactions = reader.tgread_object()
        _args['available_reactions'] = _val_available_reactions
        if flags & (1 << 0):
            _val_reactions_limit = reader.read_int()
            _args['reactions_limit'] = _val_reactions_limit
        else:
            _args['reactions_limit'] = None
        if flags & (1 << 1):
            _val_paid_enabled = reader.tgread_bool()
            _args['paid_enabled'] = _val_paid_enabled
        else:
            _args['paid_enabled'] = None
        return cls(**_args)


class SetChatThemeRequest(TLRequest):
    """TL type: messages.setChatTheme"""
    CONSTRUCTOR_ID = 0x081202c9
    SUBCLASS_OF_ID = 0x8af52aac

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

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

    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.theme))
        return buf.getvalue()

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


class SetChatWallPaperRequest(TLRequest):
    """TL type: messages.setChatWallPaper"""
    CONSTRUCTOR_ID = 0x8ffacae1
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', for_both: Optional[bool] = None, revert: Optional[bool] = None, wallpaper: Optional['TypeInputWallPaper'] = None, settings: Optional['TypeWallPaperSettings'] = None, id: Optional[int] = None):
        self.peer = peer
        self.for_both = for_both
        self.revert = revert
        self.wallpaper = wallpaper
        self.settings = settings
        self.id = id

    def to_dict(self):
        return {
            '_': 'SetChatWallPaperRequest',
            'peer': self.peer,
            'for_both': self.for_both,
            'revert': self.revert,
            'wallpaper': self.wallpaper,
            'settings': self.settings,
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.for_both:
            flags |= (1 << 3)
        if self.revert:
            flags |= (1 << 4)
        if self.wallpaper is not None:
            flags |= (1 << 0)
        if self.settings is not None:
            flags |= (1 << 2)
        if self.id is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        if self.wallpaper is not None:
            buf.write(bytes(self.wallpaper))
        if self.settings is not None:
            buf.write(bytes(self.settings))
        if self.id is not None:
            buf.write(struct.pack('<i', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['for_both'] = bool(flags & (1 << 3))
        _args['revert'] = bool(flags & (1 << 4))
        _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
        if flags & (1 << 2):
            _val_settings = reader.tgread_object()
            _args['settings'] = _val_settings
        else:
            _args['settings'] = None
        if flags & (1 << 1):
            _val_id = reader.read_int()
            _args['id'] = _val_id
        else:
            _args['id'] = None
        return cls(**_args)


class SetDefaultHistoryTtlRequest(TLRequest):
    """TL type: messages.setDefaultHistoryTTL"""
    CONSTRUCTOR_ID = 0x9eb51445
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'SetDefaultHistoryTtlRequest',
            '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 SetDefaultReactionRequest(TLRequest):
    """TL type: messages.setDefaultReaction"""
    CONSTRUCTOR_ID = 0x4f47a016
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, reaction: 'TypeReaction'):
        self.reaction = reaction

    def to_dict(self):
        return {
            '_': 'SetDefaultReactionRequest',
            'reaction': self.reaction,
        }

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

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


class SetEncryptedTypingRequest(TLRequest):
    """TL type: messages.setEncryptedTyping"""
    CONSTRUCTOR_ID = 0x791451ed
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputEncryptedChat', typing: bool):
        self.peer = peer
        self.typing = typing

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

    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', 0x997275b5 if self.typing else 0xbc799737))
        return buf.getvalue()

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


class SetGameScoreRequest(TLRequest):
    """TL type: messages.setGameScore"""
    CONSTRUCTOR_ID = 0x8ef8ecc0
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', id: int, user_id: 'TypeInputUser', score: int, edit_message: Optional[bool] = None, force: Optional[bool] = None):
        self.peer = peer
        self.id = id
        self.user_id = user_id
        self.score = score
        self.edit_message = edit_message
        self.force = force

    def to_dict(self):
        return {
            '_': 'SetGameScoreRequest',
            'peer': self.peer,
            'id': self.id,
            'user_id': self.user_id,
            'score': self.score,
            'edit_message': self.edit_message,
            'force': self.force,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.edit_message:
            flags |= (1 << 0)
        if self.force:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.id))
        buf.write(bytes(self.user_id))
        buf.write(struct.pack('<i', self.score))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['edit_message'] = bool(flags & (1 << 0))
        _args['force'] = bool(flags & (1 << 1))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_id = reader.read_int()
        _args['id'] = _val_id
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        _val_score = reader.read_int()
        _args['score'] = _val_score
        return cls(**_args)


class SetHistoryTtlRequest(TLRequest):
    """TL type: messages.setHistoryTTL"""
    CONSTRUCTOR_ID = 0xb80e5fe4
    SUBCLASS_OF_ID = 0x8af52aac

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

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

    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.period))
        return buf.getvalue()

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


class SetInlineBotResultsRequest(TLRequest):
    """TL type: messages.setInlineBotResults"""
    CONSTRUCTOR_ID = 0xbb12a419
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, query_id: int, results: List['TypeInputBotInlineResult'], cache_time: int, gallery: Optional[bool] = None, private: Optional[bool] = None, next_offset: Optional[str] = None, switch_pm: Optional['TypeInlineBotSwitchPM'] = None, switch_webview: Optional['TypeInlineBotWebView'] = None):
        self.query_id = query_id
        self.results = results
        self.cache_time = cache_time
        self.gallery = gallery
        self.private = private
        self.next_offset = next_offset
        self.switch_pm = switch_pm
        self.switch_webview = switch_webview

    def to_dict(self):
        return {
            '_': 'SetInlineBotResultsRequest',
            'query_id': self.query_id,
            'results': self.results,
            'cache_time': self.cache_time,
            'gallery': self.gallery,
            'private': self.private,
            'next_offset': self.next_offset,
            'switch_pm': self.switch_pm,
            'switch_webview': self.switch_webview,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.gallery:
            flags |= (1 << 0)
        if self.private:
            flags |= (1 << 1)
        if self.next_offset is not None:
            flags |= (1 << 2)
        if self.switch_pm is not None:
            flags |= (1 << 3)
        if self.switch_webview is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(struct.pack('<q', self.query_id))
        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))
        buf.write(struct.pack('<i', self.cache_time))
        if self.next_offset is not None:
            buf.write(TLObject.serialize_bytes(self.next_offset))
        if self.switch_pm is not None:
            buf.write(bytes(self.switch_pm))
        if self.switch_webview is not None:
            buf.write(bytes(self.switch_webview))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['gallery'] = bool(flags & (1 << 0))
        _args['private'] = bool(flags & (1 << 1))
        _val_query_id = reader.read_long()
        _args['query_id'] = _val_query_id
        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
        _val_cache_time = reader.read_int()
        _args['cache_time'] = _val_cache_time
        if flags & (1 << 2):
            _val_next_offset = reader.tgread_string()
            _args['next_offset'] = _val_next_offset
        else:
            _args['next_offset'] = None
        if flags & (1 << 3):
            _val_switch_pm = reader.tgread_object()
            _args['switch_pm'] = _val_switch_pm
        else:
            _args['switch_pm'] = None
        if flags & (1 << 4):
            _val_switch_webview = reader.tgread_object()
            _args['switch_webview'] = _val_switch_webview
        else:
            _args['switch_webview'] = None
        return cls(**_args)


class SetInlineGameScoreRequest(TLRequest):
    """TL type: messages.setInlineGameScore"""
    CONSTRUCTOR_ID = 0x15ad9f64
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, id: 'TypeInputBotInlineMessageID', user_id: 'TypeInputUser', score: int, edit_message: Optional[bool] = None, force: Optional[bool] = None):
        self.id = id
        self.user_id = user_id
        self.score = score
        self.edit_message = edit_message
        self.force = force

    def to_dict(self):
        return {
            '_': 'SetInlineGameScoreRequest',
            'id': self.id,
            'user_id': self.user_id,
            'score': self.score,
            'edit_message': self.edit_message,
            'force': self.force,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.edit_message:
            flags |= (1 << 0)
        if self.force:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.id))
        buf.write(bytes(self.user_id))
        buf.write(struct.pack('<i', self.score))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['edit_message'] = bool(flags & (1 << 0))
        _args['force'] = bool(flags & (1 << 1))
        _val_id = reader.tgread_object()
        _args['id'] = _val_id
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        _val_score = reader.read_int()
        _args['score'] = _val_score
        return cls(**_args)


class SetTypingRequest(TLRequest):
    """TL type: messages.setTyping"""
    CONSTRUCTOR_ID = 0x58943ee2
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPeer', action: 'TypeSendMessageAction', top_msg_id: Optional[int] = None):
        self.peer = peer
        self.action = action
        self.top_msg_id = top_msg_id

    def to_dict(self):
        return {
            '_': 'SetTypingRequest',
            'peer': self.peer,
            '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(bytes(self.peer))
        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_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
        _val_action = reader.tgread_object()
        _args['action'] = _val_action
        return cls(**_args)


class SetWebViewResultRequest(TLRequest):
    """TL type: messages.setWebViewResult"""
    CONSTRUCTOR_ID = 0xe41cd11d
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'SetWebViewResultRequest',
            '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 StartBotRequest(TLRequest):
    """TL type: messages.startBot"""
    CONSTRUCTOR_ID = 0xe6df7378
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, bot: 'TypeInputUser', peer: 'TypeInputPeer', start_param: str, random_id: int = None):
        self.bot = bot
        self.peer = peer
        self.start_param = start_param
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'StartBotRequest',
            'bot': self.bot,
            'peer': self.peer,
            'start_param': self.start_param,
            '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.bot))
        buf.write(bytes(self.peer))
        buf.write(TLObject.serialize_bytes(self.start_param))
        buf.write(struct.pack('<q', self.random_id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_random_id = reader.read_long()
        _args['random_id'] = _val_random_id
        _val_start_param = reader.tgread_string()
        _args['start_param'] = _val_start_param
        return cls(**_args)


class StartHistoryImportRequest(TLRequest):
    """TL type: messages.startHistoryImport"""
    CONSTRUCTOR_ID = 0xb43df344
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'StartHistoryImportRequest',
            'peer': self.peer,
            'import_id': self.import_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.import_id))
        return buf.getvalue()

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


class SummarizeTextRequest(TLRequest):
    """TL type: messages.summarizeText"""
    CONSTRUCTOR_ID = 0x9d4104e2
    SUBCLASS_OF_ID = 0x95ca4b05

    def __init__(self, peer: 'TypeInputPeer', id: int, to_lang: Optional[str] = None):
        self.peer = peer
        self.id = id
        self.to_lang = to_lang

    def to_dict(self):
        return {
            '_': 'SummarizeTextRequest',
            'peer': self.peer,
            'id': self.id,
            'to_lang': self.to_lang,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.to_lang 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.to_lang is not None:
            buf.write(TLObject.serialize_bytes(self.to_lang))
        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_to_lang = reader.tgread_string()
            _args['to_lang'] = _val_to_lang
        else:
            _args['to_lang'] = None
        return cls(**_args)


class ToggleBotInAttachMenuRequest(TLRequest):
    """TL type: messages.toggleBotInAttachMenu"""
    CONSTRUCTOR_ID = 0x69f59d69
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, bot: 'TypeInputUser', enabled: bool, write_allowed: Optional[bool] = None):
        self.bot = bot
        self.enabled = enabled
        self.write_allowed = write_allowed

    def to_dict(self):
        return {
            '_': 'ToggleBotInAttachMenuRequest',
            'bot': self.bot,
            'enabled': self.enabled,
            'write_allowed': self.write_allowed,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['write_allowed'] = bool(flags & (1 << 0))
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        _val_enabled = reader.tgread_bool()
        _args['enabled'] = _val_enabled
        return cls(**_args)


class ToggleDialogFilterTagsRequest(TLRequest):
    """TL type: messages.toggleDialogFilterTags"""
    CONSTRUCTOR_ID = 0xfd2dda49
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'ToggleDialogFilterTagsRequest',
            'enabled': self.enabled,
        }

    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.enabled else 0xbc799737))
        return buf.getvalue()

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


class ToggleDialogPinRequest(TLRequest):
    """TL type: messages.toggleDialogPin"""
    CONSTRUCTOR_ID = 0xa731e257
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputDialogPeer', pinned: Optional[bool] = None):
        self.peer = peer
        self.pinned = pinned

    def to_dict(self):
        return {
            '_': 'ToggleDialogPinRequest',
            '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 ToggleNoForwardsRequest(TLRequest):
    """TL type: messages.toggleNoForwards"""
    CONSTRUCTOR_ID = 0xb11eafa2
    SUBCLASS_OF_ID = 0x8af52aac

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

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

    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', 0x997275b5 if self.enabled else 0xbc799737))
        return buf.getvalue()

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


class TogglePaidReactionPrivacyRequest(TLRequest):
    """TL type: messages.togglePaidReactionPrivacy"""
    CONSTRUCTOR_ID = 0x435885b5
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, private: 'TypePaidReactionPrivacy'):
        self.peer = peer
        self.msg_id = msg_id
        self.private = private

    def to_dict(self):
        return {
            '_': 'TogglePaidReactionPrivacyRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'private': self.private,
        }

    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(bytes(self.private))
        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_private = reader.tgread_object()
        _args['private'] = _val_private
        return cls(**_args)


class TogglePeerTranslationsRequest(TLRequest):
    """TL type: messages.togglePeerTranslations"""
    CONSTRUCTOR_ID = 0xe47cb579
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPeer', disabled: Optional[bool] = None):
        self.peer = peer
        self.disabled = disabled

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

    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)
        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['disabled'] = bool(flags & (1 << 0))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        return cls(**_args)


class ToggleSavedDialogPinRequest(TLRequest):
    """TL type: messages.toggleSavedDialogPin"""
    CONSTRUCTOR_ID = 0xac81bbde
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputDialogPeer', pinned: Optional[bool] = None):
        self.peer = peer
        self.pinned = pinned

    def to_dict(self):
        return {
            '_': 'ToggleSavedDialogPinRequest',
            '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 ToggleStickerSetsRequest(TLRequest):
    """TL type: messages.toggleStickerSets"""
    CONSTRUCTOR_ID = 0xb5052fea
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, stickersets: List['TypeInputStickerSet'], uninstall: Optional[bool] = None, archive: Optional[bool] = None, unarchive: Optional[bool] = None):
        self.stickersets = stickersets
        self.uninstall = uninstall
        self.archive = archive
        self.unarchive = unarchive

    def to_dict(self):
        return {
            '_': 'ToggleStickerSetsRequest',
            'stickersets': self.stickersets,
            'uninstall': self.uninstall,
            'archive': self.archive,
            'unarchive': self.unarchive,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['uninstall'] = bool(flags & (1 << 0))
        _args['archive'] = bool(flags & (1 << 1))
        _args['unarchive'] = bool(flags & (1 << 2))
        reader.read_int(signed=False)  # skip vector id
        _count_stickersets = reader.read_int()
        _list_stickersets = []
        for _ in range(_count_stickersets):
            _item_stickersets = reader.tgread_object()
            _list_stickersets.append(_item_stickersets)
        _args['stickersets'] = _list_stickersets
        return cls(**_args)


class ToggleSuggestedPostApprovalRequest(TLRequest):
    """TL type: messages.toggleSuggestedPostApproval"""
    CONSTRUCTOR_ID = 0x8107455c
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, reject: Optional[bool] = None, schedule_date: Optional[datetime] = None, reject_comment: Optional[str] = None):
        self.peer = peer
        self.msg_id = msg_id
        self.reject = reject
        self.schedule_date = schedule_date
        self.reject_comment = reject_comment

    def to_dict(self):
        return {
            '_': 'ToggleSuggestedPostApprovalRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            'reject': self.reject,
            'schedule_date': self.schedule_date,
            'reject_comment': self.reject_comment,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['reject'] = bool(flags & (1 << 1))
        _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_schedule_date = reader.read_int()
            _args['schedule_date'] = _val_schedule_date
        else:
            _args['schedule_date'] = None
        if flags & (1 << 2):
            _val_reject_comment = reader.tgread_string()
            _args['reject_comment'] = _val_reject_comment
        else:
            _args['reject_comment'] = None
        return cls(**_args)


class ToggleTodoCompletedRequest(TLRequest):
    """TL type: messages.toggleTodoCompleted"""
    CONSTRUCTOR_ID = 0xd3e03124
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', msg_id: int, completed: List[int], incompleted: List[int]):
        self.peer = peer
        self.msg_id = msg_id
        self.completed = completed
        self.incompleted = incompleted

    def to_dict(self):
        return {
            '_': 'ToggleTodoCompletedRequest',
            'peer': self.peer,
            'msg_id': self.msg_id,
            '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(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.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 = {}
        _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_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 TranscribeAudioRequest(TLRequest):
    """TL type: messages.transcribeAudio"""
    CONSTRUCTOR_ID = 0x269e9a49
    SUBCLASS_OF_ID = 0x21b24936

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

    def to_dict(self):
        return {
            '_': 'TranscribeAudioRequest',
            '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 TranslateTextRequest(TLRequest):
    """TL type: messages.translateText"""
    CONSTRUCTOR_ID = 0x63183030
    SUBCLASS_OF_ID = 0x024243e8

    def __init__(self, to_lang: str, peer: Optional['TypeInputPeer'] = None, id: Optional[List[int]] = None, text: Optional[List['TypeTextWithEntities']] = None):
        self.to_lang = to_lang
        self.peer = peer
        self.id = id
        self.text = text

    def to_dict(self):
        return {
            '_': 'TranslateTextRequest',
            'to_lang': self.to_lang,
            'peer': self.peer,
            'id': self.id,
            'text': self.text,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.id is not None:
            flags |= (1 << 0)
        if self.text is not None:
            flags |= (1 << 1)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.to_lang))
        if self.peer is not None:
            buf.write(bytes(self.peer))
        if self.id is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.id)))
            for item in self.id:
                buf.write(struct.pack('<i', self.item))
        if self.text is not None:
            buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
            buf.write(struct.pack('<i', len(self.text)))
            for item in self.text:
                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):
            _val_peer = reader.tgread_object()
            _args['peer'] = _val_peer
        else:
            _args['peer'] = None
        if flags & (1 << 0):
            reader.read_int(signed=False)  # skip vector id
            _count_id = reader.read_int()
            _list_id = []
            for _ in range(_count_id):
                _item_id = reader.read_int()
                _list_id.append(_item_id)
            _args['id'] = _list_id
        else:
            _args['id'] = None
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_text = reader.read_int()
            _list_text = []
            for _ in range(_count_text):
                _item_text = reader.tgread_object()
                _list_text.append(_item_text)
            _args['text'] = _list_text
        else:
            _args['text'] = None
        _val_to_lang = reader.tgread_string()
        _args['to_lang'] = _val_to_lang
        return cls(**_args)


class UninstallStickerSetRequest(TLRequest):
    """TL type: messages.uninstallStickerSet"""
    CONSTRUCTOR_ID = 0xf96e55de
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, stickerset: 'TypeInputStickerSet'):
        self.stickerset = stickerset

    def to_dict(self):
        return {
            '_': 'UninstallStickerSetRequest',
            '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 UnpinAllMessagesRequest(TLRequest):
    """TL type: messages.unpinAllMessages"""
    CONSTRUCTOR_ID = 0x062dd747
    SUBCLASS_OF_ID = 0x2c49c116

    def __init__(self, peer: 'TypeInputPeer', top_msg_id: Optional[int] = None, saved_peer_id: Optional['TypeInputPeer'] = None):
        self.peer = peer
        self.top_msg_id = top_msg_id
        self.saved_peer_id = saved_peer_id

    def to_dict(self):
        return {
            '_': 'UnpinAllMessagesRequest',
            'peer': self.peer,
            '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))
        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
        return cls(**_args)


class UpdateDialogFilterRequest(TLRequest):
    """TL type: messages.updateDialogFilter"""
    CONSTRUCTOR_ID = 0x1ad4a04a
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, id: int, filter: Optional['TypeDialogFilter'] = None):
        self.id = id
        self.filter = filter

    def to_dict(self):
        return {
            '_': 'UpdateDialogFilterRequest',
            '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 UpdateDialogFiltersOrderRequest(TLRequest):
    """TL type: messages.updateDialogFiltersOrder"""
    CONSTRUCTOR_ID = 0xc563c1e4
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, order: List[int]):
        self.order = order

    def to_dict(self):
        return {
            '_': 'UpdateDialogFiltersOrderRequest',
            '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 UpdatePinnedForumTopicRequest(TLRequest):
    """TL type: messages.updatePinnedForumTopic"""
    CONSTRUCTOR_ID = 0x175df251
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', topic_id: int, pinned: bool):
        self.peer = peer
        self.topic_id = topic_id
        self.pinned = pinned

    def to_dict(self):
        return {
            '_': 'UpdatePinnedForumTopicRequest',
            '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))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.topic_id))
        buf.write(struct.pack('<I', 0x997275b5 if self.pinned else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_topic_id = reader.read_int()
        _args['topic_id'] = _val_topic_id
        _val_pinned = reader.tgread_bool()
        _args['pinned'] = _val_pinned
        return cls(**_args)


class UpdatePinnedMessageRequest(TLRequest):
    """TL type: messages.updatePinnedMessage"""
    CONSTRUCTOR_ID = 0xd2aaf7ec
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, peer: 'TypeInputPeer', id: int, silent: Optional[bool] = None, unpin: Optional[bool] = None, pm_oneside: Optional[bool] = None):
        self.peer = peer
        self.id = id
        self.silent = silent
        self.unpin = unpin
        self.pm_oneside = pm_oneside

    def to_dict(self):
        return {
            '_': 'UpdatePinnedMessageRequest',
            'peer': self.peer,
            'id': self.id,
            'silent': self.silent,
            'unpin': self.unpin,
            'pm_oneside': self.pm_oneside,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        flags = 0
        if self.silent:
            flags |= (1 << 0)
        if self.unpin:
            flags |= (1 << 1)
        if self.pm_oneside:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        buf.write(bytes(self.peer))
        buf.write(struct.pack('<i', self.id))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['silent'] = bool(flags & (1 << 0))
        _args['unpin'] = bool(flags & (1 << 1))
        _args['pm_oneside'] = bool(flags & (1 << 2))
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_id = reader.read_int()
        _args['id'] = _val_id
        return cls(**_args)


class UpdateSavedReactionTagRequest(TLRequest):
    """TL type: messages.updateSavedReactionTag"""
    CONSTRUCTOR_ID = 0x60297dec
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, reaction: 'TypeReaction', title: Optional[str] = None):
        self.reaction = reaction
        self.title = title

    def to_dict(self):
        return {
            '_': 'UpdateSavedReactionTagRequest',
            'reaction': self.reaction,
            '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))
        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
        return cls(**_args)


class UploadEncryptedFileRequest(TLRequest):
    """TL type: messages.uploadEncryptedFile"""
    CONSTRUCTOR_ID = 0x5057c497
    SUBCLASS_OF_ID = 0x842a67c0

    def __init__(self, peer: 'TypeInputEncryptedChat', file: 'TypeInputEncryptedFile'):
        self.peer = peer
        self.file = file

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

    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.file))
        return buf.getvalue()

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


class UploadImportedMediaRequest(TLRequest):
    """TL type: messages.uploadImportedMedia"""
    CONSTRUCTOR_ID = 0x2a862092
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, peer: 'TypeInputPeer', import_id: int, file_name: str, media: 'TypeInputMedia'):
        self.peer = peer
        self.import_id = import_id
        self.file_name = file_name
        self.media = media

    def to_dict(self):
        return {
            '_': 'UploadImportedMediaRequest',
            'peer': self.peer,
            'import_id': self.import_id,
            'file_name': self.file_name,
            'media': self.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('<q', self.import_id))
        buf.write(TLObject.serialize_bytes(self.file_name))
        buf.write(bytes(self.media))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_import_id = reader.read_long()
        _args['import_id'] = _val_import_id
        _val_file_name = reader.tgread_string()
        _args['file_name'] = _val_file_name
        _val_media = reader.tgread_object()
        _args['media'] = _val_media
        return cls(**_args)


class UploadMediaRequest(TLRequest):
    """TL type: messages.uploadMedia"""
    CONSTRUCTOR_ID = 0x14967978
    SUBCLASS_OF_ID = 0x476cbe32

    def __init__(self, peer: 'TypeInputPeer', media: 'TypeInputMedia', business_connection_id: Optional[str] = None):
        self.peer = peer
        self.media = media
        self.business_connection_id = business_connection_id

    def to_dict(self):
        return {
            '_': 'UploadMediaRequest',
            'peer': self.peer,
            'media': self.media,
            'business_connection_id': self.business_connection_id,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 0):
            _val_business_connection_id = reader.tgread_string()
            _args['business_connection_id'] = _val_business_connection_id
        else:
            _args['business_connection_id'] = None
        _val_peer = reader.tgread_object()
        _args['peer'] = _val_peer
        _val_media = reader.tgread_object()
        _args['media'] = _val_media
        return cls(**_args)


class ViewSponsoredMessageRequest(TLRequest):
    """TL type: messages.viewSponsoredMessage"""
    CONSTRUCTOR_ID = 0x269e3643
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, random_id: bytes = None):
        self.random_id = random_id

    def to_dict(self):
        return {
            '_': 'ViewSponsoredMessageRequest',
            'random_id': self.random_id,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_random_id = reader.tgread_bytes()
        _args['random_id'] = _val_random_id
        return cls(**_args)

