Builder for document payloads.
This module provides a fluent API for sending documents (files) from URLs, file paths, or Telegram file IDs. Documents can include captions and parse modes.
Examples
# Send document from URL
ctx
|> Document.url("https://example.com/report.pdf")
|> Document.caption("Monthly Report")
|> Document.send(chat_id)
# Send document from local file
ctx
|> Document.path("/path/to/file.pdf")
|> Document.caption("Important document", "Markdown")
|> Document.send(chat_id)
# Send document silently
ctx
|> Document.path("/path/to/file.pdf")
|> Document.silent()
|> Document.send(chat_id)
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.
Functions
Sets the document caption.
Parameters
ctx- Context mapcaption- Caption text
Returns
Updated context map with caption set.
Sets the document caption with parse mode.
Parameters
ctx- Context mapcaption- Caption textparse_mode- Parse mode ("Markdown", "MarkdownV2", or "HTML")
Returns
Updated context map with caption and parse mode set.
Sets the document from a local file path.
Parameters
ctx- Context mappath- Path to the document file
Returns
Updated context map with document file content set.
Sends the document to the specified chat.
Parameters
ctx- Context map with accumulated document dataid- Chat ID to send the document to
Returns
:ok- Document sent successfully{:error, reason}- Failed to send document
Sends the document without notification sound.
Parameters
ctx- Context map
Returns
Updated context map with silent flag set.
Sets the document from a URL.
Parameters
ctx- Context mapurl- URL of the document
Returns
Updated context map with document URL set.