#!/bin/bash

# Schedule Parser Bot - Installation script

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo "📦 Schedule Parser Bot - Installation"
echo "===================================="
echo ""

# Create directories
echo "📁 Creating directories..."
mkdir -p "$SCRIPT_DIR/storage"
mkdir -p "$SCRIPT_DIR/logs"
chmod 755 "$SCRIPT_DIR/storage"
chmod 755 "$SCRIPT_DIR/logs"
chmod 755 "$SCRIPT_DIR"

echo "✅ Directories created"
echo ""

# Check if config.php exists
if [ ! -f "$SCRIPT_DIR/config.php" ]; then
    echo "⚠️  config.php not found"
    echo "📋 Creating config.php from example..."
    cp "$SCRIPT_DIR/config.example.php" "$SCRIPT_DIR/config.php"
    chmod 644 "$SCRIPT_DIR/config.php"
    echo "✅ config.php created"
    echo ""
    echo "⚠️  IMPORTANT: Edit config.php and add:"
    echo "   - Your Telegram bot token"
    echo "   - Your chat ID"
    echo "   - URLs to monitor"
    echo ""
else
    echo "✅ config.php already exists"
fi

echo ""
echo "📝 Next steps:"
echo "1. Edit config.php with your settings"
echo "2. Test the script: php run.php"
echo "3. Add to crontab for automated runs"
echo ""
echo "For more info, see README.md"
