telega_httpc

httpc adapter for the Telega Telegram Bot Library.

Provides a TelegramClient that uses gleam_httpc as the HTTP backend.

import telega
import telega_httpc

pub fn main() {
  let client = telega_httpc.new("BOT_TOKEN")
  let assert Ok(_bot) =
    telega.new_for_polling(client)
    |> telega.with_router(router)
    |> telega.init_for_polling_nil_session()
}

Values

pub fn fetch_adapter(
  req: request.Request(String),
) -> Result(response.Response(String), error.TelegaError)

The httpc fetch adapter for JSON API requests.

Exposed so you can use it with client.set_fetch_client if needed.

pub fn fetch_bits_adapter(
  req: request.Request(BitArray),
) -> Result(response.Response(BitArray), error.TelegaError)

The httpc fetch adapter for binary file downloads.

Exposed so you can use it with client.set_fetch_bits_client if needed.

pub fn new(token token: String) -> client.TelegramClient

Create a new Telegram client using httpc as the HTTP backend.

This sets up both FetchClient (for JSON API calls) and FetchBitsClient (for binary file downloads).

pub fn new_with_queue(
  token token: String,
) -> Result(client.TelegramClient, error.TelegaError)

Create a new Telegram client with httpc and default request queue.

Search Document