Skip to content

flancer32/teq-telegram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@flancer32/teq-telegram-bot

The base npm package for building Telegram bots using grammY and @teqfw/di.

Overview

This package enables the creation of Telegram bots using the grammY library (the Habr post, RU).

It provides the following features:

  • Loading the bot's configuration (token) from external sources (e.g., JSON file).
  • Running the Node.js application in two modes:
    • As a bot using long polling.
    • As a webhook server:
      • HTTP & HTTP/2 as an application server behind a proxy server.
      • HTTPS as a standalone server.
  • Common activity (setup of commands on startup, webhook registration, etc.)
  • Defining extension points where applications can add custom logic.

The Use Cases

Installation

Create the npm application and add the bot library to this app:

$ npm i @flancer32/teq-telegram-bot

Usage

$ ./bin/tequila.mjs help
$ ./bin/tequila.mjs tg-bot-start        # long polling mode
$ ./bin/tequila.mjs tg-bot-stop
$ ./bin/tequila.mjs web-server-start    # webhook mode
$ ./bin/tequila.mjs web-server-stop

Configuration

File ./cfg/local.json of the main app:

{
  "@flancer32/teq-telegram-bot": {
    "apiKeyTelegram": "..."
  }
}

API

  • Telegram_Bot_Back_Api_Setup: setup the grammY bot, add the commands and handlers.