A Telegram bot built with Express.js and TypeScript that provides notifications for Jenkins builds and Docker events.
- 🤖 Telegram bot interface
- 🏗️ Jenkins build notifications
- 🐳 Docker event notifications
- 👥 User management system
- 🔐 Admin controls
- 💾 SQLite database storage
- Node.js (v20 or higher)
- npm
- Docker (optional, for containerized deployment)
- Clone the repository
- Install dependencies:
npm install- Create a Telegram bot and get your bot token from @BotFather
- Replace the token in
.envwith your bot token and the default admin chat ID
Start the development server with hot reload:
npm run devBuild the project:
npm run buildStart the production server:
npm startThe test.sh script sends a test webhook message to the server.
./test.sh <host>Example:
./test.sh http://localhost:2317The server will respond with a JSON object containing the status and the current time.
curl http://localhost:2317/Build the Docker image:
docker build -t martlet-bot .Run the Docker container:
bash
docker run -d
-p 2317:2317
-v /path/to/data:/app/data
martlet
/start- Register with the bot/subscribe- Request subscription to notifications/unsubscribe- Unsubscribe from notifications/getchatid- Get your chat ID/makeadmin- (Admin only) Make a user an admin/makesubscriber- (Admin only) Approve user subscription/listrequests- (Admin only) List pending subscription requests
- URL:
/jenkins-webhook - Method: POST
- Receives Jenkins build notifications and forwards them to subscribed users
- URL:
/docker-webhook - Method: POST
- Receives Docker events and forwards them to subscribed users
- Use
Stevedoreto listen to Docker events and send them to the webhook
src/- Source codeindex.ts- Main application entry pointdb.ts- Database operationstypes.ts- TypeScript type definitionswebhooks/- Webhook handlersjenkins.ts- Jenkins webhook handlerdocker.ts- Docker webhook handler
data/- SQLite database storagedist/- Compiled JavaScript output
PORT- Server port (default: 2317)HOST- Server host (default: 0.0.0.0)TELEGRAM_BOT_TOKEN- Telegram bot tokenDEFAULT_ADMIN_CHAT_ID- Default admin chat ID
ISC
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request