TelegramEx.Builder.Document (TelegramEx v1.3.0)

Copy Markdown View Source

Builder for document payloads.

Supports URLs, local file paths, captions, parse modes, and silent sends. See Messages and Media.

Summary

Functions

Sets the document caption.

Sets the document caption with parse mode.

Sets the document from a local file path.

Sends the document to the specified chat.

Sends the document without notification sound.

Sets the document from a URL.

Types

input()

@type input() :: map() | TelegramEx.Effect.t()

Functions

caption(input, caption)

@spec caption(input(), String.t()) :: TelegramEx.Effect.t()

Sets the document caption.

Accepts a handler context or an existing TelegramEx.Effect and returns an effect with :caption stored in the payload.

Parameters

  • input - Context map or effect
  • caption - Caption text

Returns

TelegramEx.Effect with :caption stored in the payload.

caption(input, caption, parse_mode)

@spec caption(input(), String.t(), String.t()) :: TelegramEx.Effect.t()

Sets the document caption with parse mode.

Accepts a handler context or an existing TelegramEx.Effect and returns an effect with :caption and :parse_mode stored in the payload.

Parameters

  • input - Context map or effect
  • caption - Caption text
  • parse_mode - Parse mode ("Markdown", "MarkdownV2", or "HTML")

Returns

TelegramEx.Effect with :caption and :parse_mode stored in the payload.

path(input, path)

@spec path(input(), String.t()) :: TelegramEx.Effect.t()

Sets the document from a local file path.

If the file cannot be read, the returned effect contains {:file, reason} as its error.

Parameters

  • input - Context map or effect
  • path - Path to the document file

Returns

TelegramEx.Effect with :document stored in the payload, or a file-read error.

send(input, id)

@spec send(input(), integer()) :: TelegramEx.Effect.t()

Sends the document to the specified chat.

The returned effect contains an API error if the request fails.

Parameters

  • input - Context map or effect with accumulated document data
  • id - Chat ID to send the document to

Returns

TelegramEx.Effect with the request result encoded in the effect state.

silent(input)

@spec silent(input()) :: TelegramEx.Effect.t()

Sends the document without notification sound.

Accepts a handler context or an existing TelegramEx.Effect and returns an effect with :disable_notification stored in the payload.

Parameters

  • input - Context map or effect

Returns

TelegramEx.Effect with :disable_notification stored in the payload.

url(input, url)

@spec url(input(), String.t()) :: TelegramEx.Effect.t()

Sets the document from a URL.

Accepts a handler context or an existing TelegramEx.Effect and returns an effect with :document stored in the payload.

Parameters

  • input - Context map or effect
  • url - URL of the document

Returns

TelegramEx.Effect with :document stored in the payload.