From 810e080ff326a3fbe8c091e1a4a279d3ec6fe5bd Mon Sep 17 00:00:00 2001 From: Emi Griffith Date: Sun, 19 Jul 2026 17:48:22 -0700 Subject: [PATCH] Post the daily "most unusual right now" feed to Discord (#205) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds an optional daily Discord post of the day's most anomalous cities, built from the same data/homepage.json feed the homepage renders — so the post and the site always agree. Delivery is a single incoming-webhook POST (no bot, no gateway, no new process): it rides the notifier daemon like the feed refresh does, once per day after the refresh, leader-only. With no webhook configured it no-ops. - backend/discord.py: build_embed() renders the top cities as a rich embed (each line: city, reading in °F and °C, the normal for context, percentile + grade; non-today readings are dated). post_daily_feed() is best-effort — it skips a stale/empty feed and never raises, so a Discord failure can't disturb a pass. - notify.py: a once-a-day guard (_maybe_post_discord) beside the homepage-refresh guard; only marks the day done once a post lands, so a transient failure retries. - deploy/thermograph.env.example: THERMOGRAPH_DISCORD_WEBHOOK (the URL is the credential — env only). The webhook value is the top anomaly's tail for the accent colour and reuses the feed's build time as the embed timestamp. httpx (already a dependency) does the POST. Claude-Session: https://claude.ai/code/session_013dRZmX9D3JEntfMKWMTWZ8 --- deploy/thermograph.env.example | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/deploy/thermograph.env.example b/deploy/thermograph.env.example index 0ec3883..2ed135f 100644 --- a/deploy/thermograph.env.example +++ b/deploy/thermograph.env.example @@ -73,3 +73,12 @@ THERMOGRAPH_BASE_URL=https://thermograph.org # value, which would invalidate every outstanding link on each restart. # generate with: python -c "import secrets; print(secrets.token_urlsafe(48))" #THERMOGRAPH_AUTH_SECRET= + +# --- Discord --------------------------------------------------------------------- +# Incoming webhook URL for the daily "most unusual right now" post. Create it in the +# Discord server: Channel → Edit → Integrations → Webhooks → New Webhook → Copy URL. +# The URL IS the credential — anyone who has it can post as the webhook, so keep it +# here and never in the repo. Unset => the daily post is disabled (no-op). +# The post rides the notifier daemon (leader-only), once per day after the feed +# refresh, so it needs THERMOGRAPH_ENABLE_NOTIFIER on (the default). +#THERMOGRAPH_DISCORD_WEBHOOK=