Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0141G6xqLeNRYEtviLWSB5Up
16 lines
1.1 KiB
Bash
Executable File
16 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Answer a player's report; the reply appears under it in their hall.
|
|
# deploy/report-reply.sh <host> <reportId> <resolved|by-design|open> <text...>
|
|
set -euo pipefail
|
|
HOST="${1:?usage: report-reply.sh <host> <reportId> <status> <text...>}"
|
|
REPORT_ID="${2:?usage: report-reply.sh <host> <reportId> <status> <text...>}"
|
|
STATUS="${3:?usage: report-reply.sh <host> <reportId> <status> <text...>}"
|
|
shift 3
|
|
TEXT="$*"
|
|
case "$STATUS" in resolved|by-design|open) ;; *) echo "status must be resolved, by-design, or open" >&2; exit 1;; esac
|
|
case "$REPORT_ID" in *[!0-9a-f]*|"") echo "a report id is eight hex characters" >&2; exit 1;; esac
|
|
LINE=$(REPORT_ID="$REPORT_ID" STATUS="$STATUS" TEXT="$TEXT" python3 -c '
|
|
import json, os, datetime
|
|
print(json.dumps({"reportId": os.environ["REPORT_ID"], "at": datetime.datetime.now(datetime.timezone.utc).isoformat().replace("+00:00", "Z"), "status": os.environ["STATUS"], "text": os.environ["TEXT"]}))')
|
|
printf '%s\n' "$LINE" | ssh "root@$HOST" 'cat >> /var/lib/__SLUG__/feedback.jsonl && chown __SLUG__:__SLUG__ /var/lib/__SLUG__/feedback.jsonl && tail -1 /var/lib/__SLUG__/feedback.jsonl'
|