"""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 AddPreviewMediaRequest(TLRequest):
    """TL type: bots.addPreviewMedia"""
    CONSTRUCTOR_ID = 0x17aeb75a
    SUBCLASS_OF_ID = 0x562abc2d

    def __init__(self, bot: 'TypeInputUser', lang_code: str, media: 'TypeInputMedia'):
        self.bot = bot
        self.lang_code = lang_code
        self.media = media

    def to_dict(self):
        return {
            '_': 'AddPreviewMediaRequest',
            'bot': self.bot,
            'lang_code': self.lang_code,
            'media': self.media,
        }

    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.lang_code))
        buf.write(bytes(self.media))
        return buf.getvalue()

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


class AllowSendMessageRequest(TLRequest):
    """TL type: bots.allowSendMessage"""
    CONSTRUCTOR_ID = 0xf132e3ef
    SUBCLASS_OF_ID = 0x8af52aac

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

    def to_dict(self):
        return {
            '_': 'AllowSendMessageRequest',
            '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 AnswerWebhookJsonqueryRequest(TLRequest):
    """TL type: bots.answerWebhookJSONQuery"""
    CONSTRUCTOR_ID = 0xe6213f4d
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, query_id: int, data: 'TypeDataJSON'):
        self.query_id = query_id
        self.data = data

    def to_dict(self):
        return {
            '_': 'AnswerWebhookJsonqueryRequest',
            'query_id': self.query_id,
            'data': self.data,
        }

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

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


class CanSendMessageRequest(TLRequest):
    """TL type: bots.canSendMessage"""
    CONSTRUCTOR_ID = 0x1359f4e6
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'CanSendMessageRequest',
            '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 CheckDownloadFileParamsRequest(TLRequest):
    """TL type: bots.checkDownloadFileParams"""
    CONSTRUCTOR_ID = 0x50077589
    SUBCLASS_OF_ID = 0xf5b399ac

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

    def to_dict(self):
        return {
            '_': 'CheckDownloadFileParamsRequest',
            'bot': self.bot,
            'file_name': self.file_name,
            'url': self.url,
        }

    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.file_name))
        buf.write(TLObject.serialize_bytes(self.url))
        return buf.getvalue()

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


class DeletePreviewMediaRequest(TLRequest):
    """TL type: bots.deletePreviewMedia"""
    CONSTRUCTOR_ID = 0x2d0135b3
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, bot: 'TypeInputUser', lang_code: str, media: List['TypeInputMedia']):
        self.bot = bot
        self.lang_code = lang_code
        self.media = media

    def to_dict(self):
        return {
            '_': 'DeletePreviewMediaRequest',
            'bot': self.bot,
            'lang_code': self.lang_code,
            'media': self.media,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        reader.read_int(signed=False)  # skip vector id
        _count_media = reader.read_int()
        _list_media = []
        for _ in range(_count_media):
            _item_media = reader.tgread_object()
            _list_media.append(_item_media)
        _args['media'] = _list_media
        return cls(**_args)


class EditPreviewMediaRequest(TLRequest):
    """TL type: bots.editPreviewMedia"""
    CONSTRUCTOR_ID = 0x8525606f
    SUBCLASS_OF_ID = 0x562abc2d

    def __init__(self, bot: 'TypeInputUser', lang_code: str, media: 'TypeInputMedia', new_media: 'TypeInputMedia'):
        self.bot = bot
        self.lang_code = lang_code
        self.media = media
        self.new_media = new_media

    def to_dict(self):
        return {
            '_': 'EditPreviewMediaRequest',
            'bot': self.bot,
            'lang_code': self.lang_code,
            'media': self.media,
            'new_media': self.new_media,
        }

    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.lang_code))
        buf.write(bytes(self.media))
        buf.write(bytes(self.new_media))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        _val_media = reader.tgread_object()
        _args['media'] = _val_media
        _val_new_media = reader.tgread_object()
        _args['new_media'] = _val_new_media
        return cls(**_args)


class GetAdminedBotsRequest(TLRequest):
    """TL type: bots.getAdminedBots"""
    CONSTRUCTOR_ID = 0xb0711d83
    SUBCLASS_OF_ID = 0x0406da4d

    def __init__(self):
        pass

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

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

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


class GetBotCommandsRequest(TLRequest):
    """TL type: bots.getBotCommands"""
    CONSTRUCTOR_ID = 0xe34c0dd6
    SUBCLASS_OF_ID = 0xfae91529

    def __init__(self, scope: 'TypeBotCommandScope', lang_code: str):
        self.scope = scope
        self.lang_code = lang_code

    def to_dict(self):
        return {
            '_': 'GetBotCommandsRequest',
            'scope': self.scope,
            'lang_code': self.lang_code,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_scope = reader.tgread_object()
        _args['scope'] = _val_scope
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        return cls(**_args)


class GetBotInfoRequest(TLRequest):
    """TL type: bots.getBotInfo"""
    CONSTRUCTOR_ID = 0xdcd914fd
    SUBCLASS_OF_ID = 0xca7b2235

    def __init__(self, lang_code: str, bot: Optional['TypeInputUser'] = None):
        self.lang_code = lang_code
        self.bot = bot

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

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

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


class GetBotMenuButtonRequest(TLRequest):
    """TL type: bots.getBotMenuButton"""
    CONSTRUCTOR_ID = 0x9c60eb28
    SUBCLASS_OF_ID = 0x4c71bd3c

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

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

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


class GetBotRecommendationsRequest(TLRequest):
    """TL type: bots.getBotRecommendations"""
    CONSTRUCTOR_ID = 0xa1b70815
    SUBCLASS_OF_ID = 0xf24bf0c0

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

    def to_dict(self):
        return {
            '_': 'GetBotRecommendationsRequest',
            '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 GetPopularAppBotsRequest(TLRequest):
    """TL type: bots.getPopularAppBots"""
    CONSTRUCTOR_ID = 0xc2510192
    SUBCLASS_OF_ID = 0x7b64be7d

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

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

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


class GetPreviewInfoRequest(TLRequest):
    """TL type: bots.getPreviewInfo"""
    CONSTRUCTOR_ID = 0x423ab3ad
    SUBCLASS_OF_ID = 0xf0c27f35

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

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

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

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


class GetPreviewMediasRequest(TLRequest):
    """TL type: bots.getPreviewMedias"""
    CONSTRUCTOR_ID = 0xa2a5594d
    SUBCLASS_OF_ID = 0xf9862a78

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

    def to_dict(self):
        return {
            '_': 'GetPreviewMediasRequest',
            '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 InvokeWebViewCustomMethodRequest(TLRequest):
    """TL type: bots.invokeWebViewCustomMethod"""
    CONSTRUCTOR_ID = 0x087fc5e7
    SUBCLASS_OF_ID = 0xad0352e8

    def __init__(self, bot: 'TypeInputUser', custom_method: str, params: 'TypeDataJSON'):
        self.bot = bot
        self.custom_method = custom_method
        self.params = params

    def to_dict(self):
        return {
            '_': 'InvokeWebViewCustomMethodRequest',
            'bot': self.bot,
            'custom_method': self.custom_method,
            'params': self.params,
        }

    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.custom_method))
        buf.write(bytes(self.params))
        return buf.getvalue()

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


class ReorderPreviewMediasRequest(TLRequest):
    """TL type: bots.reorderPreviewMedias"""
    CONSTRUCTOR_ID = 0xb627f3aa
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, bot: 'TypeInputUser', lang_code: str, order: List['TypeInputMedia']):
        self.bot = bot
        self.lang_code = lang_code
        self.order = order

    def to_dict(self):
        return {
            '_': 'ReorderPreviewMediasRequest',
            'bot': self.bot,
            'lang_code': self.lang_code,
            'order': self.order,
        }

    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.lang_code))
        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 = {}
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        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 ReorderUsernamesRequest(TLRequest):
    """TL type: bots.reorderUsernames"""
    CONSTRUCTOR_ID = 0x9709b1c2
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, bot: 'TypeInputUser', order: List[str]):
        self.bot = bot
        self.order = order

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

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        reader.read_int(signed=False)  # skip vector id
        _count_order = reader.read_int()
        _list_order = []
        for _ in range(_count_order):
            _item_order = reader.tgread_string()
            _list_order.append(_item_order)
        _args['order'] = _list_order
        return cls(**_args)


class ResetBotCommandsRequest(TLRequest):
    """TL type: bots.resetBotCommands"""
    CONSTRUCTOR_ID = 0x3d8de0f9
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, scope: 'TypeBotCommandScope', lang_code: str):
        self.scope = scope
        self.lang_code = lang_code

    def to_dict(self):
        return {
            '_': 'ResetBotCommandsRequest',
            'scope': self.scope,
            'lang_code': self.lang_code,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_scope = reader.tgread_object()
        _args['scope'] = _val_scope
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        return cls(**_args)


class SendCustomRequestRequest(TLRequest):
    """TL type: bots.sendCustomRequest"""
    CONSTRUCTOR_ID = 0xaa2769ed
    SUBCLASS_OF_ID = 0xad0352e8

    def __init__(self, custom_method: str, params: 'TypeDataJSON'):
        self.custom_method = custom_method
        self.params = params

    def to_dict(self):
        return {
            '_': 'SendCustomRequestRequest',
            'custom_method': self.custom_method,
            'params': self.params,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_custom_method = reader.tgread_string()
        _args['custom_method'] = _val_custom_method
        _val_params = reader.tgread_object()
        _args['params'] = _val_params
        return cls(**_args)


class SetBotBroadcastDefaultAdminRightsRequest(TLRequest):
    """TL type: bots.setBotBroadcastDefaultAdminRights"""
    CONSTRUCTOR_ID = 0x788464e1
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, admin_rights: 'TypeChatAdminRights'):
        self.admin_rights = admin_rights

    def to_dict(self):
        return {
            '_': 'SetBotBroadcastDefaultAdminRightsRequest',
            'admin_rights': self.admin_rights,
        }

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

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


class SetBotCommandsRequest(TLRequest):
    """TL type: bots.setBotCommands"""
    CONSTRUCTOR_ID = 0x0517165a
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, scope: 'TypeBotCommandScope', lang_code: str, commands: List['TypeBotCommand']):
        self.scope = scope
        self.lang_code = lang_code
        self.commands = commands

    def to_dict(self):
        return {
            '_': 'SetBotCommandsRequest',
            'scope': self.scope,
            'lang_code': self.lang_code,
            'commands': self.commands,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_scope = reader.tgread_object()
        _args['scope'] = _val_scope
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        reader.read_int(signed=False)  # skip vector id
        _count_commands = reader.read_int()
        _list_commands = []
        for _ in range(_count_commands):
            _item_commands = reader.tgread_object()
            _list_commands.append(_item_commands)
        _args['commands'] = _list_commands
        return cls(**_args)


class SetBotGroupDefaultAdminRightsRequest(TLRequest):
    """TL type: bots.setBotGroupDefaultAdminRights"""
    CONSTRUCTOR_ID = 0x925ec9ea
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, admin_rights: 'TypeChatAdminRights'):
        self.admin_rights = admin_rights

    def to_dict(self):
        return {
            '_': 'SetBotGroupDefaultAdminRightsRequest',
            'admin_rights': self.admin_rights,
        }

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

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


class SetBotInfoRequest(TLRequest):
    """TL type: bots.setBotInfo"""
    CONSTRUCTOR_ID = 0x10cf3123
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, lang_code: str, bot: Optional['TypeInputUser'] = None, name: Optional[str] = None, about: Optional[str] = None, description: Optional[str] = None):
        self.lang_code = lang_code
        self.bot = bot
        self.name = name
        self.about = about
        self.description = description

    def to_dict(self):
        return {
            '_': 'SetBotInfoRequest',
            'lang_code': self.lang_code,
            'bot': self.bot,
            'name': self.name,
            'about': self.about,
            'description': self.description,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        if flags & (1 << 2):
            _val_bot = reader.tgread_object()
            _args['bot'] = _val_bot
        else:
            _args['bot'] = None
        _val_lang_code = reader.tgread_string()
        _args['lang_code'] = _val_lang_code
        if flags & (1 << 3):
            _val_name = reader.tgread_string()
            _args['name'] = _val_name
        else:
            _args['name'] = None
        if flags & (1 << 0):
            _val_about = reader.tgread_string()
            _args['about'] = _val_about
        else:
            _args['about'] = None
        if flags & (1 << 1):
            _val_description = reader.tgread_string()
            _args['description'] = _val_description
        else:
            _args['description'] = None
        return cls(**_args)


class SetBotMenuButtonRequest(TLRequest):
    """TL type: bots.setBotMenuButton"""
    CONSTRUCTOR_ID = 0x4504d54f
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, user_id: 'TypeInputUser', button: 'TypeBotMenuButton'):
        self.user_id = user_id
        self.button = button

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

    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(bytes(self.button))
        return buf.getvalue()

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


class SetCustomVerificationRequest(TLRequest):
    """TL type: bots.setCustomVerification"""
    CONSTRUCTOR_ID = 0x8b89dfbd
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, peer: 'TypeInputPeer', enabled: Optional[bool] = None, bot: Optional['TypeInputUser'] = None, custom_description: Optional[str] = None):
        self.peer = peer
        self.enabled = enabled
        self.bot = bot
        self.custom_description = custom_description

    def to_dict(self):
        return {
            '_': 'SetCustomVerificationRequest',
            'peer': self.peer,
            'enabled': self.enabled,
            'bot': self.bot,
            'custom_description': self.custom_description,
        }

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

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


class ToggleUserEmojiStatusPermissionRequest(TLRequest):
    """TL type: bots.toggleUserEmojiStatusPermission"""
    CONSTRUCTOR_ID = 0x06de6392
    SUBCLASS_OF_ID = 0xf5b399ac

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

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

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

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


class ToggleUsernameRequest(TLRequest):
    """TL type: bots.toggleUsername"""
    CONSTRUCTOR_ID = 0x053ca973
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, bot: 'TypeInputUser', username: str, active: bool):
        self.bot = bot
        self.username = username
        self.active = active

    def to_dict(self):
        return {
            '_': 'ToggleUsernameRequest',
            'bot': self.bot,
            'username': self.username,
            'active': self.active,
        }

    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.username))
        buf.write(struct.pack('<I', 0x997275b5 if self.active else 0xbc799737))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_bot = reader.tgread_object()
        _args['bot'] = _val_bot
        _val_username = reader.tgread_string()
        _args['username'] = _val_username
        _val_active = reader.tgread_bool()
        _args['active'] = _val_active
        return cls(**_args)


class UpdateStarRefProgramRequest(TLRequest):
    """TL type: bots.updateStarRefProgram"""
    CONSTRUCTOR_ID = 0x778b5ab3
    SUBCLASS_OF_ID = 0x9888e002

    def __init__(self, bot: 'TypeInputUser', commission_permille: int, duration_months: Optional[int] = None):
        self.bot = bot
        self.commission_permille = commission_permille
        self.duration_months = duration_months

    def to_dict(self):
        return {
            '_': 'UpdateStarRefProgramRequest',
            'bot': self.bot,
            'commission_permille': self.commission_permille,
            'duration_months': self.duration_months,
        }

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

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


class UpdateUserEmojiStatusRequest(TLRequest):
    """TL type: bots.updateUserEmojiStatus"""
    CONSTRUCTOR_ID = 0xed9f30c5
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, user_id: 'TypeInputUser', emoji_status: 'TypeEmojiStatus'):
        self.user_id = user_id
        self.emoji_status = emoji_status

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

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

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

