from telethon.tl.mtproto_request import MTProtoRequest


class InviteToChannelRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = Updates"""

    # Telegram's constructor ID (and unique identifier) for this class
    constructor_id = 0x199f3a6c

    def __init__(self, channel, users):
        """
        :param channel: Telegram type: «InputChannel».
        :param users: Telegram type: «InputUser». Must be a list.
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.channel = channel
        self.users = users

    def on_send(self, writer):
        writer.write_int(InviteToChannelRequest.constructor_id, signed=False)
        self.channel.on_send(writer)
        writer.write_int(0x1cb5c415, signed=False)  # Vector's constructor ID
        writer.write_int(len(self.users))
        for users_item in self.users:
            users_item.on_send(writer)

    @staticmethod
    def empty():
        """Returns an "empty" instance (all attributes are None)"""
        return InviteToChannelRequest(None, None)

    def on_response(self, reader):
        self.result = reader.tgread_object()

    def __repr__(self):
        return 'channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = Updates'

    def __str__(self):
        return '(channels.inviteToChannel (ID: 0x199f3a6c) = (channel={}, users={}))'.format(str(self.channel), None if not self.users else [str(_) for _ in self.users])
