mirror of
https://github.com/tiennm99/openai-status-bot.git
synced 2026-10-11 03:13:41 +00:00
1.4 KiB
1.4 KiB
System Architecture
Overview
openai-status-bot is one Go process with two loops:
- Telegram long polling loop for user commands.
- OpenAI status polling loop, default every minute.
Redis stores subscribers and polling checkpoints.
Data Flow
- User sends
/startin Telegram. - Bot stores chat ID and optional topic thread ID in Redis.
- Poller fetches OpenAI status JSON:
GET /api/v2/summary.jsonGET /api/v2/incidents.json
- Poller compares fetched state with Redis checkpoints.
- New incident updates or component status changes are sent to all subscribers.
Redis Keys
| Key | Type | Purpose |
|---|---|---|
openai-status:subscribers |
set | Telegram chat or topic subscribers |
openai-status:component-statuses |
hash | Last seen component status by component ID |
openai-status:incident-updates |
set | Seen incident update IDs |
openai-status:initialized |
string | Baseline seed marker |
Subscriber set members are chatID or chatID:threadID.
Runtime
The service uses Telegram getUpdates, so it does not need a public webhook URL. Docker Compose starts Redis and the bot.
Failure Behavior
- First successful poll seeds state without notification.
- OpenAI fetch failures are logged and retried on the next interval.
- Telegram send failures are logged; other subscribers still receive messages.
- Redis connection failure at startup exits the process.