Files
2026-04-18 20:07:52 +04:00

72 lines
1.9 KiB
Python

"""Configuration module for the server manager bot."""
import os
from dataclasses import dataclass
from enum import Enum
class States(Enum):
"""Bot conversation states."""
AWAITING_FOR_TORRENT = 0
AWAITING_FOR_CATEGORY = 1
AWAITING_FOR_TORRENT_NUMBER = 2
AWAITING_FOR_VIDEO = 3
NONE = 4
@dataclass(frozen=True)
class TelegramConfig:
"""Telegram bot configuration."""
bot_token: str
chat_id: int
message_thread_id: int
proxy_server: str
@dataclass(frozen=True)
class QbittorrentConfig:
"""qBittorrent client configuration."""
host: str
port: int
username: str
password: str
@dataclass(frozen=True)
class JellyfinConfig:
"""Jellyfin server configuration."""
host: str
port: int
api_key: str
upload_path: str
def load_telegram_config() -> TelegramConfig:
"""Load Telegram configuration from environment variables."""
return TelegramConfig(
bot_token=os.getenv("TELEGRAM_BOT_TOKEN", None),
chat_id=int(os.getenv("TELEGRAM_CHAT_ID", None)),
message_thread_id=int(os.getenv("TELEGRAM_MESSAGE_THREAD_ID", None)),
proxy_server=os.getenv("TELEGRAM_PROXY", None)
)
def load_qbittorrent_config() -> QbittorrentConfig:
"""Load qBittorrent configuration from environment variables."""
return QbittorrentConfig(
host=os.getenv("QBITTORRENT_HOST", None),
port=int(os.getenv("QBITTORRENT_PORT", None)),
username=os.getenv("QBITTORRENT_USERNAME", None),
password=os.getenv("QBITTORRENT_PASSWORD", None),
)
def load_jellyfin_config() -> JellyfinConfig:
"""Load Jellyfin configuration from environment variables."""
return JellyfinConfig(
host=os.getenv("JELLYFIN_HOST", None),
port=int(os.getenv("JELLYFIN_PORT", None)),
api_key=os.getenv("JELLYFIN_API_KEY", None),
upload_path=os.getenv("JELLYFIN_UPLOAD_PATH", None),
)