Skip to content

Commit bf6e2fe

Browse files
committed
fix(notify): env var fallback for Discord token/proxy (Docker compat)
DISCORD_BOT_TOKEN and DISCORD_PROXY env vars now take priority over reading from ~/.openclaw/openclaw.json. Also falls back to HTTPS_PROXY. This fixes Docker/cloud deployments where openclaw.json doesn't exist.
1 parent 985a850 commit bf6e2fe

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

scripts/web/notify.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,12 @@ def _summary_formatter(run_id: str, state: Dict[str, Any]) -> str:
259259
# ── Discord 通知 ────────────────────────────────────────────────────
260260

261261
def _get_discord_bot_token() -> str:
262-
"""从 openclaw.json 读取 Discord bot token"""
262+
"""获取 Discord bot token(env 优先,fallback 到 openclaw.json)"""
263+
# 1. 环境变量(Docker / 云端部署推荐)
264+
token = os.environ.get("DISCORD_BOT_TOKEN", "").strip()
265+
if token:
266+
return token
267+
# 2. openclaw.json(本地 OpenClaw 部署)
263268
try:
264269
cfg_path = Path.home() / ".openclaw" / "openclaw.json"
265270
if cfg_path.exists():
@@ -272,7 +277,16 @@ def _get_discord_bot_token() -> str:
272277

273278

274279
def _get_discord_proxy() -> str:
275-
"""从 openclaw.json 读取 Discord proxy"""
280+
"""获取 Discord proxy(env 优先,fallback 到 openclaw.json)"""
281+
# 1. 环境变量
282+
proxy = os.environ.get("DISCORD_PROXY", "").strip()
283+
if proxy:
284+
return proxy
285+
# 2. HTTPS_PROXY(通用代理)
286+
proxy = os.environ.get("HTTPS_PROXY", "").strip() or os.environ.get("https_proxy", "").strip()
287+
if proxy:
288+
return proxy
289+
# 3. openclaw.json
276290
try:
277291
cfg_path = Path.home() / ".openclaw" / "openclaw.json"
278292
if cfg_path.exists():

0 commit comments

Comments
 (0)