Skip to content

parseTextEntities

Sahri Riza Umami edited this page Jul 1, 2018 · 1 revision

Parses Bold, Italic, Code, Pre, PreCode and TextUrl entities contained in the text.
This is an offline method.
Can be called before authorization.
Can be called synchronously.

parseTextEntities(text, parse_mode, callback, data)
Field Type Description
text string The text which should be parsed.
parse_mode string Text parse mode.

Example

  • Parses Bold, Italic, Code, Pre, PreCode and TextUrl entities contained in the text Test <code>parseTextEntities</code>: <b>bold</b>, <i>italic</i> and <a href="https://github.com/rizaumami/tdbot.lua">URL</a>..

    parseTextEntities('Test <code>parseTextEntities</code>: <b>bold</b>, <i>italic</i> and <a href="https://github.com/rizaumami/tdbot.lua">URL</a>.', 'HTML')

    Response:

    {
      ["@type"] = "formattedText",
      entities = {
        {
          ["@type"] = "textEntity",
          length = 17,
          offset = 5,
          type = {
            ["@type"] = "textEntityTypeCode"
          }
        },
        {
          ["@type"] = "textEntity",
          length = 4,
          offset = 24,
          type = {
            ["@type"] = "textEntityTypeBold"
          }
        },
        {
          ["@type"] = "textEntity",
          length = 6,
          offset = 30,
          type = {
            ["@type"] = "textEntityTypeItalic"
          }
        },
        {
          ["@type"] = "textEntity",
          length = 3,
          offset = 41,
          type = {
            ["@type"] = "textEntityTypeTextUrl",
            url = "https://github.com/rizaumami/tdbot.lua"
          }
        }
      },
      text = "Test parseTextEntities: bold, italic and URL."
    }

Frequently Asked Questions
The Functions

Clone this wiki locally