"""File generated by TLObjects' generator. All changes will be ERASED"""
from ...tl.tlobject import TLObject
from typing import Optional, List, Union, TYPE_CHECKING
import os
import struct
if TYPE_CHECKING:
    from ...tl.types import TypeBool, TypeInputMessage, TypeInputStickerSet, TypeInputChannel, TypeChannelAdminLogEventsFilter, TypeChannelAdminRights, TypeChannelBannedRights, TypeInputUser, TypeInputChatPhoto, TypeChannelParticipantsFilter



class CheckUsernameRequest(TLObject):
    CONSTRUCTOR_ID = 0x10e6bd2c
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel, username):
        """
        :param TypeInputChannel channel:
        :param str username:

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.username = username  # type: str

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

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

    def __bytes__(self):
        return b''.join((
            b',\xbd\xe6\x10',
            bytes(self.channel),
            TLObject.serialize_bytes(self.username),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _username = reader.tgread_string()
        return cls(channel=_channel, username=_username)


class CreateChannelRequest(TLObject):
    CONSTRUCTOR_ID = 0xf4893d7f
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, title, about, broadcast=None, megagroup=None):
        """
        :param str title:
        :param str about:
        :param Optional[bool] broadcast:
        :param Optional[bool] megagroup:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.title = title  # type: str
        self.about = about  # type: str
        self.broadcast = broadcast  # type: Optional[bool]
        self.megagroup = megagroup  # type: Optional[bool]

    def to_dict(self):
        return {
            '_': 'CreateChannelRequest',
            'title': self.title,
            'about': self.about,
            'broadcast': self.broadcast,
            'megagroup': self.megagroup
        }

    def __bytes__(self):
        return b''.join((
            b'\x7f=\x89\xf4',
            struct.pack('<I', (0 if self.broadcast is None or self.broadcast is False else 1) | (0 if self.megagroup is None or self.megagroup is False else 2)),
            TLObject.serialize_bytes(self.title),
            TLObject.serialize_bytes(self.about),
        ))

    @classmethod
    def from_reader(cls, reader):
        flags = reader.read_int()

        _broadcast = bool(flags & 1)
        _megagroup = bool(flags & 2)
        _title = reader.tgread_string()
        _about = reader.tgread_string()
        return cls(title=_title, about=_about, broadcast=_broadcast, megagroup=_megagroup)


