parseMode method

Map parseMode(
  1. String text,
  2. String? parse_mode,
  3. List? entities
)

parse text to html or markdown

Implementation

Map parseMode(String text, String? parse_mode, List? entities) {
  parse_mode ??= "";
  entities ??= [];
  dynamic pesan = {"text": text};
  var parseMode = 'textParseModeHTML';
  parse_mode = parse_mode.toLowerCase();
  if (parse_mode == 'markdown') {
    parseMode = 'textParseModeMarkdown';
  } else if (parse_mode == 'html') {
    parseMode = 'textParseModeHTML';
  }

  try {
    pesan = td_execute(
      {
        "@type": 'parseTextEntities',
        "parse_mode": {"@type": parseMode},
        "text": text
      },
    );
  } catch (e) {}

  return pesan;
}