Files

18 lines
692 B
Bash

#!/bin/bash
# Monitor Claude Code usage and send Telegram notifications on resets
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OUTPUT=$("$SCRIPT_DIR/monitor-usage.sh" 2>&1)
# Check if a reset was detected (output contains "Reset notification sent")
if echo "$OUTPUT" | grep -q "Reset notification sent"; then
# Extract just the notification message (before "✅ Reset notification sent")
MESSAGE=$(echo "$OUTPUT" | sed '/✅ Reset notification sent/q' | sed '$ d')
# Send via Telegram using bot
if command -v bot >/dev/null 2>&1; then
# Use printf to handle newlines properly
printf '%s' "$MESSAGE" | bot message send --telegram --target 5259918241
fi
fi