#!/bin/bash
# Setup arXiv daily bot

set -e

echo "🤖 ArXiv Daily Bot Setup"
echo "======================="
echo

# Check Python
if ! command -v python3 &> /dev/null; then
    echo "❌ Python 3 not found"
    exit 1
fi

echo "✓ Python $(python3 --version)"

# Check for interest profile
if [ ! -f "interest_profile.json" ]; then
    echo ""
    echo "⚠️  interest_profile.json not found"
    echo ""

    # Check if it exists in Documents
    if [ -f "$HOME/Documents/arxiv_interest_profile.json" ]; then
        echo "Found profile in Documents, copying..."
        cp "$HOME/Documents/arxiv_interest_profile.json" interest_profile.json
        echo "✓ Copied interest_profile.json"
    else
        echo "Please copy your interest_profile.json here, or run:"
        echo "  cd ~/Documents && python3 arxiv_bot.py --mode build_index"
        echo "  cp ~/Documents/arxiv_interest_profile.json ~/dev/arxiv-daily/interest_profile.json"
        echo ""
        read -p "Continue anyway? (y/N) " -n 1 -r
        echo
        if [[ ! $REPLY =~ ^[Yy]$ ]]; then
            exit 1
        fi
    fi
fi

# Make scripts executable
chmod +x arxiv_bot.py
chmod +x run_daily.sh

echo ""
echo "✓ Setup complete!"
echo ""
echo "Test it:"
echo "  ./arxiv_bot.py --days 7"
echo ""
echo "Setup cron job:"
echo "  crontab -e"
echo "  # Add: 0 9 * * * $HOME/dev/arxiv-daily/run_daily.sh"
echo ""
