Current section

Files

Jump to
telega src telega@api.erl
Raw

src/telega@api.erl

-module(telega@api).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([send_audio/2, approve_chat_join_request/2, set_webhook/2, get_webhook_info/1, delete_webhook/1, delete_webhook_and_drop_updates/1, log_out/1, close/1, send_message/2, set_my_commands/3, delete_my_commands/2, get_my_commands/2, send_dice/2, get_me/1, answer_callback_query/2, forward_message/2, set_chat_menu_button/2, get_updates/2, forward_messages/2, copy_message/2, copy_messages/2, send_photo/2, send_document/2, send_video/2, send_animation/2, send_voice/2, send_video_note/2, send_media_group/2, send_location/2, send_venue/2, send_contact/2, send_poll/2, send_chat_action/2, send_invoice/2, create_invoice_link/2, set_message_reaction/2, get_user_profile_photos/2, send_sticker/2, get_sticker_set/2, edit_message_text/2, edit_message_caption/2, edit_message_media/2, edit_message_live_location/2, stop_message_live_location/2, edit_message_reply_markup/2, stop_poll/2, delete_message/2, delete_messages/2, get_chat/2, get_file/2, ban_chat_member/2, unban_chat_member/2, restrict_chat_member/2, promote_chat_member/2, set_chat_administrator_custom_title/2, ban_chat_sender_chat/2, unban_chat_sender_chat/2, set_chat_permissions/2, export_chat_invite_link/2, create_chat_invite_link/2, edit_chat_invite_link/2, create_chat_subscription_invite_link/2, edit_chat_subscription_invite_link/2, revoke_chat_invite_link/2, decline_chat_join_request/2, set_chat_photo/2, delete_chat_photo/2]).
-export_type([api_response/1]).
-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(
" This module provides an interface for interacting with the Telegram Bot API.\n"
" It will be useful if you want to interact with the Telegram Bot API directly, without running a bot.\n"
" But it will be more convenient to use the `reply` module in bot handlers.\n"
).
-type api_response(ANHN) :: {api_success_response, boolean(), ANHN} |
{api_error_response, boolean(), integer(), binary()}.
-file("src/telega/api.gleam", 330).
?DOC(
" Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.\n"
"\n"
" For sending voice messages, use the [sendVoice](https://core.telegram.org/bots/api#sendvoice) method instead.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendaudio\n"
).
-spec send_audio(
telega@client:telegram_client(),
telega@model:send_audio_parameters()
) -> {ok, gleam@http@response:response(binary())} |
{error, telega@error:telega_error()}.
send_audio(Client, Parameters) ->
Body_json = telega@model:encode_send_audio_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendAudio"/utf8>>,
gleam@json:to_string(Body_json)
),
telega@client:fetch(_pipe, Client).
-file("src/telega/api.gleam", 959).
?DOC(
" Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the `can_invite_users` administrator right. Returns `True` on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#approvechatjoinrequest\n"
).
-spec approve_chat_join_request(
telega@client:telegram_client(),
telega@model:approve_chat_join_request_parameters()
) -> {ok, gleam@http@response:response(binary())} |
{error, telega@error:telega_error()}.
approve_chat_join_request(Client, Parameters) ->
Body_json = telega@model:encode_approve_chat_join_request_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"approveChatJoinRequest"/utf8>>,
gleam@json:to_string(Body_json)
),
telega@client:fetch(_pipe, Client).
-file("src/telega/api.gleam", 1049).
-spec response_decoder(gleam@dynamic@decode:decoder(ANQG)) -> gleam@dynamic@decode:decoder(api_response(ANQG)).
response_decoder(Result_decoder) ->
gleam@dynamic@decode:field(
<<"ok"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Ok) -> case Ok of
true ->
gleam@dynamic@decode:field(
<<"result"/utf8>>,
Result_decoder,
fun(Result) ->
gleam@dynamic@decode:success(
{api_success_response, Ok, Result}
)
end
);
false ->
gleam@dynamic@decode:field(
<<"error_code"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Error_code) ->
gleam@dynamic@decode:field(
<<"description"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Description) ->
gleam@dynamic@decode:success(
{api_error_response,
Ok,
Error_code,
Description}
)
end
)
end
)
end end
).
-file("src/telega/api.gleam", 1036).
-spec parse_api_response(
gleam@dynamic:dynamic_(),
gleam@dynamic@decode:decoder(ANQI)
) -> {ok, api_response(ANQI)} | {error, list(gleam@dynamic:decode_error())}.
parse_api_response(Json, Result_decoder) ->
_pipe = gleam@dynamic@decode:run(Json, response_decoder(Result_decoder)),
gleam@result:map_error(
_pipe,
fun(Errors) ->
gleam@list:map(
Errors,
fun(Error) ->
{decode_error,
erlang:element(2, Error),
erlang:element(3, Error),
erlang:element(4, Error)}
end
)
end
).
-file("src/telega/api.gleam", 1016).
-spec map_response(
{ok, gleam@http@response:response(binary())} |
{error, telega@error:telega_error()},
gleam@dynamic@decode:decoder(ANRL)
) -> {ok, ANRL} | {error, telega@error:telega_error()}.
map_response(Response, Result_decoder) ->
gleam@result:'try'(
Response,
fun(Response@1) ->
_pipe = gleam@json:decode(
erlang:element(4, Response@1),
fun(_capture) ->
parse_api_response(_capture, Result_decoder)
end
),
_pipe@1 = gleam@result:map_error(
_pipe,
fun(Field@0) -> {json_decode_error, Field@0} end
),
gleam@result:then(_pipe@1, fun(Response@2) -> case Response@2 of
{api_success_response, _, Result} ->
{ok, Result};
{api_error_response, _, Error_code, Description} ->
{error,
{telegram_api_error, Error_code, Description}}
end end)
end
).
-file("src/telega/api.gleam", 26).
?DOC(
" Set the webhook URL using [setWebhook](https://core.telegram.org/bots/api#setwebhook) API.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#setwebhook\n"
).
-spec set_webhook(
telega@client:telegram_client(),
telega@model:set_webhook_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
set_webhook(Client, Parameters) ->
Body = telega@model:encode_set_webhook_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"setWebhook"/utf8>>,
gleam@json:to_string(Body)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 37).
?DOC(
" Use this method to get current webhook status.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#getwebhookinfo\n"
).
-spec get_webhook_info(telega@client:telegram_client()) -> {ok,
telega@model:webhook_info()} |
{error, telega@error:telega_error()}.
get_webhook_info(Client) ->
_pipe = telega@client:new_get_request(
Client,
<<"getWebhookInfo"/utf8>>,
none
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:webhook_info_decoder()).
-file("src/telega/api.gleam", 46).
?DOC(
" Use this method to remove webhook integration if you decide to switch back to [getUpdates](https://core.telegram.org/bots/api#getupdates).\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#deletewebhook\n"
).
-spec delete_webhook(telega@client:telegram_client()) -> {ok, boolean()} |
{error, telega@error:telega_error()}.
delete_webhook(Client) ->
_pipe = telega@client:new_get_request(
Client,
<<"deleteWebhook"/utf8>>,
none
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 53).
?DOC(" The same as [delete_webhook](#delete_webhook) but also drops all pending updates.\n").
-spec delete_webhook_and_drop_updates(telega@client:telegram_client()) -> {ok,
boolean()} |
{error, telega@error:telega_error()}.
delete_webhook_and_drop_updates(Client) ->
_pipe = telega@client:new_get_request(
Client,
<<"deleteWebhook"/utf8>>,
{some, [{<<"drop_pending_updates"/utf8>>, <<"true"/utf8>>}]}
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 68).
?DOC(
" Use this method to log out from the cloud Bot API server before launching the bot locally.\n"
" You **must** log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates.\n"
" After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#logout\n"
).
-spec log_out(telega@client:telegram_client()) -> {ok, boolean()} |
{error, telega@error:telega_error()}.
log_out(Client) ->
_pipe = telega@client:new_get_request(Client, <<"logOut"/utf8>>, none),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 79).
?DOC(
" Use this method to close the bot instance before moving it from one local server to another.\n"
" You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart.\n"
" The method will return error 429 in the first 10 minutes after the bot is launched.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#close\n"
).
-spec close(telega@client:telegram_client()) -> {ok, boolean()} |
{error, telega@error:telega_error()}.
close(Client) ->
_pipe = telega@client:new_get_request(Client, <<"close"/utf8>>, none),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 88).
?DOC(
" Use this method to send text messages with additional parameters.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendmessage\n"
).
-spec send_message(
telega@client:telegram_client(),
telega@model:send_message_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_message(Client, Parameters) ->
Body_json = telega@model:encode_send_message_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendMessage"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 103).
?DOC(
" Use this method to change the list of the bot's commands. See [commands documentation](https://core.telegram.org/bots/features#commands) for more details about bot commands.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#setmycommands\n"
).
-spec set_my_commands(
telega@client:telegram_client(),
list(telega@model:bot_command()),
gleam@option:option(telega@model:bot_command_parameters())
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
set_my_commands(Client, Commands, Parameters) ->
Parameters@1 = begin
_pipe = gleam@option:unwrap(
Parameters,
telega@model:default_bot_command_parameters()
),
telega@model:encode_bot_command_parameters(_pipe)
end,
Body_json = gleam@json:object(
[{<<"commands"/utf8>>,
gleam@json:array(
Commands,
fun(Command) ->
gleam@json:object(
[{<<"command"/utf8>>,
gleam@json:string(
erlang:element(2, Command)
)},
{<<"description"/utf8>>,
gleam@json:string(
erlang:element(3, Command)
)} |
Parameters@1]
)
end
)}]
),
_pipe@1 = telega@client:new_post_request(
Client,
<<"setMyCommands"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@2 = telega@client:fetch(_pipe@1, Client),
map_response(_pipe@2, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 139).
?DOC(
" Use this method to delete the list of the bot's commands for the given scope and user language.\n"
" After deletion, [higher level commands](https://core.telegram.org/bots/api#determining-list-of-commands) will be shown to affected users.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#deletemycommands\n"
).
-spec delete_my_commands(
telega@client:telegram_client(),
gleam@option:option(telega@model:bot_command_parameters())
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
delete_my_commands(Client, Parameters) ->
Parameters@1 = begin
_pipe = gleam@option:unwrap(
Parameters,
telega@model:default_bot_command_parameters()
),
telega@model:encode_bot_command_parameters(_pipe)
end,
Body_json = gleam@json:object(Parameters@1),
_pipe@1 = telega@client:new_post_request(
Client,
<<"deleteMyCommands"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@2 = telega@client:fetch(_pipe@1, Client),
map_response(_pipe@2, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 158).
?DOC(
" Use this method to get the current list of the bot's commands for the given scope and user language.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#getmycommands\n"
).
-spec get_my_commands(
telega@client:telegram_client(),
gleam@option:option(telega@model:bot_command_parameters())
) -> {ok, telega@model:bot_command()} | {error, telega@error:telega_error()}.
get_my_commands(Client, Parameters) ->
Parameters@1 = begin
_pipe = gleam@option:unwrap(
Parameters,
telega@model:default_bot_command_parameters()
),
telega@model:encode_bot_command_parameters(_pipe)
end,
Body_json = gleam@json:object(Parameters@1),
_pipe@1 = telega@client:new_post_request(
Client,
<<"getMyCommands"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@2 = telega@client:fetch(_pipe@1, Client),
map_response(_pipe@2, telega@model:bot_command_decoder()).
-file("src/telega/api.gleam", 177).
?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 send_dice(
telega@client:telegram_client(),
telega@model:send_dice_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_dice(Client, Parameters) ->
Body_json = telega@model:encode_send_dice_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendDice"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 188).
?DOC(
" A simple method for testing your bot's authentication token.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#getme\n"
).
-spec get_me(telega@client:telegram_client()) -> {ok, telega@model:user()} |
{error, telega@error:telega_error()}.
get_me(Client) ->
_pipe = telega@client:new_get_request(Client, <<"getMe"/utf8>>, none),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:user_decoder()).
-file("src/telega/api.gleam", 199).
?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@client:telegram_client(),
telega@model:answer_callback_query_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
answer_callback_query(Client, Parameters) ->
Body_json = telega@model:encode_answer_callback_query_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"answerCallbackQuery"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 215).
?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_message(
telega@client:telegram_client(),
telega@model:forward_message_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
forward_message(Client, Parameters) ->
Body_json = telega@model:encode_forward_message_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"forwardMessage"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 230).
?DOC(
" Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#setchatmenubutton\n"
).
-spec set_chat_menu_button(
telega@client:telegram_client(),
telega@model:set_chat_menu_button_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
set_chat_menu_button(Client, Parameters) ->
_pipe@1 = telega@client:new_post_request(
Client,
<<"setChatMenuButton"/utf8>>,
begin
_pipe = telega@model:encode_set_chat_menu_button_parameters(
Parameters
),
gleam@json:to_string(_pipe)
end
),
_pipe@2 = telega@client:fetch(_pipe@1, Client),
map_response(_pipe@2, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 248).
?DOC(
" Use this method to receive incoming updates using long polling ([wiki](https://en.wikipedia.org/wiki/Push_technology#Long_polling)).\n"
"\n"
" > Notes\n"
" > 1. This method will not work if an outgoing webhook is set up.\n"
" > 2. In order to avoid getting duplicate updates, recalculate offset after each server response.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#getupdates\n"
).
-spec get_updates(
telega@client:telegram_client(),
gleam@option:option(telega@model:get_updates_parameters())
) -> {ok, list(telega@model:update())} | {error, telega@error:telega_error()}.
get_updates(Client, Parameters) ->
Query = gleam@option:map(
Parameters,
fun(P) ->
_pipe = [{<<"offset"/utf8>>, erlang:element(2, P)},
{<<"limit"/utf8>>, erlang:element(3, P)},
{<<"timeout"/utf8>>, erlang:element(4, P)}],
gleam@list:filter_map(
_pipe,
fun(X) ->
{Key, Value} = X,
case Value of
{some, Value@1} ->
{ok, {Key, erlang:integer_to_binary(Value@1)}};
none ->
{error, nil}
end
end
)
end
),
_pipe@1 = telega@client:new_get_request(
Client,
<<"getUpdates"/utf8>>,
Query
),
_pipe@2 = telega@client:fetch(_pipe@1, Client),
map_response(
_pipe@2,
gleam@dynamic@decode:list(telega@model:update_decoder())
).
-file("src/telega/api.gleam", 272).
?DOC(
" Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of [MessageId](https://core.telegram.org/bots/api#messageid) of the sent messages is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#forwardmessages\n"
).
-spec forward_messages(
telega@client:telegram_client(),
telega@model:forward_messages_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
forward_messages(Client, Parameters) ->
Body_json = telega@model:encode_forward_messages_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"forwardMessage"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 287).
?DOC(
" Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz [poll](https://core.telegram.org/bots/api#poll) can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method [forwardMessage](https://core.telegram.org/bots/api#forwardmessage), but the copied message doesn't have a link to the original message. Returns the [MessageId](https://core.telegram.org/bots/api#messageid) of the sent message on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#copymessage\n"
).
-spec copy_message(
telega@client:telegram_client(),
telega@model:copy_message_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
copy_message(Client, Parameters) ->
Body_json = telega@model:encode_copy_message_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"copyMessage"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 302).
?DOC(
" Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz [poll](https://core.telegram.org/bots/api#poll) can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method [forwardMessage](https://core.telegram.org/bots/api#forwardmessage), but the copied message doesn't have a link to the original message. Returns the [MessageId](https://core.telegram.org/bots/api#messageid) of the sent message on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#copymessages\n"
).
-spec copy_messages(
telega@client:telegram_client(),
telega@model:copy_messages_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
copy_messages(Client, Parameters) ->
Body_json = telega@model:encode_copy_messages_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"copyMessages"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 317).
?DOC(
" Use this method to send photos. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendphoto\n"
).
-spec send_photo(
telega@client:telegram_client(),
telega@model:send_photo_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_photo(Client, Parameters) ->
Body_json = telega@model:encode_send_photo_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendPhoto"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 340).
?DOC(
" Use this method to send general files. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#senddocument\n"
).
-spec send_document(
telega@client:telegram_client(),
telega@model:send_document_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_document(Client, Parameters) ->
Body_json = telega@model:encode_send_document_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendDocument"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 355).
?DOC(
" Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as Document). On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendvideo\n"
).
-spec send_video(
telega@client:telegram_client(),
telega@model:send_video_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_video(Client, Parameters) ->
Body_json = telega@model:encode_send_video_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendVideo"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 366).
?DOC(
" Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendanimation\n"
).
-spec send_animation(
telega@client:telegram_client(),
telega@model:send_animation_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_animation(Client, Parameters) ->
Body_json = telega@model:encode_send_animation_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendAnimation"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 381).
?DOC(
" Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendvoice\n"
).
-spec send_voice(
telega@client:telegram_client(),
telega@model:send_voice_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_voice(Client, Parameters) ->
Body_json = telega@model:encode_send_voice_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendVoice"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 392).
?DOC(
" Use this method to send video messages. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendvideonote\n"
).
-spec send_video_note(
telega@client:telegram_client(),
telega@model:send_video_note_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_video_note(Client, Parameters) ->
Body_json = telega@model:encode_send_video_note_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendVideoNote"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 407).
?DOC(
" Use this method to send a group of photos, videos, documents or audio files as an album. Documents and audio files can be only grouped in an album with the first item having a filename. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendmediagroup\n"
).
-spec send_media_group(
telega@client:telegram_client(),
telega@model:send_media_group_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_media_group(Client, Parameters) ->
Body_json = telega@model:encode_send_media_group_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendMediaGroup"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 422).
?DOC(
" Use this method to send point on the map. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendlocation\n"
).
-spec send_location(
telega@client:telegram_client(),
telega@model:send_location_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_location(Client, Parameters) ->
Body_json = telega@model:encode_send_location_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendLocation"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 437).
?DOC(
" Use this method to send information about a venue. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendvenue\n"
).
-spec send_venue(
telega@client:telegram_client(),
telega@model:send_venue_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_venue(Client, Parameters) ->
Body_json = telega@model:encode_send_venue_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendVenue"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 448).
?DOC(
" Use this method to send phone contacts. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendcontact\n"
).
-spec send_contact(
telega@client:telegram_client(),
telega@model:send_contact_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_contact(Client, Parameters) ->
Body_json = telega@model:encode_send_contact_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendContact"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 463).
?DOC(
" Use this method to send a native poll. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendpoll\n"
).
-spec send_poll(
telega@client:telegram_client(),
telega@model:send_poll_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_poll(Client, Parameters) ->
Body_json = telega@model:encode_send_poll_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendPoll"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 478).
?DOC(
" Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.\n"
"\n"
" > Example: The [ImageBot](https://t.me/imagebot) needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use [sendChatAction](https://core.telegram.org/bots/api#sendchataction) with action = upload_photo. The user will see a “sending photo” status for the bot.\n"
"\n"
" We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendchataction\n"
).
-spec send_chat_action(
telega@client:telegram_client(),
telega@model:send_chat_action_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_chat_action(Client, Parameters) ->
Body_json = telega@model:encode_send_chat_action_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendChatAction"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 493).
?DOC(
" Use this method to send invoices. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendinvoice\n"
).
-spec send_invoice(
telega@client:telegram_client(),
telega@model:send_invoice_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_invoice(Client, Parameters) ->
Body_json = telega@model:encode_send_invoice_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendInvoice"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 508).
?DOC(
" Use this method to create a link for an invoice.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#createinvoicelink\n"
).
-spec create_invoice_link(
telega@client:telegram_client(),
telega@model:create_invoice_link_parameters()
) -> {ok, binary()} | {error, telega@error:telega_error()}.
create_invoice_link(Client, Parameters) ->
Body_json = telega@model:encode_create_invoice_link_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"createInvoiceLink"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_string/1}).
-file("src/telega/api.gleam", 523).
?DOC(
" Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns _True_ on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#setmessagereaction\n"
).
-spec set_message_reaction(
telega@client:telegram_client(),
telega@model:set_message_reaction_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
set_message_reaction(Client, Parameters) ->
Body_json = telega@model:encode_set_message_reaction_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"setMessageReaction"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 538).
?DOC(
" Use this method to get a list of profile pictures for a user. Returns a [UserProfilePhotos](https://core.telegram.org/bots/api#userprofilephotos) object.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#getuserprofilephotos\n"
).
-spec get_user_profile_photos(
telega@client:telegram_client(),
telega@model:get_user_profile_photos_parameters()
) -> {ok, telega@model:user_profile_photos()} |
{error, telega@error:telega_error()}.
get_user_profile_photos(Client, Parameters) ->
Body_json = telega@model:encode_get_user_profile_photos_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"getUserProfilePhotos"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:user_profile_photos_decoder()).
-file("src/telega/api.gleam", 553).
?DOC(
" Use this method to send static .WEBP, [animated](https://telegram.org/blog/animated-stickers) .TGS, or [video](https://telegram.org/blog/video-stickers-better-reactions/ru?ln=a) .WEBM stickers. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#sendsticker\n"
).
-spec send_sticker(
telega@client:telegram_client(),
telega@model:send_sticker_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
send_sticker(Client, Parameters) ->
Body_json = telega@model:encode_send_sticker_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"sendSticker"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 568).
?DOC(
" Use this method to get a sticker set. On success, a [StickerSet](https://core.telegram.org/bots/api#stickerset) object is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#getstickerset\n"
).
-spec get_sticker_set(
telega@client:telegram_client(),
telega@model:get_sticker_set_parameters()
) -> {ok, telega@model:sticker_set()} | {error, telega@error:telega_error()}.
get_sticker_set(Client, Parameters) ->
Body_json = telega@model:encode_get_sticker_set_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"getStickerSet"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:sticker_set_decoder()).
-file("src/telega/api.gleam", 583).
?DOC(
" Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#editmessagetext\n"
).
-spec edit_message_text(
telega@client:telegram_client(),
telega@model:edit_message_text_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
edit_message_text(Client, Parameters) ->
Body_json = telega@model:encode_edit_message_text_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"editMessageText"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 598).
?DOC(
" Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#editmessagecaption\n"
).
-spec edit_message_caption(
telega@client:telegram_client(),
telega@model:edit_message_caption_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
edit_message_caption(Client, Parameters) ->
Body_json = telega@model:encode_edit_message_caption_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"editMessageCaption"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 613).
?DOC(
" Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#editmessagemedia\n"
).
-spec edit_message_media(
telega@client:telegram_client(),
telega@model:edit_message_media_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
edit_message_media(Client, Parameters) ->
Body_json = telega@model:encode_edit_message_media_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"editMessageMedia"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 628).
?DOC(
" Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. 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#editmessagelivelocation\n"
).
-spec edit_message_live_location(
telega@client:telegram_client(),
telega@model:edit_message_live_location_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
edit_message_live_location(Client, Parameters) ->
Body_json = telega@model:encode_edit_message_live_location_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"editMessageLiveLocation"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 643).
?DOC(
" Use this method to stop updating a live location message before live_period expires. On success, if the 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#stopmessagelivelocation\n"
).
-spec stop_message_live_location(
telega@client:telegram_client(),
telega@model:stop_message_live_location_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
stop_message_live_location(Client, Parameters) ->
Body_json = telega@model:encode_stop_message_live_location_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"stopMessageLiveLocation"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 658).
?DOC(
" Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#editmessagereplymarkup\n"
).
-spec edit_message_reply_markup(
telega@client:telegram_client(),
telega@model:edit_message_reply_markup_parameters()
) -> {ok, telega@model:message()} | {error, telega@error:telega_error()}.
edit_message_reply_markup(Client, Parameters) ->
Body_json = telega@model:encode_edit_message_reply_markup_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"editMessageReplyMarkup"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:message_decoder()).
-file("src/telega/api.gleam", 673).
?DOC(
" Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#stoppoll\n"
).
-spec stop_poll(
telega@client:telegram_client(),
telega@model:stop_poll_parameters()
) -> {ok, telega@model:poll()} | {error, telega@error:telega_error()}.
stop_poll(Client, Parameters) ->
Body_json = telega@model:encode_stop_poll_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"stopPoll"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:poll_decoder()).
-file("src/telega/api.gleam", 693).
?DOC(
" Use this method to delete a message, including service messages, with the following limitations:\n"
" - A message can only be deleted if it was sent less than 48 hours ago.\n"
" - Service messages about a supergroup, channel, or forum topic creation can't be deleted.\n"
" - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.\n"
" - Bots can delete outgoing messages in private chats, groups, and supergroups.\n"
" - Bots can delete incoming messages in private chats.\n"
" - Bots granted can_post_messages permissions can delete outgoing messages in channels.\n"
" - If the bot is an administrator of a group, it can delete any message there.\n"
" - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.\n"
" Returns True on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#deletemessage\n"
).
-spec delete_message(
telega@client:telegram_client(),
telega@model:delete_message_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
delete_message(Client, Parameters) ->
Body_json = telega@model:encode_delete_message_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"deleteMessage"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 708).
?DOC(
" Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped. Returns True on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#deletemessagessimultaneously\n"
).
-spec delete_messages(
telega@client:telegram_client(),
telega@model:delete_messages_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
delete_messages(Client, Parameters) ->
Body_json = telega@model:encode_delete_messages_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"deleteMessages"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 723).
?DOC(
" Use this method to get up-to-date information about the chat. Returns a [ChatFullInfo](https://core.telegram.org/bots/api#chatfullinfo) object on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#getchat\n"
).
-spec get_chat(telega@client:telegram_client(), binary()) -> {ok,
telega@model:chat_full_info()} |
{error, telega@error:telega_error()}.
get_chat(Client, Chat_id) ->
_pipe = telega@client:new_get_request(
Client,
<<"getChat"/utf8>>,
{some, [{<<"chat_id"/utf8>>, Chat_id}]}
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:chat_full_info_decoder()).
-file("src/telega/api.gleam", 732).
?DOC(
" Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link `https://api.telegram.org/file/bot<token>/<file_path>`, where `<file_path>` is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#getfile\n"
).
-spec get_file(telega@client:telegram_client(), binary()) -> {ok,
telega@model:file()} |
{error, telega@error:telega_error()}.
get_file(Client, File_id) ->
_pipe = telega@client:new_get_request(
Client,
<<"getFile"/utf8>>,
{some, [{<<"file_id"/utf8>>, File_id}]}
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:file_decoder()).
-file("src/telega/api.gleam", 741).
?DOC(
" Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#banchatmember\n"
).
-spec ban_chat_member(
telega@client:telegram_client(),
telega@model:ban_chat_member_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
ban_chat_member(Client, Parameters) ->
Body_json = telega@model:encode_ban_chat_member_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"banChatMember"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 756).
?DOC(
" Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#unbanchatmember\n"
).
-spec unban_chat_member(
telega@client:telegram_client(),
telega@model:unban_chat_member_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
unban_chat_member(Client, Parameters) ->
Body_json = telega@model:encode_unban_chat_member_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"unbanChatMember"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 771).
?DOC(
" Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass `True` for all permissions to lift restrictions from a user. Returns `True` on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#restrictchatmember\n"
).
-spec restrict_chat_member(
telega@client:telegram_client(),
telega@model:restrict_chat_member_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
restrict_chat_member(Client, Parameters) ->
Body_json = telega@model:encode_restrict_chat_member_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"restrictChatMember"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 786).
?DOC(
" Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass `False` for all boolean parameters to demote a user. Returns `True` on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#promotechatmember\n"
).
-spec promote_chat_member(
telega@client:telegram_client(),
telega@model:promote_chat_member_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
promote_chat_member(Client, Parameters) ->
Body_json = telega@model:encode_promote_chat_member_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"promoteChatMember"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 801).
?DOC(
" Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns `True` on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#setchatadministratorcustomtitle\n"
).
-spec set_chat_administrator_custom_title(
telega@client:telegram_client(),
telega@model:set_chat_administrator_custom_title_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
set_chat_administrator_custom_title(Client, Parameters) ->
Body_json = telega@model:encode_set_chat_administrator_custom_title_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"setChatAdministratorCustomTitle"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 817).
?DOC(
" Use this method to ban a channel chat in a supergroup or a channel. Until the chat is [unbanned](https://core.telegram.org/bots/api#unbanchatsenderchat), the owner of the banned chat won't be able to send messages on behalf of **any of their channels**. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns `True` on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#banchatsenderchat\n"
).
-spec ban_chat_sender_chat(
telega@client:telegram_client(),
telega@model:ban_chat_sender_chat_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
ban_chat_sender_chat(Client, Parameters) ->
Body_json = telega@model:encode_ban_chat_sender_chat_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"banChatSenderChat"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 832).
?DOC(
" Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns `True` on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#unbanchatsenderchat\n"
).
-spec unban_chat_sender_chat(
telega@client:telegram_client(),
telega@model:unban_chat_sender_chat_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
unban_chat_sender_chat(Client, Parameters) ->
Body_json = telega@model:encode_unban_chat_sender_chat_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"unbanChatSenderChat"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 847).
?DOC(
" Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the `can_restrict_members` administrator rights. Returns `True` on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#setchatpermissions\n"
).
-spec set_chat_permissions(
telega@client:telegram_client(),
telega@model:set_chat_permissions_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
set_chat_permissions(Client, Parameters) ->
Body_json = telega@model:encode_set_chat_permissions_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"setChatPermissions"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 864).
?DOC(
" Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success.\n"
"\n"
" > Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using [exportChatInviteLink](https://core.telegram.org/bots/api#exportchatinvitelink) or by calling the [getChat](https://core.telegram.org/bots/api#getchat) method. If your bot needs to generate a new primary invite link replacing its previous one, use [exportChatInviteLink](https://core.telegram.org/bots/api#exportchatinvitelink) again.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#exportchatinvitelink\n"
).
-spec export_chat_invite_link(
telega@client:telegram_client(),
telega@model:export_chat_invite_link_parameters()
) -> {ok, binary()} | {error, telega@error:telega_error()}.
export_chat_invite_link(Client, Parameters) ->
Body_json = telega@model:encode_export_chat_invite_link_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"exportChatInviteLink"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_string/1}).
-file("src/telega/api.gleam", 879).
?DOC(
" Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method [revokeChatInviteLink](https://core.telegram.org/bots/api#revokechatinvitelink). Returns the new invite link as [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#createchatinvitelink\n"
).
-spec create_chat_invite_link(
telega@client:telegram_client(),
telega@model:create_chat_invite_link_parameters()
) -> {ok, telega@model:chat_invite_link()} |
{error, telega@error:telega_error()}.
create_chat_invite_link(Client, Parameters) ->
Body_json = telega@model:encode_create_chat_invite_link_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"createChatInviteLink"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:chat_invite_link_decoder()).
-file("src/telega/api.gleam", 894).
?DOC(
" Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#editchatinvitelink\n"
).
-spec edit_chat_invite_link(
telega@client:telegram_client(),
telega@model:edit_chat_invite_link_parameters()
) -> {ok, telega@model:chat_invite_link()} |
{error, telega@error:telega_error()}.
edit_chat_invite_link(Client, Parameters) ->
Body_json = telega@model:encode_edit_chat_invite_link_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"editChatInviteLink"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:chat_invite_link_decoder()).
-file("src/telega/api.gleam", 909).
?DOC(
" Use this method to create a [subscription invite link](https://core.telegram.org/bots/api#chatinvitelink) for a channel chat. The bot must have the `can_invite_users` administrator rights. The link can be edited using the method [editChatSubscriptionInviteLink](https://core.telegram.org/bots/api#editchatsubscriptioninvitelink) or revoked using the method [revokeChatInviteLink](https://core.telegram.org/bots/api#revokechatinvitelink). Returns the new invite link as a [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink\n"
).
-spec create_chat_subscription_invite_link(
telega@client:telegram_client(),
telega@model:create_chat_subscription_invite_link_parameters()
) -> {ok, telega@model:chat_invite_link()} |
{error, telega@error:telega_error()}.
create_chat_subscription_invite_link(Client, Parameters) ->
Body_json = telega@model:encode_create_chat_subscription_invite_link_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"createChatSubscriptionInviteLink"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:chat_invite_link_decoder()).
-file("src/telega/api.gleam", 928).
?DOC(
" Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink\n"
).
-spec edit_chat_subscription_invite_link(
telega@client:telegram_client(),
telega@model:edit_chat_subscription_invite_link_parameters()
) -> {ok, telega@model:chat_invite_link()} |
{error, telega@error:telega_error()}.
edit_chat_subscription_invite_link(Client, Parameters) ->
Body_json = telega@model:encode_edit_chat_subscription_invite_link_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"editChatSubscriptionInviteLink"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:chat_invite_link_decoder()).
-file("src/telega/api.gleam", 944).
?DOC(
" Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#revokechatinvitelink\n"
).
-spec revoke_chat_invite_link(
telega@client:telegram_client(),
telega@model:revoke_chat_invite_link_parameters()
) -> {ok, telega@model:chat_invite_link()} |
{error, telega@error:telega_error()}.
revoke_chat_invite_link(Client, Parameters) ->
Body_json = telega@model:encode_revoke_chat_invite_link_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"revokeChatInviteLink"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, telega@model:chat_invite_link_decoder()).
-file("src/telega/api.gleam", 973).
?DOC(
" Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the `can_invite_users` administrator right. Returns `True` on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#declinechatjoinrequest\n"
).
-spec decline_chat_join_request(
telega@client:telegram_client(),
telega@model:decline_chat_join_request_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
decline_chat_join_request(Client, Parameters) ->
Body_json = telega@model:encode_decline_chat_join_request_parameters(
Parameters
),
_pipe = telega@client:new_post_request(
Client,
<<"declineChatJoinRequest"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 988).
?DOC(
" Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns `True` on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#setchatphoto\n"
).
-spec set_chat_photo(
telega@client:telegram_client(),
telega@model:set_chat_photo_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
set_chat_photo(Client, Parameters) ->
Body_json = telega@model:encode_set_chat_photo_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"setChatPhoto"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).
-file("src/telega/api.gleam", 1003).
?DOC(
" Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns `True` on success.\n"
"\n"
" **Official reference:** https://core.telegram.org/bots/api#deletechatphoto\n"
).
-spec delete_chat_photo(
telega@client:telegram_client(),
telega@model:delete_chat_photo_parameters()
) -> {ok, boolean()} | {error, telega@error:telega_error()}.
delete_chat_photo(Client, Parameters) ->
Body_json = telega@model:encode_delete_chat_photo_parameters(Parameters),
_pipe = telega@client:new_post_request(
Client,
<<"deleteChatPhoto"/utf8>>,
gleam@json:to_string(Body_json)
),
_pipe@1 = telega@client:fetch(_pipe, Client),
map_response(_pipe@1, {decoder, fun gleam@dynamic@decode:decode_bool/1}).