Files
reyna-cli/backup/macmini-automation-baseline-2026-08-03/hermes-scripts/family_silent_reading_time_800.py
T
2026-08-03 11:47:09 -04:00

43 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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())