#!/usr/bin/env bash
set -euo pipefail

# Legacy helper (not currently used). Kept for optional local testing.
# Prints NEW_MAIL|date|from|subject lines for any newly-seen ToAssistant messages.

DATA=$(/home/isthekid/.openclaw/workspace/bin/check_toassistant.py)

python3 - "$DATA" <<'PY'
import json, sys
raw = sys.argv[1]
j = json.loads(raw)
alerts = j.get('alerts') or []
for a in alerts:
  subj=a.get('subject','(no subject)')
  frm=a.get('from','')
  dt=a.get('date','')
  print(f"NEW_MAIL|{dt}|{frm}|{subj}")
PY
