telega_mist
Values
pub const default_max_body_limit: Int
Default maximum size in bytes for the incoming webhook request body.
Telegram updates are small, so 4MB is plenty while keeping a sane upper
bound. Use handle_bot_with_limit to override it.
pub fn handle_bot(
telega telega: telega.Telega(session, error, dependencies),
req req: request.Request(mist.Connection),
next handler: fn() -> response.Response(mist.ResponseData),
) -> response.Response(mist.ResponseData)
A handler to process incoming requests from the Telegram API directly on top of mist, without wisp — for minimalistic deployments.
It checks the webhook path, validates the secret token, decodes the incoming
update, and dispatches it to the bot in a separate process so the 200 OK
response is returned immediately (Telegram waits for the response before
sending the next update).
import gleam/http/request.{type Request}
import gleam/http/response.{type Response}
import mist.{type Connection, type ResponseData}
import telega.{type Telega}
import telega_mist
fn handle_request(
req: Request(Connection),
bot: Telega(session, error, dependencies),
) -> Response(ResponseData) {
use <- telega_mist.handle_bot(telega: bot, req:)
// Your other routes here...
response.new(404) |> response.set_body(mist.Bytes(bytes_tree.new()))
}
pub fn handle_bot_with_limit(
telega telega: telega.Telega(session, error, dependencies),
req req: request.Request(mist.Connection),
max_body_limit max_body_limit: Int,
next handler: fn() -> response.Response(mist.ResponseData),
) -> response.Response(mist.ResponseData)
Same as handle_bot, but lets you set the maximum request body size in bytes.