Files
quiz_test/tools/setup.py
Andrey K. Choi b0346e4bd7
Some checks reported errors
continuous-integration/drone/push Build encountered an error
cleaning root
2025-09-11 08:18:31 +09:00

140 lines
4.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
🚀 Quiz Bot - Финальная настройка и запуск
Этот скрипт поможет вам настроить и запустить телеграм-бота.
"""
import os
import sys
from pathlib import Path
def print_header():
print("🤖 Quiz Bot - Настройка и запуск")
print("=" * 50)
def check_token():
"""Проверка наличия токена бота"""
env_path = Path(".env")
if not env_path.exists():
print("❌ Файл .env не найден!")
print("📋 Создайте файл .env:")
print(" cp .env.example .env")
return False
# Читаем .env файл
with open(env_path, 'r') as f:
content = f.read()
if "BOT_TOKEN=your_bot_token_here" in content or "BOT_TOKEN=" in content:
return False
return True
def setup_instructions():
"""Инструкции по настройке"""
print("📋 Инструкции по настройке:")
print()
print("1. 🤖 Создание бота в Telegram:")
print(" - Найдите @BotFather в Telegram")
print(" - Отправьте команду /newbot")
print(" - Следуйте инструкциям")
print(" - Скопируйте токен (выглядит как: 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11)")
print()
print("2. ⚙️ Настройка файла .env:")
print(" - Откройте файл .env в текстовом редакторе")
print(" - Замените 'your_bot_token_here' на ваш токен")
print(" - Сохраните файл")
print()
print("3. 🚀 Запуск бота:")
print(" python src/bot.py")
print()
def project_status():
"""Статус проекта"""
print("📊 Статус проекта:")
# Проверяем структуру
required_files = [
"src/bot.py",
"src/database/database.py",
"src/services/csv_service.py",
"config/config.py",
"requirements.txt",
"data/quiz_bot.db"
]
missing_files = []
for file_path in required_files:
if not Path(file_path).exists():
missing_files.append(file_path)
if missing_files:
print("❌ Отсутствуют файлы:")
for file in missing_files:
print(f" - {file}")
return False
else:
print("Все необходимые файлы на месте")
# Проверяем CSV файлы
csv_files = list(Path("data").glob("*.csv"))
print(f"✅ Найдено CSV файлов: {len(csv_files)}")
# Проверяем базу данных
db_path = Path("data/quiz_bot.db")
if db_path.exists():
print(f"✅ База данных: {db_path} ({db_path.stat().st_size} байт)")
else:
print("❌ База данных не найдена")
return False
return True
def main():
print_header()
# Проверяем статус проекта
if not project_status():
print("\n❌ Проект не готов к запуску!")
print("🔧 Выполните инициализацию: python init_project.py")
return
print()
# Проверяем токен
if check_token():
print("✅ Токен бота настроен")
print()
print("🚀 Для запуска бота выполните:")
print(" python src/bot.py")
print()
print("🎮 Доступные команды в боте:")
print(" /start - Главное меню")
print(" /help - Справка")
print(" /stats - Статистика")
print(" /stop - Остановить тест")
print()
print("🎯 Режимы работы:")
print(" • Гостевой режим - быстрые викторины (5 вопросов)")
print(" • Тестирование - полные тесты (10 вопросов)")
print()
print("📚 Доступные тесты:")
print(" • Корейский язык (уровни 1-5)")
print(" • По 20 вопросов на каждый уровень")
else:
print("⚠️ Токен бота не настроен!")
setup_instructions()
print("\n🔧 Дополнительные утилиты:")
print(" python demo.py - Демонстрация возможностей")
print(" python test_quiz.py - Интерактивный тест в консоли")
print(" python load_questions.py - Перезагрузка вопросов в БД")
if __name__ == "__main__":
main()