- workspace: capmetro-monitor, github-notifications, model-selector - workspace-security: vt-monitor, monitor-unauthorized - workspace-home: cron-manager, monitor-unauthorized - extensions: vt-sentinel (VT-Sentinel plugin) Includes sync.sh for pull/push, README, AGENTS.md, .gitignore.
42 lines
1.4 KiB
Bash
Executable File
42 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Create Discord forum thread for a plugin update notification
|
|
# Usage: plugin-update-thread.sh "plugin-name" "old_version" "new_version" "install_cmd"
|
|
set -e
|
|
|
|
PLUGIN="$1"
|
|
OLD_VER="$2"
|
|
NEW_VER="$3"
|
|
INSTALL_CMD="$4"
|
|
CHANNEL_ID="1470849667737714851"
|
|
|
|
TOKEN=$(printenv DISCORD_BOT_TOKEN)
|
|
if [ -z "$TOKEN" ]; then
|
|
echo '{"error":"DISCORD_BOT_TOKEN not set"}'
|
|
exit 1
|
|
fi
|
|
|
|
# Build content with real newlines using printf
|
|
CONTENT=$(printf '📦 **Plugin Update Available**\n\n**Plugin:** `%s`\n**Current:** %s\n**Available:** %s\n\n**Install:**\n```\n%s\n```\n\n---\n*Detected by VT-Sentinel Monitor*' \
|
|
"$PLUGIN" "$OLD_VER" "$NEW_VER" "$INSTALL_CMD")
|
|
|
|
THREAD_NAME=$(printf '📦 %s — %s → %s' "$PLUGIN" "$OLD_VER" "$NEW_VER")
|
|
|
|
# Use jq to properly encode the content with real newlines
|
|
PAYLOAD=$(jq -n \
|
|
--arg name "$THREAD_NAME" \
|
|
--arg content "$CONTENT" \
|
|
'{name: $name, message: {content: $content}, auto_archive_duration: 1440}')
|
|
|
|
RESULT=$(curl -s -X POST \
|
|
-H "Authorization: Bot $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$PAYLOAD" \
|
|
"https://discord.com/api/v10/channels/${CHANNEL_ID}/threads")
|
|
|
|
THREAD_ID=$(echo "$RESULT" | jq -r '.id // empty')
|
|
if [ -n "$THREAD_ID" ]; then
|
|
echo "{\"ok\":true,\"threadId\":\"$THREAD_ID\",\"plugin\":\"$PLUGIN\"}"
|
|
else
|
|
echo "{\"ok\":false,\"error\":$(echo "$RESULT" | jq -c '.')}"
|
|
fi
|