telega
Types
pub type Command {
Command(text: String, command: String, payload: Option(String))
}
Constructors
-
Command(text: String, command: String, payload: Option(String))Arguments
-
text
Whole command message
-
payload
The command arguments, if any.
-
pub opaque type SessionSettings(session)
pub opaque type TelegaBuilder(session)
Functions
pub fn handle_all(
builder: TelegaBuilder(a),
handler: fn(Context(a)) -> Result(a, String),
) -> TelegaBuilder(a)
pub fn handle_command(
builder: TelegaBuilder(a),
command: String,
handler: fn(Context(a), Command) -> Result(a, String),
) -> TelegaBuilder(a)
pub fn handle_commands(
builder: TelegaBuilder(a),
commands: List(String),
handler: fn(Context(a), Command) -> Result(a, String),
) -> TelegaBuilder(a)
pub fn handle_text(
builder: TelegaBuilder(a),
handler: fn(Context(a), String) -> Result(a, String),
) -> TelegaBuilder(a)
pub fn handle_update(
telega: Telega(a),
message: Message,
) -> Result(Nil, String)
Handle an update from the Telegram API.
pub fn init_nil_session(
builder: TelegaBuilder(Nil),
) -> Result(Telega(Nil), String)
pub fn is_secret_token_valid(
telega: Telega(a),
token: String,
) -> Bool
Check if a secret token is valid.
pub fn is_webhook_path(telega: Telega(a), path: String) -> Bool
Check if a path is the webhook path for the bot.
pub fn log_context(
ctx: Context(a),
prefix: String,
handler: fn() -> Result(a, String),
) -> Result(a, String)
Log the message and error message if the handler fails.
pub fn new(
token token: String,
url server_url: String,
webhook_path webhook_path: String,
secret_token secret_token: Option(String),
) -> TelegaBuilder(a)
pub fn with_session_settings(
builder: TelegaBuilder(a),
persist_session persist_session: fn(String, a) ->
Result(a, String),
get_session get_session: fn(String) -> Result(a, String),
get_session_key get_session_key: fn(Message) -> String,
) -> TelegaBuilder(a)