#!/usr/bin/env python3 """ config.py -- loads all configuration from .env file. Never import secrets directly in other modules -- always import from here. """ import os from pathlib import Path from datetime import timezone, timedelta # Load .env manually (no external deps needed). # Reads KEY=VALUE lines, ignores comments and blank lines. def _load_env(path="/opt/umami/notifier/.env"): env_path = Path(path) if not env_path.exists(): raise FileNotFoundError(f".env not found at {path}. Copy .env.example and fill in values.") for line in env_path.read_text().splitlines(): line = line.strip() if not line or line.startswith("#") or "=" not in line: continue key, _, value = line.partition("=") os.environ.setdefault(key.strip(), value.strip()) _load_env() # Umami UMAMI_URL = os.environ["UMAMI_URL"] UMAMI_USER = os.environ["UMAMI_USER"] UMAMI_PASS = os.environ["UMAMI_PASS"] UMAMI_SITE_ID = os.environ["UMAMI_SITE_ID"] # Telegram -- only needed for receiving /commands via getUpdates. # Sending goes through Apprise, not directly to Telegram API. TELEGRAM_TOKEN = os.environ["TELEGRAM_TOKEN"] TELEGRAM_CHAT_ID = os.environ["TELEGRAM_CHAT_ID"] # Apprise -- all outbound notifications go here. # Format: https://user:pass@notify.manohargupta.com/notify/apprise APPRISE_URL = os.environ["APPRISE_URL"] # General POLL_INTERVAL = int(os.environ.get("POLL_INTERVAL", "30")) # seconds IST = timezone(timedelta(hours=5, minutes=30))