Files
quiz_test/tools/status.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

179 lines
6.8 KiB
Python
Raw 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
# Добавляем путь к проекту
project_root = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, project_root)
def print_banner():
print("🤖 QUIZ BOT - ФИНАЛЬНЫЙ ОТЧЕТ")
print("=" * 60)
def check_structure():
"""Проверка структуры проекта"""
print("📁 СТРУКТУРА ПРОЕКТА:")
required_structure = {
'src/bot.py': 'Основной файл бота',
'src/database/database.py': 'Менеджер базы данных',
'src/services/csv_service.py': 'Сервис загрузки CSV',
'config/config.py': 'Конфигурация',
'data/quiz_bot.db': 'База данных SQLite',
'requirements.txt': 'Зависимости Python',
'.env': 'Переменные окружения',
'README.md': 'Документация',
'Makefile': 'Команды автоматизации'
}
all_good = True
for file_path, description in required_structure.items():
if Path(file_path).exists():
print(f"{file_path:<30} - {description}")
else:
print(f"{file_path:<30} - {description}")
all_good = False
# Проверим CSV файлы
csv_files = list(Path("data").glob("*.csv"))
print(f" ✅ data/*.csv - {len(csv_files)} CSV файлов с тестами")
return all_good
def check_database():
"""Проверка базы данных"""
print("\n🗄️ БАЗА ДАННЫХ:")
try:
from src.database.database import DatabaseManager
from config.config import config
import asyncio
async def check():
db = DatabaseManager(config.database_path)
tests = await db.get_tests_by_category()
print(f" ✅ Подключение к БД работает")
print(f" ✅ Найдено тестов: {len(tests)}")
total_questions = 0
for test in tests:
questions = await db.get_random_questions(test['id'], 100)
total_questions += len(questions)
print(f" 📚 {test['name']}: {len(questions)} вопросов")
print(f"Всего вопросов в базе: {total_questions}")
asyncio.run(check())
return True
except Exception as e:
print(f" ❌ Ошибка БД: {e}")
return False
def check_config():
"""Проверка конфигурации"""
print("\n⚙️ КОНФИГУРАЦИЯ:")
try:
from config.config import config
# Проверяем токен
if config.bot_token and config.bot_token not in ['your_bot_token_here', 'test_token_for_demo_purposes']:
print(" ✅ BOT_TOKEN настроен")
bot_ready = True
else:
print(" ⚠️ BOT_TOKEN не настроен (нужен для реального запуска)")
bot_ready = False
print(f" ✅ DATABASE_PATH: {config.database_path}")
print(f" ✅ CSV_DATA_PATH: {config.csv_data_path}")
print(f" ✅ QUESTIONS_PER_QUIZ: {config.questions_per_quiz}")
print(f" ✅ GUEST_MODE_ENABLED: {config.guest_mode_enabled}")
print(f" ✅ TEST_MODE_ENABLED: {config.test_mode_enabled}")
return bot_ready
except Exception as e:
print(f" ❌ Ошибка конфигурации: {e}")
return False
def show_features():
"""Показать возможности"""
print("\n🎮 ВОЗМОЖНОСТИ:")
print(" 🎯 Гостевой режим - быстрые викторины (5 вопросов)")
print(" 📚 Режим тестирования - полные тесты (10 вопросов)")
print(" 📊 Система статистики и прогресса")
print(" 🇰🇷 100 вопросов по корейскому языку (5 уровней)")
print(" 📱 Команды: /start, /help, /stats, /stop")
print(" 🔄 Легкое добавление новых тестов через CSV")
def show_commands():
"""Показать команды"""
print("\n🚀 КОМАНДЫ ДЛЯ ЗАПУСКА:")
print(" make demo - Демонстрация без Telegram")
print(" make test - Интерактивный тест в консоли")
print(" make test-bot - Проверка импортов")
print(" make run - Запуск бота в Telegram")
print(" make help - Полная справка")
def show_instructions():
"""Инструкции по настройке"""
print("\n📋 ДЛЯ ЗАПУСКА РЕАЛЬНОГО БОТА:")
print(" 1. Найдите @BotFather в Telegram")
print(" 2. Создайте нового бота командой /newbot")
print(" 3. Скопируйте токен")
print(" 4. Откройте файл .env")
print(" 5. Замените BOT_TOKEN=... на ваш токен")
print(" 6. Запустите: make run")
def main():
print_banner()
# Проверяем структуру
structure_ok = check_structure()
# Проверяем базу данных
db_ok = check_database()
# Проверяем конфигурацию
config_ok = check_config()
# Показываем возможности
show_features()
# Показываем команды
show_commands()
print("\n" + "=" * 60)
if structure_ok and db_ok:
print("🎉 ПРОЕКТ ГОТОВ К ИСПОЛЬЗОВАНИЮ!")
if config_ok:
print("✅ Бот настроен и готов к запуску в Telegram!")
print("🚀 Команда: make run")
else:
print("⚠️ Нужно настроить токен для Telegram бота")
show_instructions()
print("\n🔧 Утилиты для тестирования:")
print(" make demo - Работает без токена")
print(" make test - Интерактивный режим")
else:
print("❌ ПРОЕКТ НЕ ГОТОВ!")
if not structure_ok:
print(" - Отсутствуют необходимые файлы")
if not db_ok:
print(" - Проблемы с базой данных")
print("=" * 60)
if __name__ == "__main__":
main()