daily 不再通过 sys.path 导入 bot/skills_service,skills feed 数据层上移到 shared/。 Co-authored-by: Cursor <cursoragent@cursor.com>
22 lines
524 B
Python
22 lines
524 B
Python
"""加载 bot/.env,供各模块在 import 时统一读取环境变量。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import os
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
from dotenv import load_dotenv
|
||
|
||
_BOT_DIR = Path(__file__).resolve().parent
|
||
_REPO_ROOT = _BOT_DIR.parent
|
||
if str(_REPO_ROOT) not in sys.path:
|
||
sys.path.insert(0, str(_REPO_ROOT))
|
||
|
||
load_dotenv(_BOT_DIR / ".env")
|
||
load_dotenv(_BOT_DIR / ".env.local", override=True)
|
||
|
||
|
||
def env(key: str, default: str | None = None) -> str | None:
|
||
return os.getenv(key, default)
|