#!/bin/bash

echo "🤖 Setting up AmlakJame Telegram Bot for Python 3.9.23"

# ایجاد پوشه‌های لازم
mkdir -p logs
mkdir -p data

# بررسی وجود پایتون 3.9
if ! command -v python3.9 &> /dev/null; then
    echo "❌ Python 3.9 not found. Please install Python 3.9 first."
    exit 1
fi

echo "✅ Python 3.9.23 found"

# ایجاد virtual environment
echo "🔧 Creating virtual environment..."
python3.9 -m venv venv

# فعال‌سازی virtual environment
echo "🔧 Activating virtual environment..."
source venv/bin/activate

# نصب requirements
echo "📦 Installing requirements..."
pip install --upgrade pip
pip install -r requirements.txt

# تنظیم دسترسی‌ها
echo "🔐 Setting permissions..."
chmod +x bot.py
chmod 600 .env
chmod 755 logs/

echo "✅ Setup completed successfully!"
echo "🚀 To run the bot: source venv/bin/activate && python bot.py"