Nadia.InputRichMessage (nadia v1.7.0)

View Source

Typed builders for Telegram InputRichMessage objects.

html/2 and markdown/2 fix the selected formatting mode and validate the locally enforceable rich-message limits. blocks/2 builds block-based content and with_media/2 attaches explicit embedded media. Nadia validates valid UTF-8, the 32,768-character source limit, the 500-block and 50-media limits, media ids, and Boolean flags. Nadia does not parse or otherwise validate HTML or Markdown formatting.

Telegram enforces up to 500 blocks, 16 nesting levels, 50 media attachments, and 20 table columns, as well as the supported syntax, block structure, media URLs and MIME types, rendering, and chat media permissions.

Telegram permits thinking blocks only in rich-message drafts. Context validation conservatively detects the case-insensitive literal <tg-thinking prefix anywhere in the source. This can reject escaped or otherwise non-tag text containing that literal because Nadia intentionally does not include an HTML or Markdown parser.

Summary

Types

t()

A typed Telegram InputRichMessage value. Its representation is opaque.

Functions

Builds a rich message described with Telegram's supported block entities.

Builds a rich message described with Telegram's supported HTML formatting.

Builds a rich message described with Telegram's supported Markdown formatting.

Builds a rich message with explicit embedded media plus HTML or Markdown source.

Types

context()

@type context() :: :send | :draft | :edit | :inline_content

options()

@type options() :: keyword() | map()

t()

@opaque t()

A typed Telegram InputRichMessage value. Its representation is opaque.

Functions

blocks(blocks, options \\ [])

@spec blocks(list(), options()) :: t()

Builds a rich message described with Telegram's supported block entities.

Each block is a map or Nadia.InputRichBlock value carrying the official type discriminator. Telegram enforces up to 500 blocks and 16 nesting levels. Nadia validates the 500-block limit locally; block structure is validated by Telegram.

html(content, options \\ [])

@spec html(binary(), options()) :: t()

Builds a rich message described with Telegram's supported HTML formatting.

The source must be valid UTF-8 and contain at most 32,768 Unicode characters. Empty source is accepted because the Bot API does not document a non-empty minimum.

markdown(content, options \\ [])

@spec markdown(binary(), options()) :: t()

Builds a rich message described with Telegram's supported Markdown formatting.

The source must be valid UTF-8 and contain at most 32,768 Unicode characters. Empty source is accepted because the Bot API does not document a non-empty minimum.

with_media(input_rich_message, media)

@spec with_media(t(), list()) :: t()

Builds a rich message with explicit embedded media plus HTML or Markdown source.

Media are referenced from the source with tg://photo?id=, tg://video?id=, tg://document?id=, or tg://audio?id= links. Each media entry is a map with id and media keys, a Nadia.InputRichMessageMedia value, or a Nadia.InputMedia value (whose id is derived from media). Nadia validates the 50-media limit, unique non-empty ASCII ids where given, and typed media values; the referenced media types are validated by Telegram.