Packages
telegex
1.3.2
1.9.0-rc.0
1.8.0
1.7.0
1.6.0
1.5.0
1.4.2
1.4.1
1.4.0
1.3.2
1.3.1
1.3.0
1.2.3-dev
1.2.2
1.2.1
1.2.0
1.1.1
1.1.0
1.0.1
1.0.0
1.0.0-rc.10
1.0.0-rc.9
1.0.0-rc.8
1.0.0-rc.7
1.0.0-rc.6
1.0.0-rc.5
1.0.0-rc.4
1.0.0-rc.3
1.0.0-rc.2
1.0.0-rc.1
1.0.0-rc.0
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.1.0-rc.11
0.1.0-rc.10
0.1.0-rc.9
0.1.0-rc.8
0.1.0-rc.7
0.1.0-rc.6
0.1.0-rc.5
0.1.0-rc.4
0.1.0-rc.3
0.1.0-rc.2
0.1.0-rc.1
0.0.4
0.0.3
0.0.2
0.0.1
A Telegram bot framework, with its client-side based on data and code generation, boasts unparalleled adaptation speed and correctness for new versions.
Current section
Files
Jump to
Current section
Files
lib/telegex/global.ex
defmodule Telegex.Global do
@moduledoc """
Global configuration options.
Read global configuration options (in contrast to `Telegex.Instance`), where these configuration options
are directly keyed under `:telegex`.
## Option descriptions
* `api_base_url` - The base URL of the Telegram Bot API. Defaults to `https://api.telegram.org/bot`.
* `caller_adapter` - The adapter module for making HTTP requests. Defaults to `Finch`.
* `hook_adapter` - The adapter module for handling webhook requests. Defaults to `Bandit`.
* `token` - The token of the bot.
"""
@spec api_base_url :: String.t()
def api_base_url do
get_option(:api_base_url, "https://api.telegram.org/bot")
end
@spec caller_adapter :: module | {module, keyword}
def caller_adapter do
# The default adapter is `Finch`
get_option(:caller_adapter, Finch)
end
@spec hook_adapter :: module
def hook_adapter do
# The default adapter is `Bandit`
get_option(:hook_adapter, Bandit)
end
@spec token :: String.t()
def token do
get_option(:token)
end
defp get_option(key, default \\ nil) do
Application.get_env(:telegex, key, default)
end
end