class DeleteChannelRequest(TLObject):
    CONSTRUCTOR_ID = 0xc0111fe3
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel):
        """
        :param TypeInputChannel channel:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'DeleteChannelRequest',
            'channel': None if self.channel is None else self.channel.to_dict()
        }

    def __bytes__(self):
        return b''.join((
            b'\xe3\x1f\x11\xc0',
            bytes(self.channel),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        return cls(channel=_channel)


class DeleteHistoryRequest(TLObject):
    CONSTRUCTOR_ID = 0xaf369d42
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel, max_id):
        """
        :param TypeInputChannel channel:
        :param int max_id:

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.max_id = max_id  # type: int

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'DeleteHistoryRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'max_id': self.max_id
        }

    def __bytes__(self):
        return b''.join((
            b'B\x9d6\xaf',
            bytes(self.channel),
            struct.pack('<i', self.max_id),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _max_id = reader.read_int()
        return cls(channel=_channel, max_id=_max_id)


class DeleteMessagesRequest(TLObject):
    CONSTRUCTOR_ID = 0x84c1fd4e
    SUBCLASS_OF_ID = 0xced3c06e

    def __init__(self, channel, id):
        """
        :param TypeInputChannel channel:
        :param List[int] id:

        :returns messages.AffectedMessages: Instance of AffectedMessages.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.id = id  # type: List[int]

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'DeleteMessagesRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'id': [] if self.id is None else self.id[:]
        }

    def __bytes__(self):
        return b''.join((
            b'N\xfd\xc1\x84',
            bytes(self.channel),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.id)),b''.join(struct.pack('<i', x) for x in self.id),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        reader.read_int()
        _id = []
        for _ in range(reader.read_int()):
            _x = reader.read_int()
            _id.append(_x)

        return cls(channel=_channel, id=_id)


class DeleteUserHistoryRequest(TLObject):
    CONSTRUCTOR_ID = 0xd10dd71b
    SUBCLASS_OF_ID = 0x2c49c116

    def __init__(self, channel, user_id):
        """
        :param TypeInputChannel channel:
        :param TypeInputUser user_id:

        :returns messages.AffectedHistory: Instance of AffectedHistory.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.user_id = user_id  # type: TypeInputUser

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))
        self.user_id = utils.get_input_user(client.get_input_entity(self.user_id))

    def to_dict(self):
        return {
            '_': 'DeleteUserHistoryRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'user_id': None if self.user_id is None else self.user_id.to_dict()
        }

    def __bytes__(self):
        return b''.join((
            b'\x1b\xd7\r\xd1',
            bytes(self.channel),
            bytes(self.user_id),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _user_id = reader.tgread_object()
        return cls(channel=_channel, user_id=_user_id)


class EditAboutRequest(TLObject):
    CONSTRUCTOR_ID = 0x13e27f1e
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel, about):
        """
        :param TypeInputChannel channel:
        :param str about:

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.about = about  # type: str

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'EditAboutRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'about': self.about
        }

    def __bytes__(self):
        return b''.join((
            b'\x1e\x7f\xe2\x13',
            bytes(self.channel),
            TLObject.serialize_bytes(self.about),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _about = reader.tgread_string()
        return cls(channel=_channel, about=_about)


class EditAdminRequest(TLObject):
    CONSTRUCTOR_ID = 0x20b88214
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel, user_id, admin_rights):
        """
        :param TypeInputChannel channel:
        :param TypeInputUser user_id:
        :param TypeChannelAdminRights admin_rights:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.user_id = user_id  # type: TypeInputUser
        self.admin_rights = admin_rights  # type: TypeChannelAdminRights

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))
        self.user_id = utils.get_input_user(client.get_input_entity(self.user_id))

    def to_dict(self):
        return {
            '_': 'EditAdminRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'user_id': None if self.user_id is None else self.user_id.to_dict(),
            'admin_rights': None if self.admin_rights is None else self.admin_rights.to_dict()
        }

    def __bytes__(self):
        return b''.join((
            b'\x14\x82\xb8 ',
            bytes(self.channel),
            bytes(self.user_id),
            bytes(self.admin_rights),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _user_id = reader.tgread_object()
        _admin_rights = reader.tgread_object()
        return cls(channel=_channel, user_id=_user_id, admin_rights=_admin_rights)


class EditBannedRequest(TLObject):
    CONSTRUCTOR_ID = 0xbfd915cd
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel, user_id, banned_rights):
        """
        :param TypeInputChannel channel:
        :param TypeInputUser user_id:
        :param TypeChannelBannedRights banned_rights:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.user_id = user_id  # type: TypeInputUser
        self.banned_rights = banned_rights  # type: TypeChannelBannedRights

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))
        self.user_id = utils.get_input_user(client.get_input_entity(self.user_id))

    def to_dict(self):
        return {
            '_': 'EditBannedRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'user_id': None if self.user_id is None else self.user_id.to_dict(),
            'banned_rights': None if self.banned_rights is None else self.banned_rights.to_dict()
        }

    def __bytes__(self):
        return b''.join((
            b'\xcd\x15\xd9\xbf',
            bytes(self.channel),
            bytes(self.user_id),
            bytes(self.banned_rights),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _user_id = reader.tgread_object()
        _banned_rights = reader.tgread_object()
        return cls(channel=_channel, user_id=_user_id, banned_rights=_banned_rights)


class EditPhotoRequest(TLObject):
    CONSTRUCTOR_ID = 0xf12e57c9
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel, photo):
        """
        :param TypeInputChannel channel:
        :param TypeInputChatPhoto photo:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.photo = photo  # type: TypeInputChatPhoto

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

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

    def __bytes__(self):
        return b''.join((
            b'\xc9W.\xf1',
            bytes(self.channel),
            bytes(self.photo),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _photo = reader.tgread_object()
        return cls(channel=_channel, photo=_photo)


class EditTitleRequest(TLObject):
    CONSTRUCTOR_ID = 0x566decd0
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel, title):
        """
        :param TypeInputChannel channel:
        :param str title:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.title = title  # type: str

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

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

    def __bytes__(self):
        return b''.join((
            b'\xd0\xecmV',
            bytes(self.channel),
            TLObject.serialize_bytes(self.title),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _title = reader.tgread_string()
        return cls(channel=_channel, title=_title)


class ExportInviteRequest(TLObject):
    CONSTRUCTOR_ID = 0xc7560885
    SUBCLASS_OF_ID = 0xb4748a58

    def __init__(self, channel):
        """
        :param TypeInputChannel channel:

        :returns ExportedChatInvite: Instance of either ChatInviteEmpty, ChatInviteExported.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'ExportInviteRequest',
            'channel': None if self.channel is None else self.channel.to_dict()
        }

    def __bytes__(self):
        return b''.join((
            b'\x85\x08V\xc7',
            bytes(self.channel),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        return cls(channel=_channel)


class ExportMessageLinkRequest(TLObject):
    CONSTRUCTOR_ID = 0xceb77163
    SUBCLASS_OF_ID = 0xdee644cc

    def __init__(self, channel, id, grouped):
        """
        :param TypeInputChannel channel:
        :param int id:
        :param TypeBool grouped:

        :returns ExportedMessageLink: Instance of ExportedMessageLink.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.id = id  # type: int
        self.grouped = grouped  # type: TypeBool

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'ExportMessageLinkRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'id': self.id,
            'grouped': self.grouped
        }

    def __bytes__(self):
        return b''.join((
            b'cq\xb7\xce',
            bytes(self.channel),
            struct.pack('<i', self.id),
            b'\xb5ur\x99' if self.grouped else b'7\x97y\xbc',
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _id = reader.read_int()
        _grouped = reader.tgread_bool()
        return cls(channel=_channel, id=_id, grouped=_grouped)


class GetAdminLogRequest(TLObject):
    CONSTRUCTOR_ID = 0x33ddf480
    SUBCLASS_OF_ID = 0x51f076bc

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

        :returns channels.AdminLogResults: Instance of AdminLogResults.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.q = q  # type: str
        self.max_id = max_id  # type: int
        self.min_id = min_id  # type: int
        self.limit = limit  # type: int
        self.events_filter = events_filter  # type: Optional[TypeChannelAdminLogEventsFilter]
        self.admins = admins  # type: Optional[List[TypeInputUser]]

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))
        self.admins = [utils.get_input_user(client.get_input_entity(_x)) for _x in self.admins] if self.admins else None

    def to_dict(self):
        return {
            '_': 'GetAdminLogRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'q': self.q,
            'max_id': self.max_id,
            'min_id': self.min_id,
            'limit': self.limit,
            'events_filter': None if self.events_filter is None else self.events_filter.to_dict(),
            'admins': [] if self.admins is None else [None if x is None else x.to_dict() for x in self.admins]
        }

    def __bytes__(self):
        return b''.join((
            b'\x80\xf4\xdd3',
            struct.pack('<I', (0 if self.events_filter is None or self.events_filter is False else 1) | (0 if self.admins is None or self.admins is False else 2)),
            bytes(self.channel),
            TLObject.serialize_bytes(self.q),
            b'' if self.events_filter is None or self.events_filter is False else (bytes(self.events_filter)),
            b'' if self.admins is None or self.admins is False else b''.join((b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.admins)),b''.join(bytes(x) for x in self.admins))),
            struct.pack('<q', self.max_id),
            struct.pack('<q', self.min_id),
            struct.pack('<i', self.limit),
        ))

    @classmethod
    def from_reader(cls, reader):
        flags = reader.read_int()

        _channel = reader.tgread_object()
        _q = reader.tgread_string()
        if flags & 1:
            _events_filter = reader.tgread_object()
        else:
            _events_filter = None
        if flags & 2:
            reader.read_int()
            _admins = []
            for _ in range(reader.read_int()):
                _x = reader.tgread_object()
                _admins.append(_x)

        else:
            _admins = None
        _max_id = reader.read_long()
        _min_id = reader.read_long()
        _limit = reader.read_int()
        return cls(channel=_channel, q=_q, max_id=_max_id, min_id=_min_id, limit=_limit, events_filter=_events_filter, admins=_admins)


class GetAdminedPublicChannelsRequest(TLObject):
    CONSTRUCTOR_ID = 0x8d8d82d7
    SUBCLASS_OF_ID = 0x99d5cb14

    def __init__(self):
        super().__init__()
        self.result = None
        self.content_related = True

    def to_dict(self):
        return {
            '_': 'GetAdminedPublicChannelsRequest'
        }

    def __bytes__(self):
        return b''.join((
            b'\xd7\x82\x8d\x8d',
        ))

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


class GetChannelsRequest(TLObject):
    CONSTRUCTOR_ID = 0xa7f6bbb
    SUBCLASS_OF_ID = 0x99d5cb14

    def __init__(self, id):
        """
        :param List[TypeInputChannel] id:

        :returns messages.Chats: Instance of either Chats, ChatsSlice.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.id = id  # type: List[TypeInputChannel]

    def resolve(self, client, utils):
        self.id = [utils.get_input_channel(client.get_input_entity(_x)) for _x in self.id]

    def to_dict(self):
        return {
            '_': 'GetChannelsRequest',
            'id': [] if self.id is None else [None if x is None else x.to_dict() for x in self.id]
        }

    def __bytes__(self):
        return b''.join((
            b'\xbbk\x7f\n',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.id)),b''.join(bytes(x) for x in self.id),
        ))

    @classmethod
    def from_reader(cls, reader):
        reader.read_int()
        _id = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _id.append(_x)

        return cls(id=_id)


class GetFullChannelRequest(TLObject):
    CONSTRUCTOR_ID = 0x8736a09
    SUBCLASS_OF_ID = 0x225a5109

    def __init__(self, channel):
        """
        :param TypeInputChannel channel:

        :returns messages.ChatFull: Instance of ChatFull.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'GetFullChannelRequest',
            'channel': None if self.channel is None else self.channel.to_dict()
        }

    def __bytes__(self):
        return b''.join((
            b'\tjs\x08',
            bytes(self.channel),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        return cls(channel=_channel)


class GetMessagesRequest(TLObject):
    CONSTRUCTOR_ID = 0xad8c9a23
    SUBCLASS_OF_ID = 0xd4b40b5e

    def __init__(self, channel, id):
        """
        :param TypeInputChannel channel:
        :param List[TypeInputMessage] id:

        :returns messages.Messages: Instance of either Messages, MessagesSlice, ChannelMessages, MessagesNotModified.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.id = id  # type: List[TypeInputMessage]

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))
        self.id = [utils.get_input_message(_x) for _x in self.id]

    def to_dict(self):
        return {
            '_': 'GetMessagesRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'id': [] if self.id is None else [None if x is None else x.to_dict() for x in self.id]
        }

    def __bytes__(self):
        return b''.join((
            b'#\x9a\x8c\xad',
            bytes(self.channel),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.id)),b''.join(bytes(x) for x in self.id),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        reader.read_int()
        _id = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _id.append(_x)

        return cls(channel=_channel, id=_id)


