function tgtb
tgtb(
bot_token: string,
config?: TgtbConfig,
): Client

Creates a new TgtbClient instance

Examples

call API methods

import tgtb, { TgtbConfig } from "@izzqz/tgtb";

const options: TgtbConfig = {
  fetch_fn: globalThis.fetch,
  base_url: "https://api.telegram.org/bot",
  use_test_mode: false
};

const bot_token = "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11";

const bot = tgtb(bot_token, options);

bot; // TgtbClient

// call a method
const res = await bot.api.sendMessage({
  chat_id: 123456,
  text: "Hello, world!"
});

res; // ApiResponse<SendMessage>

Parameters

bot_token: string
  • Telegram bot token
optional
config: TgtbConfig
  • tgtb options

Return Type

A new TgtbClient instance

Usage

import tgtb from ".";