telega/reply

reply provides a convenient way to send messages to the active chat. It uses the Context object to access the chat ID and other necessary information.

Values

pub fn answer_callback_query(
  ctx ctx: bot.Context(session, error),
  parameters parameters: types.AnswerCallbackQueryParameters,
) -> Result(Bool, error.TelegaError)

Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.

Official reference: https://core.telegram.org/bots/api#answercallbackquery

pub fn edit_text(
  ctx ctx: bot.Context(session, error),
  parameters parameters: types.EditMessageTextParameters,
) -> Result(types.Message, error.TelegaError)

Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

Official reference: https://core.telegram.org/bots/api#editmessagetext

pub fn edit_text_formatted(
  ctx ctx: bot.Context(session, error),
  message_id message_id: Int,
  formatted formatted: format.FormattedText,
) -> Result(types.Message, error.TelegaError)

Use this method to edit formatted text messages.

Official reference: https://core.telegram.org/bots/api#editmessagetext

pub fn forward(
  ctx ctx: bot.Context(session, error),
  parameters parameters: types.ForwardMessageParameters,
) -> Result(types.Message, error.TelegaError)

Use this method to forward messages of any kind. Service messages and messages with protected content can’t be forwarded. On success, the sent Message is returned.

Official reference: https://core.telegram.org/bots/api#forwardmessage

pub fn with_dice(
  ctx ctx: bot.Context(session, error),
  parameters parameters: option.Option(types.SendDiceParameters),
) -> Result(types.Message, error.TelegaError)

Use this method to send an animated emoji that will display a random value.

Official reference: https://core.telegram.org/bots/api#senddice

pub fn with_file_link(
  ctx ctx: bot.Context(session, error),
  file_id file_id: String,
) -> Result(String, error.TelegaError)

Get download link for the file.

pub fn with_formatted(
  ctx ctx: bot.Context(session, error),
  formatted formatted: format.FormattedText,
) -> Result(types.Message, error.TelegaError)

Use this method to send formatted text messages.

Example

let formatted = format.build()
  |> format.bold_text("Important!")
  |> format.to_formatted()
reply.with_formatted(ctx, formatted)

Official reference: https://core.telegram.org/bots/api#sendmessage

pub fn with_formatted_markup(
  ctx ctx: bot.Context(session, error),
  formatted formatted: format.FormattedText,
  markup reply_markup: types.SendMessageReplyMarkupParameters,
) -> Result(types.Message, error.TelegaError)

Use this method to send formatted text messages with keyboard markup.

Official reference: https://core.telegram.org/bots/api#sendmessage

pub fn with_html(
  ctx ctx: bot.Context(session, error),
  html html: String,
) -> Result(types.Message, error.TelegaError)

Use this method to send HTML formatted text messages.

Example

let html = format.bold("Hello") <> " " <> format.italic("World")
reply.with_html(ctx, html)

Official reference: https://core.telegram.org/bots/api#sendmessage

pub fn with_invoice(
  ctx ctx: bot.Context(session, error),
  title title: String,
  description description: String,
  payload payload: String,
  currency currency: String,
  prices prices: List(#(String, Int)),
) -> Result(types.Message, error.TelegaError)

Use this method to send an invoice.

Official reference: https://core.telegram.org/bots/api#sendinvoice

pub fn with_markdown(
  ctx ctx: bot.Context(session, error),
  markdown markdown: String,
) -> Result(types.Message, error.TelegaError)

Use this method to send Markdown formatted text messages.

Example

reply.with_markdown(ctx, "*Bold* _Italic_")

Official reference: https://core.telegram.org/bots/api#sendmessage

pub fn with_markdown_v2(
  ctx ctx: bot.Context(session, error),
  markdown markdown: String,
) -> Result(types.Message, error.TelegaError)

Use this method to send MarkdownV2 formatted text messages.

Example

reply.with_markdown_v2(ctx, "*Bold* _Italic_ __Underline__")

Official reference: https://core.telegram.org/bots/api#sendmessage

pub fn with_markup(
  ctx ctx: bot.Context(session, error),
  text text: String,
  markup reply_markup: types.SendMessageReplyMarkupParameters,
) -> Result(types.Message, error.TelegaError)

Use this method to send text messages with keyboard markup.

Official reference: https://core.telegram.org/bots/api#sendmessage

pub fn with_media_group(
  ctx ctx: bot.Context(session, error),
  media media: List(types.InputMedia),
) -> Result(List(types.Message), error.TelegaError)

Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. Returns a list of messages that were sent.

Example

let media_group = media_group.new()
  |> media_group.add_photo("https://example.com/photo1.jpg", None)
  |> media_group.add_photo("https://example.com/photo2.jpg", Some(
    media_group.PhotoOptions(
      caption: Some("Second photo"),
      parse_mode: Some("Markdown"),
      ..media_group.default_photo_options()
    )
  ))
  |> media_group.build()

reply.with_media_group(ctx, media_group)

Official reference: https://core.telegram.org/bots/api#sendmediagroup

pub fn with_poll(
  ctx ctx: bot.Context(session, error),
  question question: String,
  options options: List(String),
) -> Result(types.Message, error.TelegaError)

Use this method to send a native poll.

Official reference: https://core.telegram.org/bots/api#sendpoll

pub fn with_sticker(
  ctx ctx: bot.Context(session, error),
  sticker sticker: types.FileOrString,
) -> Result(types.Message, error.TelegaError)

Use this method to send a sticker.

Official reference: https://core.telegram.org/bots/api#sendsticker

pub fn with_text(
  ctx ctx: bot.Context(session, error),
  text text: String,
) -> Result(types.Message, error.TelegaError)

Use this method to send text messages.

Official reference: https://core.telegram.org/bots/api#sendmessage

Search Document