from telethon.tl.mtproto_request import MTProtoRequest


class PageBlockPreformatted(MTProtoRequest):
    """Class generated by TLObjects' generator. All changes will be ERASED. Original .tl definition below.
    pageBlockPreformatted#c070d93e text:RichText language:string = PageBlock"""

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

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

        self.text = text
        self.language = language

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

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

    def on_response(self, reader):
        self.text = reader.tgread_object()
        self.language = reader.tgread_string()

    def __repr__(self):
        return 'pageBlockPreformatted#c070d93e text:RichText language:string = PageBlock'

    def __str__(self):
        return '(pageBlockPreformatted (ID: 0xc070d93e) = (text={}, language={}))'.format(str(self.text), str(self.language))
