plugins/gateways/telegram/sender

Telegram message sender. Sends messages via telega with MarkdownV2 formatting and plain-text fallback.

Types

pub type SendResult {
  Sent
  ParseErrorSentPlain(text: String)
  SendFailed(reason: String)
}

Constructors

  • Sent
  • ParseErrorSentPlain(text: String)
  • SendFailed(reason: String)

Values

pub fn answer_callback_toast(
  ctx: bot.Context(a, b),
  callback_query_id: String,
  text: String,
) -> Result(Nil, String)

Answer a callback query with a toast notification.

pub fn edit_formatted_remove_keyboard(
  ctx: bot.Context(a, b),
  message_id: Int,
  formatted: format.FormattedText,
) -> Result(Nil, String)

Remove inline keyboard and update text on a message, with formatting.

pub fn edit_remove_keyboard(
  ctx: bot.Context(a, b),
  message_id: Int,
  text: String,
) -> Result(Nil, String)

Remove inline keyboard and update text on a message.

pub fn log_send(
  log: behaviours.Logger,
  chat_id: String,
  text: String,
) -> Nil

Log that a message would be sent (for CLI development).

pub fn react_to_msg(
  ctx: bot.Context(a, b),
  message_id: Int,
  emoji: String,
) -> Result(Nil, String)

React to a specific message with an emoji (unicode).

pub fn send(ctx: bot.Context(a, b), text: String) -> SendResult

Send a MarkdownV2-formatted reply using the telega Context. Falls back to plain text if MarkdownV2 parsing fails.

The Context type is telega’s bot.Context — it carries the chat_id, bot client, and session data needed for sending messages.

pub fn send_formatted_with_buttons(
  ctx: bot.Context(a, b),
  formatted: format.FormattedText,
  callback_prefix: String,
  buttons: List(#(String, String)),
) -> Result(Nil, String)

Send a formatted message with inline keyboard buttons. Uses telega’s FormattedText for bold, code blocks, etc.

pub fn send_typing(ctx: bot.Context(a, b)) -> Nil

Send a typing indicator via the Telegram sendChatAction API. Should be called before a potentially long-running operation (e.g., LLM call) so the user sees the “…” typing animation while waiting.

pub fn send_with_inline_buttons(
  ctx: bot.Context(a, b),
  text: String,
  callback_prefix: String,
  buttons: List(#(String, String)),
) -> Result(Nil, String)

Send a plain-text message with inline keyboard buttons. Each button is a pair of (label, callback_data_suffix). The callback_prefix identifies this keyboard (e.g. “approval”). On the wire, callback data is “prefix:suffix”.

Search Document