#!/usr/bin/env python3 """Send the 8:00 family silent-reading time reminder without cron wrappers.""" from __future__ import annotations import json import sys import urllib.request CHAT_ID = "120363424746547296@g.us" BRIDGE_URL = "http://127.0.0.1:3000/send" MESSAGE = ( "It’s 8:00 — silent reading time. Let’s sit together in the living room, " "listen to 3–5 chapters of the audio Bible, talk a little, pray, " "then read quietly until bed." ) def send_whatsapp(message: str) -> None: payload = json.dumps({"chatId": CHAT_ID, "message": message}).encode("utf-8") req = urllib.request.Request( BRIDGE_URL, data=payload, headers={"Content-Type": "application/json"}, method="POST", ) with urllib.request.urlopen(req, timeout=30) as resp: body = resp.read().decode("utf-8", errors="replace") if resp.status != 200: raise RuntimeError(f"WhatsApp bridge returned HTTP {resp.status}: {body}") def main() -> int: try: send_whatsapp(MESSAGE) return 0 except Exception as exc: print(f"Silent reading time WhatsApp send failed: {exc}", file=sys.stderr) return 1 if __name__ == "__main__": raise SystemExit(main())