#!/bin/bash # AI Newsletter Digest - Multi-Channel Sender # Sends digest to both Telegram and Discord SCRIPT_DIR="/home/openclaw/.openclaw/workspace/automations/ai-newsletter-digest" DIGEST_SCRIPT="$SCRIPT_DIR/daily-digest.sh" # Generate the digest RESULT=$($DIGEST_SCRIPT 2>/dev/null) # Check if we have newsletters if echo "$RESULT" | grep -q '"count": 0' || echo "$RESULT" | grep -q 'No AI newsletters'; then echo "No newsletters to send" exit 0 fi # Parse the digest data COUNT=$(echo "$RESULT" | python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('count',0))") SOURCES=$(echo "$RESULT" | python3 -c "import json,sys; d=json.load(sys.stdin); print(', '.join(d.get('sources',[])))") if [ "$COUNT" -eq 0 ]; then exit 0 fi # Format the message MESSAGE="🤖 Daily AI Newsletter Digest Found $COUNT AI newsletters: • $SOURCES $(echo "$RESULT" | python3 -c " import json,sys d=json.load(sys.stdin) for n in d.get('newsletters',[]): print(f\"📧 {n.get('subject','')} - {n.get('from','')}\") ") Full analysis available - reply for details!" # Send to Telegram openclaw message send --channel telegram --message "$MESSAGE" 2>/dev/null || echo "Telegram send failed" >&2 # Send to Discord (#krilly channel) openclaw message send --channel discord --target "#krilly" --message "$MESSAGE" 2>/dev/null || echo "Discord send failed" >&2 echo "Digest sent to Telegram and Discord!"