Download source/scripts/watch_board.sh from rca-umb/five-desks: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/datasets/rca-umb/five-desks/resolve/main/source/scripts/watch_board.sh
- Command line
-
hf download hf://datasets/rca-umb/five-desks/source/scripts/watch_board.sh
-
curl -L -o watch_board.sh https://huggingface.co/datasets/rca-umb/five-desks/resolve/main/source/scripts/watch_board.sh
1.15 kB
| # 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" | |