LicenseChain Telegram Bot for license operations, support flows, and admin controls over Telegram.
This repository currently runs as:
- A polling Telegram bot (
node-telegram-bot-api) started fromsrc/index.js. - A local SQLite-backed state store (
src/database/DatabaseManager.js). - An HTTP health/stats server (Express) on
PORT(default3005). - A modular command system loaded dynamically from
src/commands/*.js.
- Node.js
>=18(required bypackage.json) - npm
- Telegram bot token from BotFather
- LicenseChain API key
git clone https://github.com/LicenseChain/LicenseChain-TG-Bot.git
cd LicenseChain-TG-Bot
npm installCreate .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.dbNotes:
DATABASE_URLis used as a SQLite file path in current code.LICENSECHAIN_APP_NAMEis needed for app-scoped commands (create/list/analytics/status flows).
# Production
npm start
# Development
npm run devWhen running, the process starts:
- Telegram polling bot
GET /healthGET /stats
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-botCommands 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.
The bot client (src/client/LicenseChainClient.js) targets API v1-style routes, including:
POST /v1/licenses/verifyPOST /v1/apps/:appId/licensesPATCH /v1/licenses/:idPATCH /v1/licenses/:id/status(used by current update path)DELETE /v1/licenses/:id(used by current revoke path)GET /v1/licenses/:id/analyticsGET /v1/licenses/statsGET /v1/appsGET /v1/apps/:idGET /v1/apps/:id/licensesGET /health
GET /health- process status, uptime, versionGET /stats- bot identity + local usage counters
npm start
npm run dev
npm run lint
npm run lint:fix
npm test- Bot not responding:
- verify
TELEGRAM_TOKEN - ensure process is running and polling is not blocked
- verify
- License commands failing:
- verify
LICENSE_CHAIN_API_KEY - verify
LICENSECHAIN_APP_NAME - verify API reachability from host
- verify
- No data persistence:
- verify
DATABASE_URLpath and write permissions
- verify
Elastic License 2.0 (package.json).