diff --git a/.claude/commands/rmm.md b/.claude/commands/rmm.md index a70491c..3abd176 100644 --- a/.claude/commands/rmm.md +++ b/.claude/commands/rmm.md @@ -60,7 +60,7 @@ Interact with the GuruRMM agent fleet: list agents, run remote commands (PowerSh **Heredoc payloads — always use `--data-binary @-` and `<<'JSON'` for static payloads.** On Windows, the Write tool and Git Bash resolve `/tmp/foo.json` to different directories. Heredoc avoids the file handoff entirely. Use `<<'JSON'` (single-quoted) for static payloads that contain no shell variables; use `<") diff --git a/.claude/scripts/post-bot-alert.sh b/.claude/scripts/post-bot-alert.sh index 53a705f..9b7dacf 100644 --- a/.claude/scripts/post-bot-alert.sh +++ b/.claude/scripts/post-bot-alert.sh @@ -1,8 +1,15 @@ #!/usr/bin/env bash -# post-bot-alert.sh — post a one-line message to the Discord #bot-alerts channel. +# post-bot-alert.sh — post a one-line message to a Discord alert channel. +# +# Routing: #bot-alerts (default; Syncro + general, whole team) vs #dev-alerts +# (private; RMM/Dev alerts, Howard + Mike only). Auto-routes by message prefix: +# [RMM] [DEPLOY] [DEV] [BUILD] [GURURMM] [SMARTBADGE-WATCH] -> #dev-alerts; +# everything else (incl. [SYNCRO]) -> #bot-alerts. Override with a 2nd arg. # # Usage: -# bash post-bot-alert.sh "message text" +# bash post-bot-alert.sh "message text" # auto-route by prefix +# bash post-bot-alert.sh "message text" dev # force #dev-alerts +# bash post-bot-alert.sh "message text" bot # force #bot-alerts # echo "message text" | bash post-bot-alert.sh # # Token resolution (first hit wins): @@ -16,7 +23,8 @@ set -u -CHANNEL_ID="624710699771232265" # #bot-alerts (Arizona Computer Guru guild) +BOT_CHANNEL_ID="624710699771232265" # #bot-alerts — default (Syncro + general; whole team) +DEV_CHANNEL_ID="1509998508198068484" # #dev-alerts — private RMM/Dev alerts (Howard + Mike only) ROOT="${CLAUDETOOLS_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}" # --- message (arg or stdin) --- @@ -27,6 +35,23 @@ if [ -z "$MSG" ]; then exit 0 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 +# (Syncro, general) -> #bot-alerts. Keeps existing call sites correct unchanged. +TARGET="${2:-auto}" +case "$TARGET" in + dev|dev-alerts) CHANNEL_ID="$DEV_CHANNEL_ID"; CHANNEL_NAME="#dev-alerts" ;; + bot|bot-alerts) CHANNEL_ID="$BOT_CHANNEL_ID"; CHANNEL_NAME="#bot-alerts" ;; + auto|"") + if printf '%s' "$MSG" | grep -qiE '^\[(RMM|DEPLOY|DEV|BUILD|GURURMM|SMARTBADGE-WATCH)\b'; then + CHANNEL_ID="$DEV_CHANNEL_ID"; CHANNEL_NAME="#dev-alerts" + else + CHANNEL_ID="$BOT_CHANNEL_ID"; CHANNEL_NAME="#bot-alerts" + fi ;; + *) CHANNEL_ID="$TARGET"; CHANNEL_NAME="channel ${TARGET}" ;; +esac + # --- token: vault first, then .env --- TOKEN="$(bash "$ROOT/.claude/scripts/vault.sh" get-field \ projects/discord-bot/bot-token.sops.yaml credentials.bot_token 2>/dev/null)" @@ -56,7 +81,7 @@ BODY="$(printf '%s' "$RESP" | sed '$d')" if [ "$HTTP" = "200" ]; then MID="$(printf '%s' "$BODY" | jq -r '.id // empty' 2>/dev/null)" - echo "[OK] post-bot-alert: posted to #bot-alerts (message_id=${MID})" + echo "[OK] post-bot-alert: posted to ${CHANNEL_NAME} (message_id=${MID})" exit 0 fi