mirror of
https://github.com/BEDOLAGA-DEV/remnawave-bedolaga-telegram-bot.git
synced 2026-02-16 17:10:31 +00:00
Рефакторинг архитектуры ежедневных конкурсов: - Создан модуль app/services/contests/ с новой архитектурой: - enums.py: GameType, RoundStatus, PrizeType enum классы - games.py: паттерн Стратегия для 7 типов игр - attempt_service.py: ContestAttemptService для атомарных операций - Упрощён handlers/contests.py: - Удалены отдельные _render_* функции (заменены на стратегии) - Логика обработки попыток вынесена в ContestAttemptService - Уменьшено с 523 до 342 строк (-35%) - Обновлён contest_rotation_service.py: - Заменена if-elif цепочка на get_game_strategy().build_payload() - Используются enum классы вместо магических строк - Исправлен handlers/admin/daily_contests.py: - prize_days → prize_type/prize_value (соответствие модели БД) - Обновлены EDITABLE_FIELDS и отображение приза 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
"""Enum classes for contest system."""
|
|
|
|
from enum import Enum
|
|
|
|
|
|
class GameType(str, Enum):
|
|
"""Types of daily contest games."""
|
|
|
|
QUEST_BUTTONS = "quest_buttons"
|
|
LOCK_HACK = "lock_hack"
|
|
LETTER_CIPHER = "letter_cipher"
|
|
SERVER_LOTTERY = "server_lottery"
|
|
BLITZ_REACTION = "blitz_reaction"
|
|
EMOJI_GUESS = "emoji_guess"
|
|
ANAGRAM = "anagram"
|
|
|
|
@classmethod
|
|
def is_text_input(cls, game_type: "GameType") -> bool:
|
|
"""Check if game requires text input from user."""
|
|
return game_type in {cls.LETTER_CIPHER, cls.EMOJI_GUESS, cls.ANAGRAM}
|
|
|
|
@classmethod
|
|
def is_button_pick(cls, game_type: "GameType") -> bool:
|
|
"""Check if game uses button selection."""
|
|
return game_type in {
|
|
cls.QUEST_BUTTONS,
|
|
cls.LOCK_HACK,
|
|
cls.SERVER_LOTTERY,
|
|
cls.BLITZ_REACTION,
|
|
}
|
|
|
|
|
|
class RoundStatus(str, Enum):
|
|
"""Contest round status."""
|
|
|
|
ACTIVE = "active"
|
|
FINISHED = "finished"
|
|
|
|
|
|
class PrizeType(str, Enum):
|
|
"""Types of prizes for contests."""
|
|
|
|
DAYS = "days"
|
|
BALANCE = "balance"
|
|
CUSTOM = "custom"
|