Module telegram-bot-lua.async

async polling and concurrency via copas.

[[

Functions

api.async.all(fns) run multiple functions concurrently and collect results.
api.async.is_running() check if we're currently inside the async event loop.
api.async.request(endpoint, parameters, file) non-blocking HTTP request using copas.
api.async.run(opts) run the bot with concurrent update processing.
api.async.sleep(seconds) non-blocking sleep (only works within a copas coroutine).
api.async.spawn(fn) spawn a background coroutine within the copas event loop.
api.async.stop() stop the async run loop.


Functions

api.async.all(fns)
run multiple functions concurrently and collect results. each function runs in its own coroutine. returns when all complete.

Parameters:

  • fns table array of functions to execute in parallel

Returns:

    table results in order: { {value, ...}, {false, error}, ... }
api.async.is_running()
check if we're currently inside the async event loop.

Returns:

    boolean true if the async loop is active
api.async.request(endpoint, parameters, file)
non-blocking HTTP request using copas. has the same signature as api.request but uses copas.http.

Parameters:

  • endpoint string the full API endpoint URL
  • parameters table optional request parameters
  • file table optional file upload map

Returns:

    table decoded JSON response, or false on error
api.async.run(opts)
run the bot with concurrent update processing. each update is dispatched to its own coroutine so a slow handler won't block processing of other updates.

Parameters:

  • opts table polling options (limit, timeout, offset, allowed_updates)
api.async.sleep(seconds)
non-blocking sleep (only works within a copas coroutine).

Parameters:

  • seconds number duration to sleep
api.async.spawn(fn)
spawn a background coroutine within the copas event loop.

Parameters:

  • fn function the function to run in a new coroutine

Returns:

    thread the copas thread
api.async.stop()
stop the async run loop.
generated by LDoc 1.5.0 Last updated 2026-04-07 21:37:15