sync: auto-sync from GURU-5070 at 2026-07-01 15:49:56
Author: Mike Swanson Machine: GURU-5070 Timestamp: 2026-07-01 15:49:56
This commit is contained in:
@@ -35,6 +35,13 @@ if [ -z "$MSG" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Discord caps message content at 2000 chars (code 50035 on overflow). Alerts
|
||||
# are one-liners by contract — truncate rather than chunk.
|
||||
if [ "${#MSG}" -gt 1900 ]; then
|
||||
MSG="${MSG:0:1900} ...[truncated]"
|
||||
echo "[WARNING] post-bot-alert: message over 1900 chars — truncated" >&2
|
||||
fi
|
||||
|
||||
# --- channel routing ---
|
||||
# Optional 2nd arg: "dev"/"bot" keyword, a raw channel id, or omit for auto.
|
||||
# Auto: RMM/Dev-category prefixes -> #dev-alerts (private); everything else
|
||||
@@ -67,14 +74,15 @@ if [ -z "$TOKEN" ] || [ "$TOKEN" = "null" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# --- post (jq builds JSON so the message is safely escaped) ---
|
||||
PAYLOAD="$(jq -nc --arg c "$MSG" '{content: $c}')"
|
||||
RESP="$(curl -s -m 15 -w $'\n%{http_code}' \
|
||||
# --- post (jq builds the JSON; piped to curl via STDIN, never argv — a payload
|
||||
# passed as a command-line arg on Windows goes through the argv encoding layer,
|
||||
# which mangles non-ASCII chars into invalid JSON -> Discord 50109) ---
|
||||
RESP="$(jq -nc --arg c "$MSG" '{content: $c}' | curl -s -m 15 -w $'\n%{http_code}' \
|
||||
-X POST "https://discord.com/api/v10/channels/${CHANNEL_ID}/messages" \
|
||||
-H "Authorization: Bot ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "User-Agent: ClaudeToolsBot (claudetools, 1.0)" \
|
||||
--data-binary "$PAYLOAD" 2>/dev/null)"
|
||||
--data-binary @- 2>/dev/null)"
|
||||
|
||||
HTTP="$(printf '%s' "$RESP" | tail -n1)"
|
||||
BODY="$(printf '%s' "$RESP" | sed '$d')"
|
||||
|
||||
Reference in New Issue
Block a user