# Copyright (c) 2026 Krzysztof Rudnicki. MIT licence. """Where the bot keeps what is not in this repository. One answer for every file that has to live outside the tree -- the album, the suggestions export, the operator's own aliases -- so that the bot and the management page, two processes reading the same environment, cannot disagree about where a file is. """ from __future__ import annotations import os from pathlib import Path def state_dir() -> Path: """The directory for data this repository never sees. Read straight off os.environ rather than from a passed mapping, exactly as portraits.default_cache_dir is: .env has already been loaded into the environment by then, and it is what lets one autouse fixture keep the whole test suite away from the operator's real data. STATE_DIRECTORY comes before anything under $HOME because that is the directory systemd creates and exposes regardless of ProtectHome. """ state = os.environ.get("STATE_DIRECTORY", "").strip() if state: return Path(state) home = os.environ.get("XDG_DATA_HOME", "").strip() or str(Path.home() / ".local" / "share") return Path(home) / "signal-bot"