class GetParticipantRequest(TLObject):
    CONSTRUCTOR_ID = 0x546dd7a6
    SUBCLASS_OF_ID = 0x6658151a

    def __init__(self, channel, user_id):
        """
        :param TypeInputChannel channel:
        :param TypeInputUser user_id:

        :returns channels.ChannelParticipant: Instance of ChannelParticipant.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.user_id = user_id  # type: TypeInputUser

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))
        self.user_id = utils.get_input_user(client.get_input_entity(self.user_id))

    def to_dict(self):
        return {
            '_': 'GetParticipantRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'user_id': None if self.user_id is None else self.user_id.to_dict()
        }

    def __bytes__(self):
        return b''.join((
            b'\xa6\xd7mT',
            bytes(self.channel),
            bytes(self.user_id),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _user_id = reader.tgread_object()
        return cls(channel=_channel, user_id=_user_id)


class GetParticipantsRequest(TLObject):
    CONSTRUCTOR_ID = 0x123e05e9
    SUBCLASS_OF_ID = 0xe60a6e64

    def __init__(self, channel, filter, offset, limit, hash):
        """
        :param TypeInputChannel channel:
        :param TypeChannelParticipantsFilter filter:
        :param int offset:
        :param int limit:
        :param int hash:

        :returns channels.ChannelParticipants: Instance of either ChannelParticipants, ChannelParticipantsNotModified.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.filter = filter  # type: TypeChannelParticipantsFilter
        self.offset = offset  # type: int
        self.limit = limit  # type: int
        self.hash = hash  # type: int

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'GetParticipantsRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'filter': None if self.filter is None else self.filter.to_dict(),
            'offset': self.offset,
            'limit': self.limit,
            'hash': self.hash
        }

    def __bytes__(self):
        return b''.join((
            b'\xe9\x05>\x12',
            bytes(self.channel),
            bytes(self.filter),
            struct.pack('<i', self.offset),
            struct.pack('<i', self.limit),
            struct.pack('<i', self.hash),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _filter = reader.tgread_object()
        _offset = reader.read_int()
        _limit = reader.read_int()
        _hash = reader.read_int()
        return cls(channel=_channel, filter=_filter, offset=_offset, limit=_limit, hash=_hash)


class InviteToChannelRequest(TLObject):
    CONSTRUCTOR_ID = 0x199f3a6c
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel, users):
        """
        :param TypeInputChannel channel:
        :param List[TypeInputUser] users:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.users = users  # type: List[TypeInputUser]

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))
        self.users = [utils.get_input_user(client.get_input_entity(_x)) for _x in self.users]

    def to_dict(self):
        return {
            '_': 'InviteToChannelRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'users': [] if self.users is None else [None if x is None else x.to_dict() for x in self.users]
        }

    def __bytes__(self):
        return b''.join((
            b'l:\x9f\x19',
            bytes(self.channel),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(bytes(x) for x in self.users),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        reader.read_int()
        _users = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _users.append(_x)

        return cls(channel=_channel, users=_users)


class JoinChannelRequest(TLObject):
    CONSTRUCTOR_ID = 0x24b524c5
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel):
        """
        :param TypeInputChannel channel:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'JoinChannelRequest',
            'channel': None if self.channel is None else self.channel.to_dict()
        }

    def __bytes__(self):
        return b''.join((
            b'\xc5$\xb5$',
            bytes(self.channel),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        return cls(channel=_channel)


class LeaveChannelRequest(TLObject):
    CONSTRUCTOR_ID = 0xf836aa95
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel):
        """
        :param TypeInputChannel channel:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'LeaveChannelRequest',
            'channel': None if self.channel is None else self.channel.to_dict()
        }

    def __bytes__(self):
        return b''.join((
            b'\x95\xaa6\xf8',
            bytes(self.channel),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        return cls(channel=_channel)


class ReadHistoryRequest(TLObject):
    CONSTRUCTOR_ID = 0xcc104937
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel, max_id):
        """
        :param TypeInputChannel channel:
        :param int max_id:

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.max_id = max_id  # type: int

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'ReadHistoryRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'max_id': self.max_id
        }

    def __bytes__(self):
        return b''.join((
            b'7I\x10\xcc',
            bytes(self.channel),
            struct.pack('<i', self.max_id),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _max_id = reader.read_int()
        return cls(channel=_channel, max_id=_max_id)


class ReadMessageContentsRequest(TLObject):
    CONSTRUCTOR_ID = 0xeab5dc38
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel, id):
        """
        :param TypeInputChannel channel:
        :param List[int] id:

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.id = id  # type: List[int]

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'ReadMessageContentsRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'id': [] if self.id is None else self.id[:]
        }

    def __bytes__(self):
        return b''.join((
            b'8\xdc\xb5\xea',
            bytes(self.channel),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.id)),b''.join(struct.pack('<i', x) for x in self.id),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        reader.read_int()
        _id = []
        for _ in range(reader.read_int()):
            _x = reader.read_int()
            _id.append(_x)

        return cls(channel=_channel, id=_id)


class ReportSpamRequest(TLObject):
    CONSTRUCTOR_ID = 0xfe087810
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel, user_id, id):
        """
        :param TypeInputChannel channel:
        :param TypeInputUser user_id:
        :param List[int] id:

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.user_id = user_id  # type: TypeInputUser
        self.id = id  # type: List[int]

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))
        self.user_id = utils.get_input_user(client.get_input_entity(self.user_id))

    def to_dict(self):
        return {
            '_': 'ReportSpamRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'user_id': None if self.user_id is None else self.user_id.to_dict(),
            'id': [] if self.id is None else self.id[:]
        }

    def __bytes__(self):
        return b''.join((
            b'\x10x\x08\xfe',
            bytes(self.channel),
            bytes(self.user_id),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.id)),b''.join(struct.pack('<i', x) for x in self.id),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _user_id = reader.tgread_object()
        reader.read_int()
        _id = []
        for _ in range(reader.read_int()):
            _x = reader.read_int()
            _id.append(_x)

        return cls(channel=_channel, user_id=_user_id, id=_id)


