Jido.Chat.Telegram.ParseMode (Jido Chat Telegram v1.2.1)

Copy Markdown View Source

Resolves Telegram parse_mode from adapter option maps.

Precedence:

  • explicit parse_mode option
  • canonical top-level format mapping
  • nil (no parse mode)

Summary

Functions

Returns the Telegram parse_mode for normalized option maps.

Returns the rich-message body field for normalized option maps, or nil.

Functions

resolve_from_opts(opts)

@spec resolve_from_opts(map()) :: String.t() | nil

Returns the Telegram parse_mode for normalized option maps.

Supported format mappings:

  • :markdown / "markdown" -> "MarkdownV2"
  • :html / "html" -> "HTML"
  • :plain_text / "plain_text" -> nil

Unknown values are ignored and return nil.

Methods that support rich messages resolve resolve_rich_format/1 first and skip parse_mode entirely when it returns a format; captions (sendPhoto, sendDocument) have no rich variant and always land here.

resolve_rich_format(opts)

@spec resolve_rich_format(map()) :: :markdown | :html | nil

Returns the rich-message body field for normalized option maps, or nil.

Rich messages (Bot API 10.1) carry the whole body as Markdown or HTML inside rich_message and are parsed server-side, so they use no parse_mode.

Supported format mappings:

  • :markdown / :rich / :rich_markdown -> :markdown
  • :rich_html -> :html

Plain :markdown maps here, not to "MarkdownV2": MarkdownV2 is a Telegram subset that cannot express tables, headings, or nested lists, so callers asking for markdown get the renderer that handles all of it. Callers that specifically want the sendMessage subset opt out with an explicit parse_mode — that suppresses the inference, while an explicitly requested :rich_* format still wins.

An explicit rich_format option wins over an inferred one.