#!/bin/bash # # PetBot Startup Script # Complete one-command startup for PetBot with all dependencies # # Usage: ./start_petbot.sh # set -e # Exit on any error echo "🐾 Starting PetBot..." echo "====================" # Get script directory (works even if called from elsewhere) SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" echo "📁 Working directory: $SCRIPT_DIR" # Check if virtual environment exists if [ ! -d "venv" ]; then echo "❌ Virtual environment not found!" echo "🔧 Creating virtual environment..." python3 -m venv venv echo "✅ Virtual environment created" fi # Activate virtual environment echo "🔄 Activating virtual environment..." source venv/bin/activate # Check if requirements are installed echo "🔄 Checking dependencies..." if ! python -c "import aiosqlite, irc, dotenv" 2>/dev/null; then echo "đŸ“Ļ Installing/updating dependencies..." # Create requirements.txt if it doesn't exist if [ ! -f "requirements.txt" ]; then echo "📝 Creating requirements.txt..." cat > requirements.txt << EOF aiosqlite>=0.17.0 irc>=20.3.0 python-dotenv>=0.19.0 aiohttp>=3.8.0 EOF fi pip install --upgrade pip pip install -r requirements.txt echo "✅ Dependencies installed" else echo "✅ Dependencies already satisfied" fi # Verify core modules can be imported echo "🔄 Verifying core modules..." python3 -c " import sys sys.path.append('.') try: from src.database import Database from src.game_engine import GameEngine from src.rate_limiter import RateLimiter from src.irc_connection_manager import IRCConnectionManager from config import ADMIN_USER, IRC_CONFIG, RATE_LIMIT_CONFIG print('✅ Core modules verified') print(f'â„šī¸ Admin user: {ADMIN_USER}') except ImportError as e: print(f'❌ Module import error: {e}') sys.exit(1) " # Create data directory if it doesn't exist if [ ! -d "data" ]; then echo "📁 Creating data directory..." mkdir -p data fi # Create backups directory if it doesn't exist if [ ! -d "backups" ]; then echo "📁 Creating backups directory..." mkdir -p backups fi # Check if database exists, if not mention first-time setup if [ ! -f "data/petbot.db" ]; then echo "â„šī¸ First-time setup detected - database will be created automatically" fi # Display startup information echo "" echo "🚀 Launching PetBot with Auto-Reconnect..." echo "🌐 Web interface will be available at: http://localhost:8080" echo "đŸ’Ŧ IRC: Connecting to irc.libera.chat #petz" echo "📊 Features: Rate limiting, auto-reconnect, web interface, team builder" echo "" echo "Press Ctrl+C to stop the bot" echo "====================" echo "" # Launch the bot exec python run_bot_with_reconnect.py