Skip to content

Commit 975ddd9

Browse files
committed
Initial commit: Fresh start
- Removed all old commits
0 parents  commit 975ddd9

95 files changed

Lines changed: 21546 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules
2+
npm-debug.log
3+
.env
4+
.env.local
5+
.git
6+
.gitignore
7+
README.md
8+
.vscode
9+
.idea
10+
*.md
11+
.DS_Store
12+
coverage
13+
.nyc_output
14+

.env.example

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# =============================================================================
2+
# LicenseChain Telegram Bot - Example environment variables
3+
# Copy to .env and fill in real values. Do not commit .env.
4+
# =============================================================================
5+
6+
# -----------------------------------------------------------------------------
7+
# Required [SENSITIVE]
8+
# -----------------------------------------------------------------------------
9+
TELEGRAM_TOKEN=your_bot_token_from_botfather
10+
LICENSECHAIN_API_KEY=your_licensechain_api_key
11+
DATABASE_URL=postgresql://user:password@host:5432/dbname?sslmode=require
12+
13+
# -----------------------------------------------------------------------------
14+
# Recommended (LicenseChain API and app)
15+
# -----------------------------------------------------------------------------
16+
LICENSECHAIN_BASE_URL=https://api.licensechain.app/v1
17+
LICENSECHAIN_APP_NAME=your_app_slug_or_id
18+
LICENSECHAIN_APP_VERSION=1.0.0
19+
# Legacy aliases are still accepted for compatibility:
20+
# LICENSE_CHAIN_API_KEY=your_licensechain_api_key
21+
# LICENSE_CHAIN_API_URL=https://api.licensechain.app/v1
22+
23+
# -----------------------------------------------------------------------------
24+
# Bot / runtime
25+
# -----------------------------------------------------------------------------
26+
PORT=3005
27+
LOG_LEVEL=info
28+
29+
# Platform-injected (do not set manually unless testing)
30+
# VERCEL=1
31+
# AWS_LAMBDA_FUNCTION_NAME=
32+
33+
# -----------------------------------------------------------------------------
34+
# Admin (Telegram user IDs; get yours from @userinfobot)
35+
# -----------------------------------------------------------------------------
36+
BOT_OWNER_ID=123456789
37+
ADMIN_USERS=123456789,987654321
38+
39+
# -----------------------------------------------------------------------------
40+
# Webhook mode (optional; if set, polling is disabled)
41+
# Set USE_WEBHOOK=true and TELEGRAM_WEBHOOK_URL to the full HTTPS URL
42+
# that Telegram will POST updates to (e.g. https://tg.licensechain.app/api/webhook).
43+
# -----------------------------------------------------------------------------
44+
# USE_WEBHOOK=false
45+
# TELEGRAM_WEBHOOK_URL=https://your-domain.com/api/webhook
46+
# WEBHOOK_SECRET=optional_secret_for_x_telegram_bot_api_secret_token
47+
48+
# -----------------------------------------------------------------------------
49+
# Dashboard linked user (optional; for profile tier/role when Telegram linked)
50+
# -----------------------------------------------------------------------------
51+
# LICENSECHAIN_DASHBOARD_URL=https://dashboard.licensechain.app
52+
# DASHBOARD_URL=https://dashboard.licensechain.app
53+
# BOT_LINKED_USER_SECRET=shared_secret_for_linked_user_api

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Summary
2+
3+
<!-- What changed (commands, client, DB). -->
4+
5+
## Related issue
6+
7+
Closes #____
8+
9+
## API alignment
10+
11+
- [ ] Uses `POST /v1/licenses/verify` with body field `key`.
12+
- [ ] List/aggregate commands do not expose other users’ licenses.
13+
14+
## Vendored API helper
15+
16+
- [ ] If editing `src/client/licensechainApiNormalize.js`: mirror the same bytes in `LicenseChain-Discord-Bot`, `Bots/shared/licensechain-api-normalize/index.js`, and `api/src/contracts/bot-license-contracts.ts` + tests if shapes change.
17+
18+
## Verification
19+
20+
- [ ] Smoke test: `/validate` and `/list` against staging API.
21+
- [ ] CI / tests green.

