TelegramEx.Builder.Video (TelegramEx v1.2.1)

Copy Markdown View Source

Builder for video payloads.

This module provides a fluent API for sending videos from URLs, file paths, or Telegram file IDs. Videos can include duration, cover images, and other options.

Examples

# Send video from local file
ctx
|> Video.path("/tmp/video.mp4")
|> Video.duration(120)
|> Video.send(chat_id)

# Send video from URL with cover
ctx
|> Video.url("https://example.com/video.mp4")
|> Video.cover_url("https://example.com/cover.jpg")
|> Video.send(chat_id)

# Send video by file ID
ctx
|> Video.id("example_file_id")
|> Video.send(chat_id)

Summary

Functions

Sets the video cover image from a local file path.

Sets the video cover image from a URL.

Sets the video duration in seconds.

Sets the video by Telegram file ID.

Sets the video from a local file path.

Sends the video to the specified chat.

Sends the video without notification sound.

Sets the video from a URL.

Functions

cover_path(ctx, path)

@spec cover_path(map(), String.t()) :: map()

Sets the video cover image from a local file path.

Parameters

  • ctx - Context map
  • path - Path to the cover image file

Returns

Updated context map with cover image content set.

cover_url(ctx, url)

@spec cover_url(map(), String.t()) :: map()

Sets the video cover image from a URL.

Parameters

  • ctx - Context map
  • url - URL of the cover image

Returns

Updated context map with cover image URL set.

duration(ctx, seconds)

@spec duration(map(), integer()) :: map()

Sets the video duration in seconds.

Parameters

  • ctx - Context map
  • seconds - Duration in seconds

Returns

Updated context map with duration set.

id(ctx, id)

@spec id(map(), String.t()) :: map()

Sets the video by Telegram file ID.

Parameters

  • ctx - Context map
  • id - Telegram file ID

Returns

Updated context map with video ID set.

path(ctx, path)

@spec path(map(), String.t()) :: map()

Sets the video from a local file path.

Parameters

  • ctx - Context map
  • path - Path to the video file

Returns

Updated context map with video file content set.

send(ctx, id)

@spec send(map(), integer()) :: :ok | {:error, term()}

Sends the video to the specified chat.

Parameters

  • ctx - Context map with accumulated video data
  • id - Chat ID to send the video to

Returns

  • :ok - Video sent successfully
  • {:error, reason} - Failed to send video

silent(ctx)

@spec silent(map()) :: map()

Sends the video without notification sound.

Parameters

  • ctx - Context map

Returns

Updated context map with silent flag set.

url(ctx, url)

@spec url(map(), String.t()) :: map()

Sets the video from a URL.

Parameters

  • ctx - Context map
  • url - URL of the video

Returns

Updated context map with video URL set.