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


class AdminLogResults(TLObject):
    """TL type: channels.adminLogResults"""
    CONSTRUCTOR_ID = 0xed8af74d
    SUBCLASS_OF_ID = 0x51f076bc

    def __init__(self, events: List['TypeChannelAdminLogEvent'], chats: List['TypeChat'], users: List['TypeUser']):
        self.events = events
        self.chats = chats
        self.users = users

    def to_dict(self):
        return {
            '_': 'AdminLogResults',
            'events': self.events,
            'chats': self.chats,
            'users': self.users,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_events = reader.read_int()
        _list_events = []
        for _ in range(_count_events):
            _item_events = reader.tgread_object()
            _list_events.append(_item_events)
        _args['events'] = _list_events
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.tgread_object()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        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 ChannelParticipant(TLObject):
    """TL type: channels.channelParticipant"""
    CONSTRUCTOR_ID = 0xdfb80317
    SUBCLASS_OF_ID = 0x6658151a

    def __init__(self, participant: 'TypeChannelParticipant', chats: List['TypeChat'], users: List['TypeUser']):
        self.participant = participant
        self.chats = chats
        self.users = users

    def to_dict(self):
        return {
            '_': 'ChannelParticipant',
            'participant': self.participant,
            'chats': self.chats,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(bytes(self.participant))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 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_participant = reader.tgread_object()
        _args['participant'] = _val_participant
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.tgread_object()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        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 ChannelParticipants(TLObject):
    """TL type: channels.channelParticipants"""
    CONSTRUCTOR_ID = 0x9ab0feaf
    SUBCLASS_OF_ID = 0xe60a6e64

    def __init__(self, count: int, participants: List['TypeChannelParticipant'], chats: List['TypeChat'], users: List['TypeUser']):
        self.count = count
        self.participants = participants
        self.chats = chats
        self.users = users

    def to_dict(self):
        return {
            '_': 'ChannelParticipants',
            'count': self.count,
            'participants': self.participants,
            'chats': self.chats,
            'users': self.users,
        }

    def _bytes(self) -> bytes:
        import io
        buf = io.BytesIO()
        buf.write(struct.pack('<I', self.CONSTRUCTOR_ID))
        buf.write(struct.pack('<i', self.count))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.participants)))
        for item in self.participants:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 0x1cb5c415))  # vector id
        buf.write(struct.pack('<i', len(self.chats)))
        for item in self.chats:
            buf.write(bytes(self.item))
        buf.write(struct.pack('<i', 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_count = reader.read_int()
        _args['count'] = _val_count
        reader.read_int(signed=False)  # skip vector id
        _count_participants = reader.read_int()
        _list_participants = []
        for _ in range(_count_participants):
            _item_participants = reader.tgread_object()
            _list_participants.append(_item_participants)
        _args['participants'] = _list_participants
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.tgread_object()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        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 ChannelParticipantsNotModified(TLObject):
    """TL type: channels.channelParticipantsNotModified"""
    CONSTRUCTOR_ID = 0xf0173fe9
    SUBCLASS_OF_ID = 0xe60a6e64

    def __init__(self):
        pass

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

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

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


class SendAsPeers(TLObject):
    """TL type: channels.sendAsPeers"""
    CONSTRUCTOR_ID = 0xf496b0c6
    SUBCLASS_OF_ID = 0x38cb8d21

    def __init__(self, peers: List['TypeSendAsPeer'], chats: List['TypeChat'], users: List['TypeUser']):
        self.peers = peers
        self.chats = chats
        self.users = users

    def to_dict(self):
        return {
            '_': 'SendAsPeers',
            'peers': self.peers,
            'chats': self.chats,
            'users': self.users,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        reader.read_int(signed=False)  # skip vector id
        _count_peers = reader.read_int()
        _list_peers = []
        for _ in range(_count_peers):
            _item_peers = reader.tgread_object()
            _list_peers.append(_item_peers)
        _args['peers'] = _list_peers
        reader.read_int(signed=False)  # skip vector id
        _count_chats = reader.read_int()
        _list_chats = []
        for _ in range(_count_chats):
            _item_chats = reader.tgread_object()
            _list_chats.append(_item_chats)
        _args['chats'] = _list_chats
        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 SponsoredMessageReportResultAdsHidden(TLObject):
    """TL type: channels.sponsoredMessageReportResultAdsHidden"""
    CONSTRUCTOR_ID = 0x3e3bcf2f
    SUBCLASS_OF_ID = 0x26231822

    def __init__(self):
        pass

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

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

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


class SponsoredMessageReportResultChooseOption(TLObject):
    """TL type: channels.sponsoredMessageReportResultChooseOption"""
    CONSTRUCTOR_ID = 0x846f9e42
    SUBCLASS_OF_ID = 0x26231822

    def __init__(self, title: str, options: List['TypeSponsoredMessageReportOption']):
        self.title = title
        self.options = options

    def to_dict(self):
        return {
            '_': 'SponsoredMessageReportResultChooseOption',
            'title': self.title,
            'options': self.options,
        }

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

    @classmethod
    def from_reader(cls, reader):
        _args = {}
        _val_title = reader.tgread_string()
        _args['title'] = _val_title
        reader.read_int(signed=False)  # skip vector id
        _count_options = reader.read_int()
        _list_options = []
        for _ in range(_count_options):
            _item_options = reader.tgread_object()
            _list_options.append(_item_options)
        _args['options'] = _list_options
        return cls(**_args)


class SponsoredMessageReportResultReported(TLObject):
    """TL type: channels.sponsoredMessageReportResultReported"""
    CONSTRUCTOR_ID = 0xad798849
    SUBCLASS_OF_ID = 0x26231822

    def __init__(self):
        pass

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

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

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

