from telethon.tl.mtproto_request import MTProtoRequest


class SetEncryptedTypingRequest(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    messages.setEncryptedTyping#791451ed peer:InputEncryptedChat typing:Bool = Bool"""

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

    def __init__(self, peer, typing):
        """
        :param peer: Telegram type: «InputEncryptedChat».
        :param typing: Telegram type: «Bool».
        """
        super().__init__()
        self.result = None
        self.confirmed = True  # Confirmed by default

        self.peer = peer
        self.typing = typing

    def on_send(self, writer):
        writer.write_int(SetEncryptedTypingRequest.constructor_id, signed=False)
        self.peer.on_send(writer)
        writer.tgwrite_bool(self.typing)

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

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

    def __repr__(self):
        return 'messages.setEncryptedTyping#791451ed peer:InputEncryptedChat typing:Bool = Bool'

    def __str__(self):
        return '(messages.setEncryptedTyping (ID: 0x791451ed) = (peer={}, typing={}))'.format(str(self.peer), str(self.typing))