.github/workflows/ci.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [main, develop, master]
6+
pull_request:
7+
branches: [main, develop, master]
8+
9+
concurrency:
10+
group: tg-bot-ci-${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
NODE_VERSION: '20'
15+
16+
jobs:
17+
lint:
18+
name: ESLint
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
cache: npm
27+
28+
- run: npm ci
29+
30+
- run: npm run lint
31+
32+
test:
33+
name: Unit tests (Jest)
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- uses: actions/setup-node@v4
39+
with:
40+
node-version: ${{ env.NODE_VERSION }}
41+
cache: npm
42+
43+
- run: npm ci
44+
45+
- run: npm test
46+
env:
47+
CI: true
48+
49+
security:
50+
name: npm audit (high+)
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- uses: actions/setup-node@v4
56+
with:
57+
node-version: ${{ env.NODE_VERSION }}
58+
cache: npm
59+
60+
- run: npm ci
61+
62+
- run: npm audit --audit-level=high
63+
64+
smoke:
65+
name: Entry smoke
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v4
69+
70+
- uses: actions/setup-node@v4
71+
with:
72+
node-version: ${{ env.NODE_VERSION }}
73+
cache: npm
74+
75+
- run: npm ci
76+
77+
- name: Syntax check entrypoint
78+
run: node --check src/index.js

.gitignore

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Dependencies
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Environment variables
8+
.env
9+
.env.local
10+
.env.development.local
11+
.env.test.local
12+
.env.production.local
13+
14+
# Logs
15+
logs/*.log
16+
*.log
17+
npm-debug.log*
18+
yarn-debug.log*
19+
yarn-error.log*
20+
lerna-debug.log*
21+
22+
# Runtime data
23+
pids/
24+
*.pid
25+
*.seed
26+
*.pid.lock
27+
28+
# Coverage directory used by tools like istanbul
29+
coverage/
30+
*.lcov
31+
32+
# nyc test coverage
33+
.nyc_output
34+
35+
# Grunt intermediate storage
36+
.grunt
37+
38+
# Bower dependency directory
39+
bower_components
40+
41+
# node-waf configuration
42+
.lock-wscript
43+
44+
# Compiled binary addons
45+
build/Release
46+
47+
# Dependency directories
48+
node_modules/
49+
jspm_packages/
50+
51+
# TypeScript v1 declaration files
52+
typings/
53+
54+
# TypeScript cache
55+
*.tsbuildinfo
56+
57+
# Optional npm cache directory
58+
.npm
59+
60+
# Optional eslint cache
61+
.eslintcache
62+
63+
# Prisma
64+
prisma/migrations/*.sql
65+
prisma/*.db
66+
prisma/*.db-journal
67+
68+
# Microbundle cache
69+
.rpt2_cache/
70+
.rts2_cache_cjs/
71+
.rts2_cache_es/
72+
.rts2_cache_umd/
73+
74+
# Optional REPL history
75+
.node_repl_history
76+
77+
# Output of 'npm pack'
78+
*.tgz
79+
80+
# Yarn Integrity file
81+
.yarn-integrity
82+
83+
# parcel-bundler cache
84+
.cache
85+
.parcel-cache
86+
87+
# Next.js build output
88+
.next
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
public
97+
98+
# Storybook build outputs
99+
.out
100+
.storybook-out
101+
102+
# Temporary folders
103+
tmp/
104+
temp/
105+
106+
# Editor directories and files
107+
.vscode/
108+
.idea/
109+
*.swp
110+
*.swo
111+
*~
112+
113+
# OS generated files
114+
.DS_Store
115+
.DS_Store?
116+
._*
117+
.Spotlight-V100
118+
.Trashes
119+
ehthumbs.db
120+
Thumbs.db
121+
122+
# Droplet deploy — private SSH key (never commit)
123+
deploy/ssh/droplet_licensechain_tg_bot_ed25519
124+
125+
# Telegram Bot specific
126+
config.json
127+
data/
128+
backups/
129+
*.db
130+
131+
# Another files
132+
.cursorindexingignore
133+
.specstory/
134+
.dockerignore

CHANGELOG.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Changelog — LicenseChain Telegram Bot
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
-
12+
13+
### Changed
14+
-
15+
16+
### Fixed
17+
-
18+
19+
### Removed
20+
- Unused dependencies: `moment`, `lodash`
21+
- Unused bot wrapper files: `DiscordBot.js`, `TelegramBot.js`
22+
23+
## [1.0.1] - 2026-02-22
24+
25+
### Fixed
26+
27+
- Fixed ESLint configuration module error by renaming `eslint.config.js` to `eslint.config.mjs`
28+
- Fixed all lint errors: unreachable code, undefined variables, duplicate cases, unnecessary try/catch
29+
- Fixed `loadingMsg` undefined errors in multiple command files (info, update, validate, errors, licenses, revoke)
30+
- Fixed duplicate case labels in MessageHandler.js
31+
- Fixed duplicate function definition `handleCreateCallback`
32+
- Fixed `hasOwnProperty` usage to use `Object.prototype.hasOwnProperty.call()`
33+
- Fixed duplicate else-if condition in licenses.js
34+
- Updated test script to use `--passWithNoTests` flag
35+
36+
### Changed
37+
38+
- CI/CD workflow now passes all checks (lint, test, build)
39+
- ESLint configuration now properly recognized as ES module
40+
41+
## [1.0.0] - 2026-02-21
42+
43+
### Added
44+
45+
- **Dual mode: polling and webhook**
46+
- Default: long-polling (24/7 process fetching updates from Telegram).
47+
- Optional webhook: set `USE_WEBHOOK=true` and `TELEGRAM_WEBHOOK_URL` to the full HTTPS URL; bot registers `setWebHook` on startup and `deleteWebHook` on shutdown.
48+
- Optional `WEBHOOK_SECRET` for `X-Telegram-Bot-Api-Secret-Token` verification.
49+
- `POST /webhook` returns 200 immediately and processes updates asynchronously.
50+
- **Health endpoint** now includes `mode: "polling"` or `mode: "webhook"`.
51+
- **Validator** module: license key, email, user id, integer, period, and display sanitization; used in validate, create, extend, revoke, update, usage.
52+
- **PermissionManager**: owner (`BOT_OWNER_ID`) and admin list (`ADMIN_USERS`); used for all admin-only commands and callbacks.
53+
- **Admin panel**: Products (list apps from API), Webhooks (list webhooks when API supports), Health (API health check).
54+
- **Structured help**: per-command usage, examples, and permission; `/help <command>`.
55+
- **Usage period** validation: 7d, 30d, 90d, 1y via `Validator.validatePeriod`.
56+
- **PostgreSQL-only** persistence (Supabase); SQLite no longer supported.
57+
- **Startup validation**: `TELEGRAM_TOKEN` required (exit if missing); warning if `LICENSE_CHAIN_API_KEY` is missing.
58+
- **Documentation**: README (env, modes, Docker, commands), shared hosting guide, cPanel bots setup, ROADMAP and alignment doc.
59+
60+
### Changed
61+
62+
- Bot constructor uses `{ polling: !USE_WEBHOOK }` so polling is disabled when webhook is enabled.
63+
- Express app uses `express.json()` for webhook body parsing.
64+
- Graceful shutdown: `deleteWebHook()` in webhook mode; `stopPolling()` in polling mode.
65+
- License changed from Elastic License 2.0 to Eclipse Public License 2.0.
66+
67+
### Fixed
68+
69+
- N/A (initial consolidated release).
70+
71+
---
72+
73+
[Unreleased]: https://github.com/licensechain/telegram-bot/compare/v1.0.1...HEAD
74+
[1.0.1]: https://github.com/licensechain/telegram-bot/compare/v1.0.0...v1.0.1
75+
[1.0.0]: https://github.com/licensechain/telegram-bot/releases/tag/v1.0.0

0 commit comments

Comments
 (0)