-module(telega@reply). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/telega/reply.gleam"). -export([with_text/2, with_markup/3, with_formatted/2, with_html/2, with_markdown/2, with_markdown_v2/2, with_formatted_markup/3, with_dice/2, with_photo/3, edit_text/2, edit_text_formatted/3, forward/2, answer_callback_query/2, with_file_link/2, with_poll/3, with_invoice/6, with_sticker/2, with_media_group/2, with_paid_media/3]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " `reply` provides a convenient way to send messages to the active chat.\n" " It uses the `Context` object to access the chat ID and other necessary information.\n" ). -file("src/telega/reply.gleam", 29). ?DOC( " Use this method to send text messages.\n" "\n" " Uses the client's default parse mode if one is configured\n" " via `client.set_default_parse_mode`.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendmessage\n" ). -spec with_text(telega@bot:context(any(), any(), any()), binary()) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_text(Ctx, Text) -> telega@api:send_message( erlang:element(5, erlang:element(4, Ctx)), {send_message_parameters, none, {str, erlang:element(2, Ctx)}, none, Text, telega@client:default_parse_mode_string( erlang:element(5, erlang:element(4, Ctx)) ), none, none, none, none, none, none, none, none} ). -file("src/telega/reply.gleam", 59). ?DOC( " Use this method to send text messages with keyboard markup.\n" "\n" " Uses the client's default parse mode if one is configured\n" " via `client.set_default_parse_mode`.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendmessage\n" ). -spec with_markup( telega@bot:context(any(), any(), any()), binary(), telega@model@types:send_message_reply_markup_parameters() ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_markup(Ctx, Text, Reply_markup) -> telega@api:send_message( erlang:element(5, erlang:element(4, Ctx)), {send_message_parameters, none, {str, erlang:element(2, Ctx)}, none, Text, telega@client:default_parse_mode_string( erlang:element(5, erlang:element(4, Ctx)) ), none, none, none, none, none, none, none, {some, Reply_markup}} ). -file("src/telega/reply.gleam", 95). ?DOC( " Use this method to send formatted text messages.\n" "\n" " ## Example\n" " ```gleam\n" " let formatted = format.build()\n" " |> format.bold_text(\"Important!\")\n" " |> format.to_formatted()\n" " reply.with_formatted(ctx, formatted)\n" " ```\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendmessage\n" ). -spec with_formatted( telega@bot:context(any(), any(), any()), telega@format:formatted_text() ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_formatted(Ctx, Formatted) -> {Text, Parse_mode} = telega@format:render(Formatted), telega@api:send_message( erlang:element(5, erlang:element(4, Ctx)), {send_message_parameters, none, {str, erlang:element(2, Ctx)}, none, Text, {some, telega@format:parse_mode_to_string(Parse_mode)}, none, none, none, none, none, none, none, none} ). -file("src/telega/reply.gleam", 130). ?DOC( " Use this method to send HTML formatted text messages.\n" "\n" " ## Example\n" " ```gleam\n" " let html = format.bold(\"Hello\") <> \" \" <> format.italic(\"World\")\n" " reply.with_html(ctx, html)\n" " ```\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendmessage\n" ). -spec with_html(telega@bot:context(any(), any(), any()), binary()) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_html(Ctx, Html) -> telega@api:send_message( erlang:element(5, erlang:element(4, Ctx)), {send_message_parameters, none, {str, erlang:element(2, Ctx)}, none, Html, {some, <<"HTML"/utf8>>}, none, none, none, none, none, none, none, none} ). -file("src/telega/reply.gleam", 162). ?DOC( " Use this method to send Markdown formatted text messages.\n" "\n" " ## Example\n" " ```gleam\n" " reply.with_markdown(ctx, \"*Bold* _Italic_\")\n" " ```\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendmessage\n" ). -spec with_markdown(telega@bot:context(any(), any(), any()), binary()) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_markdown(Ctx, Markdown) -> telega@api:send_message( erlang:element(5, erlang:element(4, Ctx)), {send_message_parameters, none, {str, erlang:element(2, Ctx)}, none, Markdown, {some, <<"Markdown"/utf8>>}, none, none, none, none, none, none, none, none} ). -file("src/telega/reply.gleam", 194). ?DOC( " Use this method to send MarkdownV2 formatted text messages.\n" "\n" " ## Example\n" " ```gleam\n" " reply.with_markdown_v2(ctx, \"*Bold* _Italic_ __Underline__\")\n" " ```\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendmessage\n" ). -spec with_markdown_v2(telega@bot:context(any(), any(), any()), binary()) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_markdown_v2(Ctx, Markdown) -> telega@api:send_message( erlang:element(5, erlang:element(4, Ctx)), {send_message_parameters, none, {str, erlang:element(2, Ctx)}, none, Markdown, {some, <<"MarkdownV2"/utf8>>}, none, none, none, none, none, none, none, none} ). -file("src/telega/reply.gleam", 221). ?DOC( " Use this method to send formatted text messages with keyboard markup.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendmessage\n" ). -spec with_formatted_markup( telega@bot:context(any(), any(), any()), telega@format:formatted_text(), telega@model@types:send_message_reply_markup_parameters() ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_formatted_markup(Ctx, Formatted, Reply_markup) -> {Text, Parse_mode} = telega@format:render(Formatted), telega@api:send_message( erlang:element(5, erlang:element(4, Ctx)), {send_message_parameters, none, {str, erlang:element(2, Ctx)}, none, Text, {some, telega@format:parse_mode_to_string(Parse_mode)}, none, none, none, none, none, none, none, {some, Reply_markup}} ). -file("src/telega/reply.gleam", 251). ?DOC( " Use this method to send an animated emoji that will display a random value.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#senddice\n" ). -spec with_dice( telega@bot:context(any(), any(), any()), gleam@option:option(telega@model@types:send_dice_parameters()) ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_dice(Ctx, Parameters) -> Parameters@1 = begin _pipe = Parameters, gleam@option:lazy_unwrap( _pipe, fun() -> {send_dice_parameters, {str, erlang:element(2, Ctx)}, none, none, none, none, none} end ) end, telega@api:send_dice( erlang:element(5, erlang:element(4, Ctx)), Parameters@1 ). -file("src/telega/reply.gleam", 282). ?DOC( " Use this method to send a photo — by `file_id`, URL, or upload.\n" "\n" " The caption uses the client's default parse mode if one is configured\n" " via `client.set_default_parse_mode`.\n" "\n" " ## Example\n" " ```gleam\n" " reply.with_photo(ctx, types.StringV(\"https://example.com/cat.jpg\"), Some(\"A cat\"))\n" " ```\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendphoto\n" ). -spec with_photo( telega@bot:context(any(), any(), any()), telega@model@types:file_or_string(), gleam@option:option(binary()) ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_photo(Ctx, Photo, Caption) -> telega@api:send_photo( erlang:element(5, erlang:element(4, Ctx)), {send_photo_parameters, {str, erlang:element(2, Ctx)}, none, none, Photo, Caption, gleam@option:then( Caption, fun(_) -> telega@client:default_parse_mode_string( erlang:element(5, erlang:element(4, Ctx)) ) end ), none, none, none, none, none, none, none, none, none} ). -file("src/telega/reply.gleam", 318). ?DOC( " Use this method to edit text and game messages.\n" " On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.\n" "\n" " If `parameters.parse_mode` is `None`, the client's default parse mode\n" " (set via `client.set_default_parse_mode`) is used.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#editmessagetext\n" ). -spec edit_text( telega@bot:context(any(), any(), any()), telega@model@types:edit_message_text_parameters() ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. edit_text(Ctx, Parameters) -> Parameters@1 = case erlang:element(6, Parameters) of none -> {edit_message_text_parameters, erlang:element(2, Parameters), erlang:element(3, Parameters), erlang:element(4, Parameters), erlang:element(5, Parameters), telega@client:default_parse_mode_string( erlang:element(5, erlang:element(4, Ctx)) ), erlang:element(7, Parameters), erlang:element(8, Parameters), erlang:element(9, Parameters)}; {some, _} -> Parameters end, telega@api:edit_message_text( erlang:element(5, erlang:element(4, Ctx)), Parameters@1 ). -file("src/telega/reply.gleam", 336). ?DOC( " Use this method to edit formatted text messages.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#editmessagetext\n" ). -spec edit_text_formatted( telega@bot:context(any(), any(), any()), integer(), telega@format:formatted_text() ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. edit_text_formatted(Ctx, Message_id, Formatted) -> {Text, Parse_mode} = telega@format:render(Formatted), Parameters = {edit_message_text_parameters, {some, {str, erlang:element(2, Ctx)}}, {some, Message_id}, none, Text, {some, telega@format:parse_mode_to_string(Parse_mode)}, none, none, none}, telega@api:edit_message_text( erlang:element(5, erlang:element(4, Ctx)), Parameters ). -file("src/telega/reply.gleam", 362). ?DOC( " Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded.\n" " On success, the sent Message is returned.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#forwardmessage\n" ). -spec forward( telega@bot:context(any(), any(), any()), telega@model@types:forward_message_parameters() ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. forward(Ctx, Parameters) -> telega@api:forward_message( erlang:element(5, erlang:element(4, Ctx)), Parameters ). -file("src/telega/reply.gleam", 374). ?DOC( " Use this method to send answers to callback queries sent from inline keyboards.\n" " The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.\n" " On success, _True_ is returned.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#answercallbackquery\n" ). -spec answer_callback_query( telega@bot:context(any(), any(), any()), telega@model@types:answer_callback_query_parameters() ) -> {ok, boolean()} | {error, telega@error:telega_error()}. answer_callback_query(Ctx, Parameters) -> telega@api:answer_callback_query( erlang:element(5, erlang:element(4, Ctx)), Parameters ). -file("src/telega/reply.gleam", 382). ?DOC(" Get download link for the file.\n"). -spec with_file_link(telega@bot:context(any(), any(), any()), binary()) -> {ok, binary()} | {error, telega@error:telega_error()}. with_file_link(Ctx, File_id) -> gleam@result:'try'( telega@api:get_file(erlang:element(5, erlang:element(4, Ctx)), File_id), fun(File) -> gleam@result:'try'( gleam@option:to_result( erlang:element(5, File), file_not_found_error ), fun(File_path) -> {ok, <<<<<<<<(telega@client:get_api_url( erlang:element( 5, erlang:element(4, Ctx) ) ))/binary, "/file/bot"/utf8>>/binary, (erlang:element(4, erlang:element(4, Ctx)))/binary>>/binary, "/"/utf8>>/binary, File_path/binary>>} end ) end ). -file("src/telega/reply.gleam", 404). ?DOC( " Use this method to send a native poll.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendpoll\n" ). -spec with_poll( telega@bot:context(any(), any(), any()), binary(), list(binary()) ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_poll(Ctx, Question, Options) -> telega@api:send_poll( erlang:element(5, erlang:element(4, Ctx)), {send_poll_parameters, {str, erlang:element(2, Ctx)}, none, none, Question, none, none, Options, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none} ). -file("src/telega/reply.gleam", 453). ?DOC( " Use this method to send an invoice.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendinvoice\n" ). -spec with_invoice( telega@bot:context(any(), any(), any()), binary(), binary(), binary(), binary(), list({binary(), integer()}) ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_invoice(Ctx, Title, Description, Payload, Currency, Prices) -> telega@api:send_invoice( erlang:element(5, erlang:element(4, Ctx)), {send_invoice_parameters, {str, erlang:element(2, Ctx)}, none, Title, Description, Payload, none, Currency, gleam@list:map( Prices, fun(Price) -> {Label, Amount} = Price, {labeled_price, Label, Amount} end ), none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none} ). -file("src/telega/reply.gleam", 503). ?DOC( " Use this method to send a sticker.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendsticker\n" ). -spec with_sticker( telega@bot:context(any(), any(), any()), telega@model@types:file_or_string() ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_sticker(Ctx, Sticker) -> telega@api:send_sticker( erlang:element(5, erlang:element(4, Ctx)), {send_sticker_parameters, {str, erlang:element(2, Ctx)}, none, none, Sticker, none, none, none, none, none, none, none} ). -file("src/telega/reply.gleam", 546). ?DOC( " Use this method to send a group of photos, videos, documents or audios as an album.\n" " Documents and audio files can be only grouped in an album with messages of the same type.\n" " Returns a list of messages that were sent.\n" "\n" " ## Example\n" " ```gleam\n" " let media_group = media_group.new()\n" " |> media_group.add_photo(\"https://example.com/photo1.jpg\", None)\n" " |> media_group.add_photo(\"https://example.com/photo2.jpg\", Some(\n" " media_group.PhotoOptions(\n" " caption: Some(\"Second photo\"),\n" " parse_mode: Some(\"Markdown\"),\n" " ..media_group.default_photo_options()\n" " )\n" " ))\n" " |> media_group.build()\n" "\n" " reply.with_media_group(ctx, media_group)\n" " ```\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendmediagroup\n" ). -spec with_media_group( telega@bot:context(any(), any(), any()), list(telega@model@types:input_media()) ) -> {ok, list(telega@model@types:message())} | {error, telega@error:telega_error()}. with_media_group(Ctx, Media) -> telega@api:send_media_group( erlang:element(5, erlang:element(4, Ctx)), {send_media_group_parameters, {str, erlang:element(2, Ctx)}, none, none, Media, none, none, none, none, none} ). -file("src/telega/reply.gleam", 583). ?DOC( " Use this method to send paid media — photos and videos that the user must\n" " pay Telegram Stars to unlock.\n" "\n" " Uses the client's default parse mode if one is configured\n" " via `client.set_default_parse_mode`.\n" "\n" " ## Example\n" " ```gleam\n" " reply.with_paid_media(ctx, star_count: 10, media: [\n" " types.InputPaidMediaPhotoInputPaidMedia(types.InputPaidMediaPhoto(\n" " type_: \"photo\",\n" " media: \"https://example.com/photo.jpg\",\n" " )),\n" " ])\n" " ```\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendpaidmedia\n" ). -spec with_paid_media( telega@bot:context(any(), any(), any()), integer(), list(telega@model@types:input_paid_media()) ) -> {ok, telega@model@types:message()} | {error, telega@error:telega_error()}. with_paid_media(Ctx, Star_count, Media) -> telega@api:send_paid_media( erlang:element(5, erlang:element(4, Ctx)), {send_paid_media_parameters, none, {str, erlang:element(2, Ctx)}, Star_count, Media, none, none, telega@client:default_parse_mode_string( erlang:element(5, erlang:element(4, Ctx)) ), none, none, none, none, none, none, none} ).