-module(telega@bot). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([new/4, get_secret_token/1, get_token/1, get_server_url/1, get_webhook_path/1, get_tg_api_url/1, get_max_retry_attempts/1]). -export_type([context/1, config/0, bot/0]). -type context(PGN) :: {context, telega@message:message(), bot(), PGN}. -opaque config() :: {config, binary(), binary(), binary(), binary(), gleam@option:option(integer()), gleam@option:option(binary())}. -type bot() :: {bot, config()}. -spec new(binary(), binary(), binary(), gleam@option:option(binary())) -> bot(). new(Token, Server_url, Webhook_path, Secret_token) -> Secret_token@1 = gleam@option:lazy_unwrap( Secret_token, fun() -> _pipe = gleam@int:random(1000000), gleam@int:to_string(_pipe) end ), {bot, {config, Token, Server_url, Webhook_path, Secret_token@1, none, none}}. -spec get_secret_token(bot()) -> binary(). get_secret_token(Bot) -> erlang:element(5, erlang:element(2, Bot)). -spec get_token(bot()) -> binary(). get_token(Bot) -> erlang:element(2, erlang:element(2, Bot)). -spec get_server_url(bot()) -> binary(). get_server_url(Bot) -> erlang:element(3, erlang:element(2, Bot)). -spec get_webhook_path(bot()) -> binary(). get_webhook_path(Bot) -> erlang:element(4, erlang:element(2, Bot)). -spec get_tg_api_url(bot()) -> binary(). get_tg_api_url(Bot) -> gleam@option:unwrap( erlang:element(7, erlang:element(2, Bot)), <<"https://api.telegram.org/bot"/utf8>> ). -spec get_max_retry_attempts(bot()) -> integer(). get_max_retry_attempts(Bot) -> gleam@option:unwrap(erlang:element(6, erlang:element(2, Bot)), 3).