Telegram bot for managing squash court payments in a community.
The bot automates session registration, cost calculation, and payment tracking. Detailed architecture is described in docs/architecture.md.
-
Clone the repository
-
Install dependencies:
npm install
-
Create environment files:
- Copy
.env.exampleto.env.prodand fill in production values - Copy
.env.exampleto.env.testand fill in test values - Both files use the same variable names (e.g.,
TELEGRAM_BOT_TOKEN) - Production values go in
.env.prod, test values go in.env.test - See
.env.examplefor the full list of required variables
- Copy
-
Run in development mode:
# Production environment npm run dev:prod # Test environment npm run dev:test
Or via Docker:
docker-compose up
The bot supports two environments: production and test. Each environment uses different bot tokens and databases.
npm run dev- run in development mode with hot-reload (defaults to production)npm run dev:prod- run in development mode with production environmentnpm run dev:test- run in development mode with test environmentnpm run build- build TypeScriptnpm run start- run the built application (defaults to production)npm run start:prod- run the built application in production modenpm run start:test- run the built application in test mode
npm run lint- check code with linternpm run lint:fix- automatically fix linter errorsnpm run format- format codenpm run type-check- type check without buildingnpm test- run testsnpm run test:watch- run tests in watch mode
- Create
.env.testfile based on.env.exampleand fill in test values:TELEGRAM_BOT_TOKEN- test bot tokenTELEGRAM_TEST_CHAT_ID- test chat ID- See docs/manual-testing.md for details
- Start the bot in test mode:
npm run dev:test
- Open the test chat in Telegram
- Send
/test infoto check the environment
Detailed setup and testing instructions can be found in docs/manual-testing.md.
/getchatid- get Chat ID (works in any chat)/test info- test environment information (only in test chat)/test config- configuration check (only in test chat)/test scaffold create <day> <time> <courts>- create scaffold in test mode
src/
bot/ # Telegram bot logic
api/ # REST endpoints for n8n
services/ # Business logic
types/ # TypeScript types
utils/ # Helpers
config/ # Configuration
GET /health- healthcheckPOST /check-events- check and create events (requires API key)POST /check-payments- check and send reminders (requires API key)
ISC