class SetStickersRequest(TLObject):
    CONSTRUCTOR_ID = 0xea8ca4f9
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel, stickerset):
        """
        :param TypeInputChannel channel:
        :param TypeInputStickerSet stickerset:

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.stickerset = stickerset  # type: TypeInputStickerSet

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

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

    def __bytes__(self):
        return b''.join((
            b'\xf9\xa4\x8c\xea',
            bytes(self.channel),
            bytes(self.stickerset),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _stickerset = reader.tgread_object()
        return cls(channel=_channel, stickerset=_stickerset)


class ToggleInvitesRequest(TLObject):
    CONSTRUCTOR_ID = 0x49609307
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel, enabled):
        """
        :param TypeInputChannel channel:
        :param TypeBool enabled:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.enabled = enabled  # type: TypeBool

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'ToggleInvitesRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'enabled': self.enabled
        }

    def __bytes__(self):
        return b''.join((
            b'\x07\x93`I',
            bytes(self.channel),
            b'\xb5ur\x99' if self.enabled else b'7\x97y\xbc',
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _enabled = reader.tgread_bool()
        return cls(channel=_channel, enabled=_enabled)


class TogglePreHistoryHiddenRequest(TLObject):
    CONSTRUCTOR_ID = 0xeabbb94c
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel, enabled):
        """
        :param TypeInputChannel channel:
        :param TypeBool enabled:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.enabled = enabled  # type: TypeBool

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

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

    def __bytes__(self):
        return b''.join((
            b'L\xb9\xbb\xea',
            bytes(self.channel),
            b'\xb5ur\x99' if self.enabled else b'7\x97y\xbc',
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _enabled = reader.tgread_bool()
        return cls(channel=_channel, enabled=_enabled)


class ToggleSignaturesRequest(TLObject):
    CONSTRUCTOR_ID = 0x1f69b606
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel, enabled):
        """
        :param TypeInputChannel channel:
        :param TypeBool enabled:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.enabled = enabled  # type: TypeBool

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'ToggleSignaturesRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'enabled': self.enabled
        }

    def __bytes__(self):
        return b''.join((
            b'\x06\xb6i\x1f',
            bytes(self.channel),
            b'\xb5ur\x99' if self.enabled else b'7\x97y\xbc',
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _enabled = reader.tgread_bool()
        return cls(channel=_channel, enabled=_enabled)


class UpdatePinnedMessageRequest(TLObject):
    CONSTRUCTOR_ID = 0xa72ded52
    SUBCLASS_OF_ID = 0x8af52aac

    def __init__(self, channel, id, silent=None):
        """
        :param TypeInputChannel channel:
        :param int id:
        :param Optional[bool] silent:

        :returns Updates: Instance of either UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.id = id  # type: int
        self.silent = silent  # type: Optional[bool]

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

    def to_dict(self):
        return {
            '_': 'UpdatePinnedMessageRequest',
            'channel': None if self.channel is None else self.channel.to_dict(),
            'id': self.id,
            'silent': self.silent
        }

    def __bytes__(self):
        return b''.join((
            b'R\xed-\xa7',
            struct.pack('<I', (0 if self.silent is None or self.silent is False else 1)),
            bytes(self.channel),
            struct.pack('<i', self.id),
        ))

    @classmethod
    def from_reader(cls, reader):
        flags = reader.read_int()

        _silent = bool(flags & 1)
        _channel = reader.tgread_object()
        _id = reader.read_int()
        return cls(channel=_channel, id=_id, silent=_silent)


class UpdateUsernameRequest(TLObject):
    CONSTRUCTOR_ID = 0x3514b3de
    SUBCLASS_OF_ID = 0xf5b399ac

    def __init__(self, channel, username):
        """
        :param TypeInputChannel channel:
        :param str username:

        :returns Bool: This type has no constructors.
        """
        super().__init__()
        self.result = None
        self.content_related = True

        self.channel = channel  # type: TypeInputChannel
        self.username = username  # type: str

    def resolve(self, client, utils):
        self.channel = utils.get_input_channel(client.get_input_entity(self.channel))

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

    def __bytes__(self):
        return b''.join((
            b'\xde\xb3\x145',
            bytes(self.channel),
            TLObject.serialize_bytes(self.username),
        ))

    @classmethod
    def from_reader(cls, reader):
        _channel = reader.tgread_object()
        _username = reader.tgread_string()
        return cls(channel=_channel, username=_username)

