telega
Types
pub type Bot {
Bot(config: Config, handlers: List(Handler))
}
Constructors
-
Bot(config: Config, handlers: List(Handler))
pub type Chat {
Chat(id: Int)
}
Constructors
-
Chat(id: Int)
pub opaque type Config
pub type Context {
Context(message: Message, bot: Bot)
}
Constructors
-
Context(message: Message, bot: Bot)
pub type Handler {
HandleAll(handler: fn(Context) -> Result(Nil, Nil))
}
Constructors
-
HandleAll(handler: fn(Context) -> Result(Nil, Nil))
Messages represent the data that the bot receives from the Telegram API.
pub type Message {
TextMessage(text: String, chat: Chat)
}
Constructors
-
TextMessage(text: String, chat: Chat)
Functions
pub fn decode_message(
json: Dynamic,
) -> Result(Message, List(DecodeError))
Decode a message from the Telegram API.
pub fn handle_update(bot: Bot, message: Message) -> Nil
Handle an update from the Telegram API.
pub fn is_secret_token_valid(bot: Bot, token: String) -> Bool
Check if a token is the secret token for the bot.
pub fn is_webhook_path(bot: Bot, path: String) -> Bool
Check if a path is the webhook path for the bot.
pub fn new(
token token: String,
url server_url: String,
webhook_path webhook_path: String,
secret_token secret_token: Option(String),
) -> Bot
Create a new bot instance.
pub fn reply(ctx: Context, text: String) -> Result(Nil, Nil)
Replies to user with a text message.