Builder for photo payloads.
This module provides a fluent API for sending photos from URLs, file paths, or Telegram file IDs. Photos can include captions, parse modes, and other options.
Examples
# Send photo from URL
ctx
|> Photo.url("https://example.com/image.jpg")
|> Photo.caption("Look at this")
|> Photo.send(chat_id)
# Send photo from local file
ctx
|> Photo.path("/path/to/image.jpg")
|> Photo.caption("Local photo", "Markdown")
|> Photo.send(chat_id)
# Send photo silently
ctx
|> Photo.url("https://example.com/image.jpg")
|> Photo.silent()
|> Photo.send(chat_id)
Summary
Functions
Sets the photo caption.
Sets the photo caption with parse mode.
Sets the photo from a local file path.
Sends the photo to the specified chat.
Sends the photo without notification sound.
Sets the photo from a URL.
Functions
Sets the photo caption.
Parameters
ctx- Context mapcaption- Caption text
Returns
Updated context map with caption set.
Examples
ctx
|> Photo.url("https://example.com/photo.jpg")
|> Photo.caption("Beautiful sunset")
|> Photo.send(chat_id)
Sets the photo 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.
Examples
ctx
|> Photo.url("https://example.com/photo.jpg")
|> Photo.caption("*Bold* caption", "Markdown")
|> Photo.send(chat_id)
Sets the photo from a local file path.
Parameters
ctx- Context mappath- Path to the photo file
Returns
Updated context map with photo file content set.
Examples
ctx
|> Photo.path("/tmp/photo.jpg")
|> Photo.send(chat_id)
Sends the photo to the specified chat.
Parameters
ctx- Context map with accumulated photo dataid- Chat ID to send the photo to
Returns
:ok- Photo sent successfully{:error, reason}- Failed to send photo
Examples
ctx
|> Photo.url("https://example.com/photo.jpg")
|> Photo.send(chat_id)
Sends the photo without notification sound.
Parameters
ctx- Context map
Returns
Updated context map with silent flag set.
Examples
ctx
|> Photo.url("https://example.com/photo.jpg")
|> Photo.silent()
|> Photo.send(chat_id)
Sets the photo from a URL.
Parameters
ctx- Context mapurl- URL of the photo
Returns
Updated context map with photo URL set.
Examples
ctx
|> Photo.url("https://example.com/photo.jpg")
|> Photo.send(chat_id)