TelegramEx.Builder.Location (TelegramEx v1.2.1)

Copy Markdown View Source

Builder for location payloads.

This module provides a fluent API for sending geographic coordinates.

Examples

# Send location coordinates
ctx
|> Location.coordinates(40.7128, -74.0060)
|> Location.send(chat_id)

# Send location silently
ctx
|> Location.coordinates(55.7558, 37.6173)
|> Location.silent()
|> Location.send(chat_id)

Summary

Functions

Sets the geographic coordinates.

Sends the location to the specified chat.

Sends the location without notification sound.

Functions

coordinates(ctx, lat, lng)

@spec coordinates(map(), float(), float()) :: map()

Sets the geographic coordinates.

Parameters

  • ctx - Context map
  • lat - Latitude
  • lng - Longitude

Returns

Updated context map with coordinates set.

Examples

# New York City coordinates
ctx
|> Location.coordinates(40.7128, -74.0060)
|> Location.send(chat_id)

send(ctx, id)

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

Sends the location to the specified chat.

Parameters

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

Returns

  • :ok - Location sent successfully
  • {:error, reason} - Failed to send location

silent(ctx)

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

Sends the location without notification sound.

Parameters

  • ctx - Context map

Returns

Updated context map with silent flag set.