five-desks / source /scripts /watch_board.sh
rca-umb's picture
Five Desks v3: train on the eight caveat tasks; add v1/v2 results
453b36d verified
Raw History Blame Contribute Delete
1.15 kB
#!/bin/sh
# Poll the arena message board every 5 minutes (up to 24 h). When messages newer than the last seen id appear
# (other than our own), print them, record the newest id and exit, so a background run notifies on exit.
# Usage: sh scripts/watch_board.sh (state in reports/board-last-id)
cd "$(dirname "$0")/.." || exit 1
STATE=reports/board-last-id
TMP=$(mktemp)
for i in $(seq 1 288); do
if curl -fsS https://openenvarena-arena.hf.space/api/openenv/messages -o "$TMP" 2>/dev/null; then
python3 -I - "$TMP" "$STATE" <<'PY' && { rm -f "$TMP"; exit 0; }
import json, sys
d = json.load(open(sys.argv[1])); msgs = d.get("messages", d) if isinstance(d, dict) else d
try: last = int(open(sys.argv[2]).read())
except Exception: last = max(m["id"] for m in msgs)
new = sorted((m for m in msgs if m["id"] > last), key=lambda m: m["id"])
if new: open(sys.argv[2], "w").write(str(new[-1]["id"]))
others = [m for m in new if m.get("author") != "rca-umb"]
for m in others: print(f'#{m["id"]} {m.get("author")}: {m["body"][:600]}')
sys.exit(0 if others else 1)
PY
fi
sleep 300
done
rm -f "$TMP"; echo "board watcher: 24 h without new messages"