mirror of
https://github.com/tiennm99/openai-status-bot.git
synced 2026-07-15 18:21:48 +00:00
Swap the Redis datastore for MongoDB via mongo-driver v2. New internal/mongostore mirrors the old redisstore type/constant names so consumers change only the import qualifier; document model collapses the multi-key subscriber/settings and per-event delivery sets into single-doc operations and a TTL-indexed delivery collection. Config now requires MONGODB_URI (Atlas) with MONGODB_DATABASE selecting dev vs prod on one cluster; REDIS_URL removed. Compose files run bot-only against Atlas. Default tests stay Docker-free (poller/bot use fakes, mongostore unit tests are pure-logic); a gated //go:build integration suite covers the real backend via testcontainers.
1.5 KiB
1.5 KiB
Setup Guide
Prerequisites
- Go 1.24+
- MongoDB Atlas cluster (managed, no local MongoDB service required)
- Telegram bot token from BotFather
Local Docker Run
cp .env.example .env
# set TELEGRAM_BOT_TOKEN in .env
# set MONGODB_URI to your MongoDB Atlas connection string
# docker compose sets MONGODB_DATABASE=openai_status_bot_dev for local development
docker compose up --build
The Docker Compose service connects to MongoDB Atlas; there is no bundled local MongoDB. Ensure MONGODB_URI is set in .env.
Bot-Only Docker Run
Use this for production deployment:
cp .env.example .env
# set TELEGRAM_BOT_TOKEN in .env
# set MONGODB_URI to your MongoDB Atlas connection string
# MONGODB_DATABASE defaults to openai_status_bot (production)
docker compose -f docker-compose.bot.yml up -d --build
Local Go Run
cp .env.example .env
# set TELEGRAM_BOT_TOKEN in .env
# set MONGODB_URI to your MongoDB Atlas connection string
# export TELEGRAM_BOT_TOKEN or source .env with your shell workflow
# MONGODB_DATABASE defaults to openai_status_bot
go run ./cmd/openai-status-bot
MongoDB Atlas connection is required; there is no local MongoDB fallback.
Verification
go test ./...
go build -o /tmp/openai-status-bot ./cmd/openai-status-bot
Then send /start to the Telegram bot and run /status. If the same token was previously used by a webhook deployment, startup clears that webhook before long polling begins.
Docker images include a health check against http://127.0.0.1:8080/healthz inside the container.