Add stale-donor alerting with per-route recipients and delivery fallback

New STALE_DONOR_ALERT_DAYS (.env, global threshold, 0=off) + per-route
stale_alert_enabled/stale_alert_ids (routes.json). Checked once per route
per cycle against MAX(posted_at) in the DB - self-resetting via a single
route_alerts.stale_alert_sent_at timestamp compared against the last post
time, so it fires once per quiet spell and re-arms automatically once the
donor posts again, no separate ack/clear step needed.

If a configured stale_alert_ids recipient can't be reached (never started
a chat with the bot), the global TG_ADMIN_IDS get a separate notice about
that delivery failure instead of the alert silently vanishing.
This commit is contained in:
2026-08-18 19:13:01 +05:00
parent ab69fff33b
commit 3a086d9e54
8 changed files with 180 additions and 10 deletions
+4 -2
View File
@@ -1,6 +1,6 @@
[
// redairsoft_main
// redairsoft_main - с оповещением о простое донора (нужен STALE_DONOR_ALERT_DAYS в .env)
{
"id": "redairsoft_main",
"name": "Red Airsoft (основная группа)",
@@ -8,7 +8,9 @@
"tg_chat_id": "-1001303630155",
"tg_enabled": true,
"max_chat_id": "123456",
"max_enabled": true
"max_enabled": true,
"stale_alert_enabled": true,
"stale_alert_ids": [123456789]
},
// second_donor - только в TG, MAX выключен