52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
"""환경 변수 및 설정 관리."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
|
|
class Config:
|
|
"""앱 전체 설정을 담당하는 클래스."""
|
|
|
|
# Slack
|
|
slack_bot_token: str = os.getenv("SLACK_BOT_TOKEN", "")
|
|
slack_app_token: str = os.getenv("SLACK_APP_TOKEN", "")
|
|
allowed_user_id: str = os.getenv("SLACK_ALLOWED_USER_ID", "")
|
|
allowed_channel_id: str = os.getenv("SLACK_ALLOWED_CHANNEL_ID", "")
|
|
|
|
# PTY / tmux attach
|
|
tmux_session_name: str = os.getenv("TMUX_SESSION_NAME", "claude")
|
|
codex_tmux_session_name: str = os.getenv("CODEX_TMUX_SESSION_NAME", "codex")
|
|
pty_read_timeout: int = int(os.getenv("PTY_READ_TIMEOUT", "5"))
|
|
|
|
# Buffer
|
|
output_buffer_interval: float = float(os.getenv("OUTPUT_BUFFER_INTERVAL", "2.0"))
|
|
max_message_length: int = int(os.getenv("MAX_MESSAGE_LENGTH", "3000"))
|
|
|
|
# Status reporting / reconnect
|
|
reconnect_delay_seconds: float = float(os.getenv("RECONNECT_DELAY_SECONDS", "5.0"))
|
|
output_idle_report_seconds: int = int(
|
|
os.getenv("OUTPUT_IDLE_REPORT_SECONDS", "120")
|
|
)
|
|
input_idle_report_seconds: int = int(os.getenv("INPUT_IDLE_REPORT_SECONDS", "300"))
|
|
|
|
def validate_required_settings(self) -> None:
|
|
"""필수 설정값 누락 여부를 검증한다."""
|
|
missing: list[str] = []
|
|
if not self.slack_bot_token:
|
|
missing.append("SLACK_BOT_TOKEN")
|
|
if not self.slack_app_token:
|
|
missing.append("SLACK_APP_TOKEN")
|
|
if not self.allowed_user_id:
|
|
missing.append("SLACK_ALLOWED_USER_ID")
|
|
if not self.allowed_channel_id:
|
|
missing.append("SLACK_ALLOWED_CHANNEL_ID")
|
|
|
|
if missing:
|
|
joined = ", ".join(missing)
|
|
raise ValueError(f"필수 환경 변수가 누락되었습니다: {joined}")
|