"""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 CheckSearchPostsFloodRequest(TLRequest):
    """TL type: channels.checkSearchPostsFlood"""
    CONSTRUCTOR_ID = 0x22567115
    SUBCLASS_OF_ID = 0xc2c0ccc1

    def __init__(self, query: Optional[str] = None):
        self.query = query

    def to_dict(self):
        return {
            '_': 'CheckSearchPostsFloodRequest',
            'query': self.query,
        }

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

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


class CheckUsernameRequest(TLRequest):
    """TL type: channels.checkUsername"""
    CONSTRUCTOR_ID = 0x10e6bd2c
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel: 'TypeInputChannel', username: str):
        self.channel = channel
        self.username = username

    def to_dict(self):
        return {
            '_': 'CheckUsernameRequest',
            'channel': self.channel,
            'username': self.username,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_username = reader.tgread_string()
        _args['username'] = _val_username
        return cls(**_args)


class ConvertToGigagroupRequest(TLRequest):
    """TL type: channels.convertToGigagroup"""
    CONSTRUCTOR_ID = 0x0b290c69
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel'):
        self.channel = channel

    def to_dict(self):
        return {
            '_': 'ConvertToGigagroupRequest',
            'channel': self.channel,
        }

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

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


class CreateChannelRequest(TLRequest):
    """TL type: channels.createChannel"""
    CONSTRUCTOR_ID = 0x91006707
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, title: str, about: str, broadcast: Optional[bool] = None, megagroup: Optional[bool] = None, for_import: Optional[bool] = None, forum: Optional[bool] = None, geo_point: Optional['TypeInputGeoPoint'] = None, address: Optional[str] = None, ttl_period: Optional[int] = None):
        self.title = title
        self.about = about
        self.broadcast = broadcast
        self.megagroup = megagroup
        self.for_import = for_import
        self.forum = forum
        self.geo_point = geo_point
        self.address = address
        self.ttl_period = ttl_period

    def to_dict(self):
        return {
            '_': 'CreateChannelRequest',
            'title': self.title,
            'about': self.about,
            'broadcast': self.broadcast,
            'megagroup': self.megagroup,
            'for_import': self.for_import,
            'forum': self.forum,
            'geo_point': self.geo_point,
            'address': self.address,
            '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.broadcast:
            flags |= (1 << 0)
        if self.megagroup:
            flags |= (1 << 1)
        if self.for_import:
            flags |= (1 << 3)
        if self.forum:
            flags |= (1 << 5)
        if self.address is not None:
            flags |= (1 << 2)
        if self.ttl_period is not None:
            flags |= (1 << 4)
        buf.write(struct.pack('<I', flags))
        buf.write(TLObject.serialize_bytes(self.title))
        buf.write(TLObject.serialize_bytes(self.about))
        if self.geo_point is not None:
            buf.write(bytes(self.geo_point))
        if self.address is not None:
            buf.write(TLObject.serialize_bytes(self.address))
        if self.ttl_period is not None:
            buf.write(struct.pack('<i', self.ttl_period))
        return buf.getvalue()

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['broadcast'] = bool(flags & (1 << 0))
        _args['megagroup'] = bool(flags & (1 << 1))
        _args['for_import'] = bool(flags & (1 << 3))
        _args['forum'] = bool(flags & (1 << 5))
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        _val_about = reader.tgread_string()
        _args['about'] = _val_about
        if flags & (1 << 2):
            _val_geo_point = reader.tgread_object()
            _args['geo_point'] = _val_geo_point
        else:
            _args['geo_point'] = None
        if flags & (1 << 2):
            _val_address = reader.tgread_string()
            _args['address'] = _val_address
        else:
            _args['address'] = None
        if flags & (1 << 4):
            _val_ttl_period = reader.read_int()
            _args['ttl_period'] = _val_ttl_period
        else:
            _args['ttl_period'] = None
        return cls(**_args)


class DeactivateAllUsernamesRequest(TLRequest):
    """TL type: channels.deactivateAllUsernames"""
    CONSTRUCTOR_ID = 0x0a245dd3
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel: 'TypeInputChannel'):
        self.channel = channel

    def to_dict(self):
        return {
            '_': 'DeactivateAllUsernamesRequest',
            'channel': self.channel,
        }

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

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


class DeleteChannelRequest(TLRequest):
    """TL type: channels.deleteChannel"""
    CONSTRUCTOR_ID = 0xc0111fe3
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel'):
        self.channel = channel

    def to_dict(self):
        return {
            '_': 'DeleteChannelRequest',
            'channel': self.channel,
        }

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

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


class DeleteHistoryRequest(TLRequest):
    """TL type: channels.deleteHistory"""
    CONSTRUCTOR_ID = 0x9baa9647
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', max_id: int, for_everyone: Optional[bool] = None):
        self.channel = channel
        self.max_id = max_id
        self.for_everyone = for_everyone

    def to_dict(self):
        return {
            '_': 'DeleteHistoryRequest',
            'channel': self.channel,
            'max_id': self.max_id,
            'for_everyone': self.for_everyone,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['for_everyone'] = bool(flags & (1 << 0))
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_max_id = reader.read_int()
        _args['max_id'] = _val_max_id
        return cls(**_args)


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

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

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

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.channel))
        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_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        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 DeleteParticipantHistoryRequest(TLRequest):
    """TL type: channels.deleteParticipantHistory"""
    CONSTRUCTOR_ID = 0x367544db
    SUBCLASS_OF_ID = 0x2c49c116

    def __init__(self, channel: 'TypeInputChannel', participant: 'TypeInputPeer'):
        self.channel = channel
        self.participant = participant

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

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

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


class EditAdminRequest(TLRequest):
    """TL type: channels.editAdmin"""
    CONSTRUCTOR_ID = 0xd33c8902
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', user_id: 'TypeInputUser', admin_rights: 'TypeChatAdminRights', rank: str):
        self.channel = channel
        self.user_id = user_id
        self.admin_rights = admin_rights
        self.rank = rank

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

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_user_id = reader.tgread_object()
        _args['user_id'] = _val_user_id
        _val_admin_rights = reader.tgread_object()
        _args['admin_rights'] = _val_admin_rights
        _val_rank = reader.tgread_string()
        _args['rank'] = _val_rank
        return cls(**_args)


class EditBannedRequest(TLRequest):
    """TL type: channels.editBanned"""
    CONSTRUCTOR_ID = 0x96e6cd81
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', participant: 'TypeInputPeer', banned_rights: 'TypeChatBannedRights'):
        self.channel = channel
        self.participant = participant
        self.banned_rights = banned_rights

    def to_dict(self):
        return {
            '_': 'EditBannedRequest',
            'channel': self.channel,
            'participant': self.participant,
            '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.channel))
        buf.write(bytes(self.participant))
        buf.write(bytes(self.banned_rights))
        return buf.getvalue()

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


class EditCreatorRequest(TLRequest):
    """TL type: channels.editCreator"""
    CONSTRUCTOR_ID = 0x8f38cd1f
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', user_id: 'TypeInputUser', password: 'TypeInputCheckPasswordSRP'):
        self.channel = channel
        self.user_id = user_id
        self.password = password

    def to_dict(self):
        return {
            '_': 'EditCreatorRequest',
            'channel': self.channel,
            'user_id': self.user_id,
            'password': self.password,
        }

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

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


class EditLocationRequest(TLRequest):
    """TL type: channels.editLocation"""
    CONSTRUCTOR_ID = 0x58e63f6d
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel: 'TypeInputChannel', geo_point: 'TypeInputGeoPoint', address: str):
        self.channel = channel
        self.geo_point = geo_point
        self.address = address

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

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

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


class EditPhotoRequest(TLRequest):
    """TL type: channels.editPhoto"""
    CONSTRUCTOR_ID = 0xf12e57c9
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', photo: 'TypeInputChatPhoto'):
        self.channel = channel
        self.photo = photo

    def to_dict(self):
        return {
            '_': 'EditPhotoRequest',
            'channel': self.channel,
            'photo': self.photo,
        }

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

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


class EditTitleRequest(TLRequest):
    """TL type: channels.editTitle"""
    CONSTRUCTOR_ID = 0x566decd0
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', title: str):
        self.channel = channel
        self.title = title

    def to_dict(self):
        return {
            '_': 'EditTitleRequest',
            'channel': self.channel,
            'title': self.title,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        return cls(**_args)


class ExportMessageLinkRequest(TLRequest):
    """TL type: channels.exportMessageLink"""
    CONSTRUCTOR_ID = 0xe63fadeb
    SUBCLASS_OF_ID = 0xdee644cc

    def __init__(self, channel: 'TypeInputChannel', id: int, grouped: Optional[bool] = None, thread: Optional[bool] = None):
        self.channel = channel
        self.id = id
        self.grouped = grouped
        self.thread = thread

    def to_dict(self):
        return {
            '_': 'ExportMessageLinkRequest',
            'channel': self.channel,
            'id': self.id,
            'grouped': self.grouped,
            'thread': self.thread,
        }

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

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


class GetAdminLogRequest(TLRequest):
    """TL type: channels.getAdminLog"""
    CONSTRUCTOR_ID = 0x33ddf480
    SUBCLASS_OF_ID = 0x51f076bc

    def __init__(self, channel: 'TypeInputChannel', q: str, max_id: int, min_id: int, limit: int, events_filter: Optional['TypeChannelAdminLogEventsFilter'] = None, admins: Optional[List['TypeInputUser']] = None):
        self.channel = channel
        self.q = q
        self.max_id = max_id
        self.min_id = min_id
        self.limit = limit
        self.events_filter = events_filter
        self.admins = admins

    def to_dict(self):
        return {
            '_': 'GetAdminLogRequest',
            'channel': self.channel,
            'q': self.q,
            'max_id': self.max_id,
            'min_id': self.min_id,
            'limit': self.limit,
            'events_filter': self.events_filter,
            'admins': self.admins,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_q = reader.tgread_string()
        _args['q'] = _val_q
        if flags & (1 << 0):
            _val_events_filter = reader.tgread_object()
            _args['events_filter'] = _val_events_filter
        else:
            _args['events_filter'] = None
        if flags & (1 << 1):
            reader.read_int(signed=False)  # skip vector id
            _count_admins = reader.read_int()
            _list_admins = []
            for _ in range(_count_admins):
                _item_admins = reader.tgread_object()
                _list_admins.append(_item_admins)
            _args['admins'] = _list_admins
        else:
            _args['admins'] = None
        _val_max_id = reader.read_long()
        _args['max_id'] = _val_max_id
        _val_min_id = reader.read_long()
        _args['min_id'] = _val_min_id
        _val_limit = reader.read_int()
        _args['limit'] = _val_limit
        return cls(**_args)


class GetAdminedPublicChannelsRequest(TLRequest):
    """TL type: channels.getAdminedPublicChannels"""
    CONSTRUCTOR_ID = 0xf8b036af
    SUBCLASS_OF_ID = 0x99d5cb14

    def __init__(self, by_location: Optional[bool] = None, check_limit: Optional[bool] = None, for_personal: Optional[bool] = None):
        self.by_location = by_location
        self.check_limit = check_limit
        self.for_personal = for_personal

    def to_dict(self):
        return {
            '_': 'GetAdminedPublicChannelsRequest',
            'by_location': self.by_location,
            'check_limit': self.check_limit,
            'for_personal': self.for_personal,
        }

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

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


class GetChannelRecommendationsRequest(TLRequest):
    """TL type: channels.getChannelRecommendations"""
    CONSTRUCTOR_ID = 0x25a71742
    SUBCLASS_OF_ID = 0x99d5cb14

    def __init__(self, channel: Optional['TypeInputChannel'] = None):
        self.channel = channel

    def to_dict(self):
        return {
            '_': 'GetChannelRecommendationsRequest',
            'channel': self.channel,
        }

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

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


class GetChannelsRequest(TLRequest):
    """TL type: channels.getChannels"""
    CONSTRUCTOR_ID = 0x0a7f6bbb
    SUBCLASS_OF_ID = 0x99d5cb14

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

    def to_dict(self):
        return {
            '_': 'GetChannelsRequest',
            '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 GetFullChannelRequest(TLRequest):
    """TL type: channels.getFullChannel"""
    CONSTRUCTOR_ID = 0x08736a09
    SUBCLASS_OF_ID = 0x225a5109

    def __init__(self, channel: 'TypeInputChannel'):
        self.channel = channel

    def to_dict(self):
        return {
            '_': 'GetFullChannelRequest',
            'channel': self.channel,
        }

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

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


class GetFutureCreatorAfterLeaveRequest(TLRequest):
    """TL type: channels.getFutureCreatorAfterLeave"""
    CONSTRUCTOR_ID = 0xa00918af
    SUBCLASS_OF_ID = 0x2da17977

    def __init__(self, channel: 'TypeInputChannel'):
        self.channel = channel

    def to_dict(self):
        return {
            '_': 'GetFutureCreatorAfterLeaveRequest',
            'channel': self.channel,
        }

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

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


class GetGroupsForDiscussionRequest(TLRequest):
    """TL type: channels.getGroupsForDiscussion"""
    CONSTRUCTOR_ID = 0xf5dad378
    SUBCLASS_OF_ID = 0x99d5cb14

    def __init__(self):
        pass

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

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

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


class GetInactiveChannelsRequest(TLRequest):
    """TL type: channels.getInactiveChannels"""
    CONSTRUCTOR_ID = 0x11e831ee
    SUBCLASS_OF_ID = 0x8bf3d7d4

    def __init__(self):
        pass

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

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

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


class GetLeftChannelsRequest(TLRequest):
    """TL type: channels.getLeftChannels"""
    CONSTRUCTOR_ID = 0x8341ecc0
    SUBCLASS_OF_ID = 0x99d5cb14

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

    def to_dict(self):
        return {
            '_': 'GetLeftChannelsRequest',
            'offset': self.offset,
        }

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

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


class GetMessageAuthorRequest(TLRequest):
    """TL type: channels.getMessageAuthor"""
    CONSTRUCTOR_ID = 0xece2a0e6
    SUBCLASS_OF_ID = 0x2da17977

    def __init__(self, channel: 'TypeInputChannel', id: int):
        self.channel = channel
        self.id = id

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

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

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


class GetMessagesRequest(TLRequest):
    """TL type: channels.getMessages"""
    CONSTRUCTOR_ID = 0xad8c9a23
    SUBCLASS_OF_ID = 0xd4b40b5e

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

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

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.channel))
        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 = {}
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        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 GetParticipantRequest(TLRequest):
    """TL type: channels.getParticipant"""
    CONSTRUCTOR_ID = 0xa0ab6cc6
    SUBCLASS_OF_ID = 0x6658151a

    def __init__(self, channel: 'TypeInputChannel', participant: 'TypeInputPeer'):
        self.channel = channel
        self.participant = participant

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

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

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


class GetParticipantsRequest(TLRequest):
    """TL type: channels.getParticipants"""
    CONSTRUCTOR_ID = 0x77ced9d0
    SUBCLASS_OF_ID = 0xe60a6e64

    def __init__(self, channel: 'TypeInputChannel', filter: 'TypeChannelParticipantsFilter', offset: int, limit: int, hash: int):
        self.channel = channel
        self.filter = filter
        self.offset = offset
        self.limit = limit
        self.hash = hash

    def to_dict(self):
        return {
            '_': 'GetParticipantsRequest',
            'channel': self.channel,
            'filter': self.filter,
            '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(bytes(self.channel))
        buf.write(bytes(self.filter))
        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_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_filter = reader.tgread_object()
        _args['filter'] = _val_filter
        _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 GetSendAsRequest(TLRequest):
    """TL type: channels.getSendAs"""
    CONSTRUCTOR_ID = 0xe785a43f
    SUBCLASS_OF_ID = 0x38cb8d21

    def __init__(self, peer: 'TypeInputPeer', for_paid_reactions: Optional[bool] = None, for_live_stories: Optional[bool] = None):
        self.peer = peer
        self.for_paid_reactions = for_paid_reactions
        self.for_live_stories = for_live_stories

    def to_dict(self):
        return {
            '_': 'GetSendAsRequest',
            'peer': self.peer,
            'for_paid_reactions': self.for_paid_reactions,
            'for_live_stories': self.for_live_stories,
        }

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


class InviteToChannelRequest(TLRequest):
    """TL type: channels.inviteToChannel"""
    CONSTRUCTOR_ID = 0xc9e33d54
    SUBCLASS_OF_ID = 0x3dbe90a1

    def __init__(self, channel: 'TypeInputChannel', users: List['TypeInputUser']):
        self.channel = channel
        self.users = users

    def to_dict(self):
        return {
            '_': 'InviteToChannelRequest',
            'channel': self.channel,
            'users': self.users,
        }

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

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


class JoinChannelRequest(TLRequest):
    """TL type: channels.joinChannel"""
    CONSTRUCTOR_ID = 0x24b524c5
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel'):
        self.channel = channel

    def to_dict(self):
        return {
            '_': 'JoinChannelRequest',
            'channel': self.channel,
        }

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

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


class LeaveChannelRequest(TLRequest):
    """TL type: channels.leaveChannel"""
    CONSTRUCTOR_ID = 0xf836aa95
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel'):
        self.channel = channel

    def to_dict(self):
        return {
            '_': 'LeaveChannelRequest',
            'channel': self.channel,
        }

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

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


class ReadHistoryRequest(TLRequest):
    """TL type: channels.readHistory"""
    CONSTRUCTOR_ID = 0xcc104937
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel: 'TypeInputChannel', max_id: int):
        self.channel = channel
        self.max_id = max_id

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

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


class ReadMessageContentsRequest(TLRequest):
    """TL type: channels.readMessageContents"""
    CONSTRUCTOR_ID = 0xeab5dc38
    SUBCLASS_OF_ID = 0xf5b399ac

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

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

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.channel))
        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_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        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 ReorderUsernamesRequest(TLRequest):
    """TL type: channels.reorderUsernames"""
    CONSTRUCTOR_ID = 0xb45ced1d
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel: 'TypeInputChannel', order: List[str]):
        self.channel = channel
        self.order = order

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

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.channel))
        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_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        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 ReportAntiSpamFalsePositiveRequest(TLRequest):
    """TL type: channels.reportAntiSpamFalsePositive"""
    CONSTRUCTOR_ID = 0xa850a693
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel: 'TypeInputChannel', msg_id: int):
        self.channel = channel
        self.msg_id = msg_id

    def to_dict(self):
        return {
            '_': 'ReportAntiSpamFalsePositiveRequest',
            'channel': self.channel,
            'msg_id': self.msg_id,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_msg_id = reader.read_int()
        _args['msg_id'] = _val_msg_id
        return cls(**_args)


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

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

    def to_dict(self):
        return {
            '_': 'ReportSpamRequest',
            'channel': self.channel,
            'participant': self.participant,
            'id': self.id,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.channel))
        buf.write(bytes(self.participant))
        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_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_participant = reader.tgread_object()
        _args['participant'] = _val_participant
        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 RestrictSponsoredMessagesRequest(TLRequest):
    """TL type: channels.restrictSponsoredMessages"""
    CONSTRUCTOR_ID = 0x9ae91519
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', restricted: bool):
        self.channel = channel
        self.restricted = restricted

    def to_dict(self):
        return {
            '_': 'RestrictSponsoredMessagesRequest',
            'channel': self.channel,
            'restricted': self.restricted,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_restricted = reader.tgread_bool()
        _args['restricted'] = _val_restricted
        return cls(**_args)


class SearchPostsRequest(TLRequest):
    """TL type: channels.searchPosts"""
    CONSTRUCTOR_ID = 0xf2c4f24d
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, offset_rate: int, offset_peer: 'TypeInputPeer', offset_id: int, limit: int, hashtag: Optional[str] = None, query: Optional[str] = None, allow_paid_stars: Optional[int] = None):
        self.offset_rate = offset_rate
        self.offset_peer = offset_peer
        self.offset_id = offset_id
        self.limit = limit
        self.hashtag = hashtag
        self.query = query
        self.allow_paid_stars = allow_paid_stars

    def to_dict(self):
        return {
            '_': 'SearchPostsRequest',
            'offset_rate': self.offset_rate,
            'offset_peer': self.offset_peer,
            'offset_id': self.offset_id,
            'limit': self.limit,
            'hashtag': self.hashtag,
            'query': self.query,
            '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.hashtag is not None:
            flags |= (1 << 0)
        if self.query is not None:
            flags |= (1 << 1)
        if self.allow_paid_stars is not None:
            flags |= (1 << 2)
        buf.write(struct.pack('<I', flags))
        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.hashtag is not None:
            buf.write(TLObject.serialize_bytes(self.hashtag))
        if self.query is not None:
            buf.write(TLObject.serialize_bytes(self.query))
        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)
        if flags & (1 << 0):
            _val_hashtag = reader.tgread_string()
            _args['hashtag'] = _val_hashtag
        else:
            _args['hashtag'] = None
        if flags & (1 << 1):
            _val_query = reader.tgread_string()
            _args['query'] = _val_query
        else:
            _args['query'] = None
        _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
        if flags & (1 << 2):
            _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 SetBoostsToUnblockRestrictionsRequest(TLRequest):
    """TL type: channels.setBoostsToUnblockRestrictions"""
    CONSTRUCTOR_ID = 0xad399cee
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', boosts: int):
        self.channel = channel
        self.boosts = boosts

    def to_dict(self):
        return {
            '_': 'SetBoostsToUnblockRestrictionsRequest',
            'channel': self.channel,
            'boosts': self.boosts,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_boosts = reader.read_int()
        _args['boosts'] = _val_boosts
        return cls(**_args)


class SetDiscussionGroupRequest(TLRequest):
    """TL type: channels.setDiscussionGroup"""
    CONSTRUCTOR_ID = 0x40582bb2
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, broadcast: 'TypeInputChannel', group: 'TypeInputChannel'):
        self.broadcast = broadcast
        self.group = group

    def to_dict(self):
        return {
            '_': 'SetDiscussionGroupRequest',
            'broadcast': self.broadcast,
            'group': self.group,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_broadcast = reader.tgread_object()
        _args['broadcast'] = _val_broadcast
        _val_group = reader.tgread_object()
        _args['group'] = _val_group
        return cls(**_args)


class SetEmojiStickersRequest(TLRequest):
    """TL type: channels.setEmojiStickers"""
    CONSTRUCTOR_ID = 0x3cd930b7
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel: 'TypeInputChannel', stickerset: 'TypeInputStickerSet'):
        self.channel = channel
        self.stickerset = stickerset

    def to_dict(self):
        return {
            '_': 'SetEmojiStickersRequest',
            'channel': self.channel,
            'stickerset': self.stickerset,
        }

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

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


class SetMainProfileTabRequest(TLRequest):
    """TL type: channels.setMainProfileTab"""
    CONSTRUCTOR_ID = 0x3583fcb1
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel: 'TypeInputChannel', tab: 'TypeProfileTab'):
        self.channel = channel
        self.tab = tab

    def to_dict(self):
        return {
            '_': 'SetMainProfileTabRequest',
            'channel': self.channel,
            'tab': self.tab,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_tab = reader.tgread_object()
        _args['tab'] = _val_tab
        return cls(**_args)


class SetStickersRequest(TLRequest):
    """TL type: channels.setStickers"""
    CONSTRUCTOR_ID = 0xea8ca4f9
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel: 'TypeInputChannel', stickerset: 'TypeInputStickerSet'):
        self.channel = channel
        self.stickerset = stickerset

    def to_dict(self):
        return {
            '_': 'SetStickersRequest',
            'channel': self.channel,
            'stickerset': self.stickerset,
        }

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

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


class ToggleAntiSpamRequest(TLRequest):
    """TL type: channels.toggleAntiSpam"""
    CONSTRUCTOR_ID = 0x68f3e4eb
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', enabled: bool):
        self.channel = channel
        self.enabled = enabled

    def to_dict(self):
        return {
            '_': 'ToggleAntiSpamRequest',
            'channel': self.channel,
            'enabled': self.enabled,
        }

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

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


class ToggleAutotranslationRequest(TLRequest):
    """TL type: channels.toggleAutotranslation"""
    CONSTRUCTOR_ID = 0x167fc0a1
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', enabled: bool):
        self.channel = channel
        self.enabled = enabled

    def to_dict(self):
        return {
            '_': 'ToggleAutotranslationRequest',
            'channel': self.channel,
            'enabled': self.enabled,
        }

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

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


class ToggleForumRequest(TLRequest):
    """TL type: channels.toggleForum"""
    CONSTRUCTOR_ID = 0x3ff75734
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', enabled: bool, tabs: bool):
        self.channel = channel
        self.enabled = enabled
        self.tabs = tabs

    def to_dict(self):
        return {
            '_': 'ToggleForumRequest',
            'channel': self.channel,
            'enabled': self.enabled,
            'tabs': self.tabs,
        }

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

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


class ToggleJoinRequestRequest(TLRequest):
    """TL type: channels.toggleJoinRequest"""
    CONSTRUCTOR_ID = 0x4c2985b6
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', enabled: bool):
        self.channel = channel
        self.enabled = enabled

    def to_dict(self):
        return {
            '_': 'ToggleJoinRequestRequest',
            'channel': self.channel,
            'enabled': self.enabled,
        }

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

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


class ToggleJoinToSendRequest(TLRequest):
    """TL type: channels.toggleJoinToSend"""
    CONSTRUCTOR_ID = 0xe4cb9580
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', enabled: bool):
        self.channel = channel
        self.enabled = enabled

    def to_dict(self):
        return {
            '_': 'ToggleJoinToSendRequest',
            'channel': self.channel,
            'enabled': self.enabled,
        }

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

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


class ToggleParticipantsHiddenRequest(TLRequest):
    """TL type: channels.toggleParticipantsHidden"""
    CONSTRUCTOR_ID = 0x6a6e7854
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', enabled: bool):
        self.channel = channel
        self.enabled = enabled

    def to_dict(self):
        return {
            '_': 'ToggleParticipantsHiddenRequest',
            'channel': self.channel,
            'enabled': self.enabled,
        }

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

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


class TogglePreHistoryHiddenRequest(TLRequest):
    """TL type: channels.togglePreHistoryHidden"""
    CONSTRUCTOR_ID = 0xeabbb94c
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', enabled: bool):
        self.channel = channel
        self.enabled = enabled

    def to_dict(self):
        return {
            '_': 'TogglePreHistoryHiddenRequest',
            'channel': self.channel,
            'enabled': self.enabled,
        }

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

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


class ToggleSignaturesRequest(TLRequest):
    """TL type: channels.toggleSignatures"""
    CONSTRUCTOR_ID = 0x418d549c
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', signatures_enabled: Optional[bool] = None, profiles_enabled: Optional[bool] = None):
        self.channel = channel
        self.signatures_enabled = signatures_enabled
        self.profiles_enabled = profiles_enabled

    def to_dict(self):
        return {
            '_': 'ToggleSignaturesRequest',
            'channel': self.channel,
            'signatures_enabled': self.signatures_enabled,
            'profiles_enabled': self.profiles_enabled,
        }

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

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


class ToggleSlowModeRequest(TLRequest):
    """TL type: channels.toggleSlowMode"""
    CONSTRUCTOR_ID = 0xedd49ef0
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', seconds: int):
        self.channel = channel
        self.seconds = seconds

    def to_dict(self):
        return {
            '_': 'ToggleSlowModeRequest',
            'channel': self.channel,
            'seconds': self.seconds,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_seconds = reader.read_int()
        _args['seconds'] = _val_seconds
        return cls(**_args)


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

    def __init__(self, channel: 'TypeInputChannel', username: str, active: bool):
        self.channel = channel
        self.username = username
        self.active = active

    def to_dict(self):
        return {
            '_': 'ToggleUsernameRequest',
            'channel': self.channel,
            '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.channel))
        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_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_username = reader.tgread_string()
        _args['username'] = _val_username
        _val_active = reader.tgread_bool()
        _args['active'] = _val_active
        return cls(**_args)


class ToggleViewForumAsMessagesRequest(TLRequest):
    """TL type: channels.toggleViewForumAsMessages"""
    CONSTRUCTOR_ID = 0x9738bb15
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', enabled: bool):
        self.channel = channel
        self.enabled = enabled

    def to_dict(self):
        return {
            '_': 'ToggleViewForumAsMessagesRequest',
            'channel': self.channel,
            'enabled': self.enabled,
        }

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

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


class UpdateColorRequest(TLRequest):
    """TL type: channels.updateColor"""
    CONSTRUCTOR_ID = 0xd8aa3671
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', for_profile: Optional[bool] = None, color: Optional[int] = None, background_emoji_id: Optional[int] = None):
        self.channel = channel
        self.for_profile = for_profile
        self.color = color
        self.background_emoji_id = background_emoji_id

    def to_dict(self):
        return {
            '_': 'UpdateColorRequest',
            'channel': self.channel,
            'for_profile': self.for_profile,
            'color': self.color,
            'background_emoji_id': self.background_emoji_id,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['for_profile'] = bool(flags & (1 << 1))
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        if flags & (1 << 2):
            _val_color = reader.read_int()
            _args['color'] = _val_color
        else:
            _args['color'] = None
        if flags & (1 << 0):
            _val_background_emoji_id = reader.read_long()
            _args['background_emoji_id'] = _val_background_emoji_id
        else:
            _args['background_emoji_id'] = None
        return cls(**_args)


class UpdateEmojiStatusRequest(TLRequest):
    """TL type: channels.updateEmojiStatus"""
    CONSTRUCTOR_ID = 0xf0d3e6a8
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', emoji_status: 'TypeEmojiStatus'):
        self.channel = channel
        self.emoji_status = emoji_status

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

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


class UpdatePaidMessagesPriceRequest(TLRequest):
    """TL type: channels.updatePaidMessagesPrice"""
    CONSTRUCTOR_ID = 0x4b12327b
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel: 'TypeInputChannel', send_paid_messages_stars: int, broadcast_messages_allowed: Optional[bool] = None):
        self.channel = channel
        self.send_paid_messages_stars = send_paid_messages_stars
        self.broadcast_messages_allowed = broadcast_messages_allowed

    def to_dict(self):
        return {
            '_': 'UpdatePaidMessagesPriceRequest',
            'channel': self.channel,
            'send_paid_messages_stars': self.send_paid_messages_stars,
            'broadcast_messages_allowed': self.broadcast_messages_allowed,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        flags = reader.read_int(signed=False)
        _args['broadcast_messages_allowed'] = bool(flags & (1 << 0))
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_send_paid_messages_stars = reader.read_long()
        _args['send_paid_messages_stars'] = _val_send_paid_messages_stars
        return cls(**_args)


class UpdateUsernameRequest(TLRequest):
    """TL type: channels.updateUsername"""
    CONSTRUCTOR_ID = 0x3514b3de
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel: 'TypeInputChannel', username: str):
        self.channel = channel
        self.username = username

    def to_dict(self):
        return {
            '_': 'UpdateUsernameRequest',
            'channel': self.channel,
            'username': self.username,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_channel = reader.tgread_object()
        _args['channel'] = _val_channel
        _val_username = reader.tgread_string()
        _args['username'] = _val_username
        return cls(**_args)

