Skip to content

Official Telegram Bot for LicenseChain - License management and customer support through Telegram.

License

Notifications You must be signed in to change notification settings

LicenseChain/LicenseChain-TG-Bot

Repository files navigation

LicenseChain Telegram Bot

License Node.js Telegram

LicenseChain Telegram Bot for license operations, support flows, and admin controls over Telegram.

Current Repository Stage

This repository currently runs as:

  • A polling Telegram bot (node-telegram-bot-api) started from src/index.js.
  • A local SQLite-backed state store (src/database/DatabaseManager.js).
  • An HTTP health/stats server (Express) on PORT (default 3005).
  • A modular command system loaded dynamically from src/commands/*.js.

Requirements

  • Node.js >=18 (required by package.json)
  • npm
  • Telegram bot token from BotFather
  • LicenseChain API key

Installation

git clone https://github.com/LicenseChain/LicenseChain-TG-Bot.git
cd LicenseChain-TG-Bot
npm install

Environment Variables

Create .env in project root:

# Required
TELEGRAM_TOKEN=your_bot_token
LICENSE_CHAIN_API_KEY=your_licensechain_api_key

# Recommended
LICENSE_CHAIN_API_URL=https://api.licensechain.app
LICENSECHAIN_APP_NAME=your_app_id_or_name

# Bot/runtime
PORT=3005
LOG_LEVEL=info
LICENSECHAIN_APP_VERSION=1.0.0

# Admin controls (comma-separated IDs for admin list)
ADMIN_USERS=123456789,987654321
BOT_OWNER_ID=123456789

# SQLite file path (this project uses sqlite path semantics)
DATABASE_URL=./data/bot.db

Notes:

  • DATABASE_URL is used as a SQLite file path in current code.
  • LICENSECHAIN_APP_NAME is needed for app-scoped commands (create/list/analytics/status flows).

Run

# Production
npm start

# Development
npm run dev

When running, the process starts:

  • Telegram polling bot
  • GET /health
  • GET /stats

Docker

This repository includes a Dockerfile.

docker build -t licensechain-telegram-bot .
docker run --name lc-tg-bot \
  -p 3005:3005 \
  -e TELEGRAM_TOKEN=your_bot_token \
  -e LICENSE_CHAIN_API_KEY=your_licensechain_api_key \
  -e LICENSECHAIN_APP_NAME=your_app_id_or_name \
  -e BOT_OWNER_ID=123456789 \
  -e ADMIN_USERS=123456789 \
  -e DATABASE_URL=/app/data/bot.db \
  -v "$(pwd)/data:/app/data" \
  licensechain-telegram-bot

Command Surface (Current)

Commands are loaded from src/commands and handled by src/handlers/CommandHandler.js.

Primary user commands:

  • /start
  • /help
  • /license
  • /validate <license_key>
  • /analytics
  • /profile
  • /settings
  • /list
  • /info <license_key>

License/admin operations:

  • /create <issued_to_or_email> <plan> <expires>
  • /update <license_id_or_key> ...
  • /revoke <license_id_or_key>
  • /extend <license_id_or_key> <days>
  • /licenses
  • /status
  • /setstatus <online|offline|maintenance>
  • /stats
  • /reload
  • /admin
  • /logs [lines]
  • /errors
  • /performance
  • /usage [timeframe]
  • /user <id>
  • /ban <id> [reason]
  • /unban <id>
  • /ticket ...
  • /tickets
  • /close <ticket_id>
  • /m licenses

Admin-gated commands are enforced with ADMIN_USERS and BOT_OWNER_ID.

API Integration (Current)

The bot client (src/client/LicenseChainClient.js) targets API v1-style routes, including:

  • POST /v1/licenses/verify
  • POST /v1/apps/:appId/licenses
  • PATCH /v1/licenses/:id
  • PATCH /v1/licenses/:id/status (used by current update path)
  • DELETE /v1/licenses/:id (used by current revoke path)
  • GET /v1/licenses/:id/analytics
  • GET /v1/licenses/stats
  • GET /v1/apps
  • GET /v1/apps/:id
  • GET /v1/apps/:id/licenses
  • GET /health

Health Endpoints

  • GET /health - process status, uptime, version
  • GET /stats - bot identity + local usage counters

Scripts

npm start
npm run dev
npm run lint
npm run lint:fix
npm test

Troubleshooting

  • Bot not responding:
    • verify TELEGRAM_TOKEN
    • ensure process is running and polling is not blocked
  • License commands failing:
    • verify LICENSE_CHAIN_API_KEY
    • verify LICENSECHAIN_APP_NAME
    • verify API reachability from host
  • No data persistence:
    • verify DATABASE_URL path and write permissions

License

Elastic License 2.0 (package.json).

About

Official Telegram Bot for LicenseChain - License management and customer support through Telegram.

Topics

Resources

License

Stars

Watchers

Forks