Files
b3nw 3b7d6bb67c Initial commit: custom OpenClaw skills from docker-test
- 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.
2026-02-16 15:32:44 +00:00

64 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Check CapMetro service changes for Route 5 and Route 500
# Returns JSON with new changes since last check
set -e
STATE_FILE="${STATE_FILE:-memory/capmetro-check-state.json}"
WORKSPACE="${WORKSPACE:-/home/node/.openclaw/workspace}"
cd "$WORKSPACE"
# Initialize state if missing
if [ ! -f "$STATE_FILE" ]; then
mkdir -p "$(dirname "$STATE_FILE")"
echo '{"lastCheck":"1970-01-01T00:00:00Z","seenChanges":[]}' > "$STATE_FILE"
fi
NOW=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Fetch current service changes page
CHANGES=$(curl -s "https://www.capmetro.org/servicechange" | \
grep -oP 'href="/servicechange/[^"]+' | \
sed 's/href="//' | \
sort -u)
# Check each change period for Route 5 or Route 500
RELEVANT_CHANGES='[]'
for change_url in $CHANGES; do
FULL_URL="https://www.capmetro.org$change_url"
CONTENT=$(curl -s "$FULL_URL")
# Check if Route 5 or Route 500 mentioned
if echo "$CONTENT" | grep -qiE "(Route 5[^0-9]|Route 500)"; then
TITLE=$(echo "$CONTENT" | grep -oP '<title>\K[^<]+' | head -1)
RELEVANT_CHANGES=$(echo "$RELEVANT_CHANGES" | jq --arg url "$FULL_URL" --arg title "$TITLE" \
'. += [{"url":$url, "title":$title, "id":$url}]')
fi
done
# Load seen changes
SEEN=$(jq -r '.seenChanges // []' "$STATE_FILE")
# Find new changes
NEW_CHANGES=$(echo "$RELEVANT_CHANGES" | jq --argjson seen "$SEEN" '[
.[] | select(.id as $id | $seen | index($id) | not)
]')
NEW_COUNT=$(echo "$NEW_CHANGES" | jq 'length')
# Update state
ALL_IDS=$(echo "$RELEVANT_CHANGES" | jq -r '[.[].id]')
jq -n \
--arg now "$NOW" \
--argjson ids "$ALL_IDS" \
'{lastCheck:$now, seenChanges:$ids}' > "$STATE_FILE"
# Output
if [ "$NEW_COUNT" -eq 0 ]; then
echo '{"hasNew":false}'
exit 0
fi
jq -n --argjson changes "$NEW_CHANGES" '{hasNew:true, newChanges:$changes}'