1.0.1 • Published 3 years ago

@dauletbaev/telegram-bot v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Telegram Bot API

The Bot API is an HTTP-based interface created for developers keen on building bots for Telegram. Read more about the bots at the introduction for developers page.

Features

  • 100% typesafe
  • ES6 (Package not compatible with CommonJS)

This package has no framework abstraction it is just raw api mapping to typescript/javascript.

If you want some framework abstraction on top (in most cases you do) consider using like grammyjs

Examples

import { Bot } from '@dauletbaev/telegram-bot';

const BOT_TOKEN = '1111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';

const bot = new Bot(BOT_TOKEN);

bot.startPolling({
  fn: async (update) => {
    const chatId = update?.message.chat.id;
    const text = update?.message.text;

    await bot.sendMessage({
      chat_id: chatId,
      text: text,
    });
  },
});