from telethon.tl.mtproto_request import MTProtoRequest


class Error(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    error#c4b9f9bb code:int text:string = Error"""

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

    def __init__(self, code, text):
        """
        :param code: Telegram type: «int».
        :param text: Telegram type: «string».
        """
        super().__init__()

        self.code = code
        self.text = text

    def on_send(self, writer):
        writer.write_int(Error.constructor_id, signed=False)
        writer.write_int(self.code)
        writer.tgwrite_string(self.text)

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

    def on_response(self, reader):
        self.code = reader.read_int()
        self.text = reader.tgread_string()

    def __repr__(self):
        return 'error#c4b9f9bb code:int text:string = Error'

    def __str__(self):
        return '(error (ID: 0xc4b9f9bb) = (code={}, text={}))'.format(str(self.code), str(self.text))
