-module(telega@reply). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -define(FILEPATH, "src/telega/reply.gleam"). -export([with_text/2, with_markup/3, with_dice/2, edit_text/2, forward/2, answer_callback_query/2, with_file_link/2, with_poll/3, with_invoice/6, with_sticker/2]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -file("src/telega/reply.gleam", 16). ?DOC( " Use this method to send text messages.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendmessage\n" ). -spec with_text(telega@bot:context(any(), any()), binary()) -> {ok, telega@model: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, none, none, none, none, none, none, none, none, none} ). -file("src/telega/reply.gleam", 43). ?DOC( " Use this method to send text messages with keyboard markup.\n" "\n" " **Official reference:** https://core.telegram.org/bots/api#sendmessage\n" ). -spec with_markup( telega@bot:context(any(), any()), binary(), telega@model:send_message_reply_markup_parameters() ) -> {ok, telega@model: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, none, none, none, none, none, none, none, none, {some, Reply_markup}} ). -file("src/telega/reply.gleam", 71). ?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()), gleam@option:option(telega@model:send_dice_parameters()) ) -> {ok, telega@model: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", 95). ?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" " **Official reference:** https://core.telegram.org/bots/api#editmessagetext\n" ). -spec edit_text( telega@bot:context(any(), any()), telega@model:edit_message_text_parameters() ) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}. edit_text(Ctx, Parameters) -> telega@api:edit_message_text( erlang:element(5, erlang:element(4, Ctx)), Parameters ). -file("src/telega/reply.gleam", 106). ?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()), telega@model:forward_message_parameters() ) -> {ok, telega@model: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", 118). ?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()), telega@model: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", 126). ?DOC(" Get download link for the file.\n"). -spec with_file_link(telega@bot:context(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", 148). ?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()), binary(), list(binary())) -> {ok, telega@model: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} ). -file("src/telega/reply.gleam", 186). ?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()), binary(), binary(), binary(), binary(), list({binary(), integer()}) ) -> {ok, telega@model: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", 236). ?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()), telega@model:file_or_string() ) -> {ok, telega@model: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} ).