telega_wisp
Values
pub fn handle_bot(
telega telega: telega.Telega(session, error, dependencies),
req req: request.Request(wisp.Connection),
next handler: fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body)
A middleware function to handle incoming requests from the Telegram API. Handles a request to the bot webhook endpoint, decodes the incoming message, validates the secret token, and passes the message to the bot for processing.
import wisp.{type Request, type Response}
import telega.{type Bot}
import telega_wisp
fn handle_request(bot: Bot, req: Request) -> Response {
use <- telega_wisp.handle_bot(req, bot)
// ...
}
pub fn handle_bot_with_reply(
telega telega: telega.Telega(session, error, dependencies),
req req: request.Request(wisp.Connection),
timeout timeout: Int,
next handler: fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body)
Like handle_bot, but lets the handler answer the update directly in the
webhook HTTP response body (webhook reply),
saving one HTTP round-trip for the first eligible API call.
Unlike handle_bot, the request process waits up to timeout ms for the
handler to either claim a reply or finish; after the timeout it answers an
empty 200 OK and the handler keeps running in the background. Pick a
timeout safely below Telegram’s webhook timeout — e.g. 5000 ms.
⚠️ A claimed call resolves to a synthetic stub inside the handler (
Truefor boolean methods, a fakeMessageforsendMessage). Full guide in telega’stelega/webhook_replymodule docs.