fix(telegram,discord): respect STATE_DIR env vars in skill prompts#977
fix(telegram,discord): respect STATE_DIR env vars in skill prompts#977snemesh wants to merge 2 commits intoanthropics:mainfrom
Conversation
The /telegram:access and /telegram:configure skills hardcode ~/.claude/channels/telegram/ in 12 places. When TELEGRAM_STATE_DIR is set (multi-project setups), the skills read/write the wrong directory — pairing codes are not found, tokens are saved to the wrong .env, and allowlists don't match the running server. Both skills now resolve $STATE_DIR from the environment variable before any file operations, falling back to the default path when unset. No behavior change for single-channel setups. Fixes anthropics#931
|
The same issue is happening with DISCORD_STATE_DIR ;) |
Same fix as Telegram: replace 11 hardcoded ~/.claude/channels/discord/ paths in access and configure skills with $STATE_DIR resolved from DISCORD_STATE_DIR env var (fallback to default when unset). Fixes multi-bot setups where pairing codes, tokens, and allowlists were written to/read from the wrong directory. Reported by @gtapps in PR review.
|
+1 — hit this exact issue today deploying a second Claude Code agent (thinking partner) alongside an existing one on the same VPS, each with its own Telegram bot. Repro: Set Workaround: manually edit This PR's approach (resolve |
Problem
PR #792 added
TELEGRAM_STATE_DIRsupport toserver.ts, and Discord'sserver.tssimilarly supportsDISCORD_STATE_DIR. But the skill files for both channels were not updated — they hardcode~/.claude/channels/{telegram,discord}/paths.When running multiple bots (e.g. per-project), the server writes state to the correct directory via the env var, but the skills always read/write the default path. This means:
/access pair <code>looks up the code in the wrongaccess.json/configure <token>saves the token to the wrong.env/accessstatus shows the wrong allowlistFix
Both Telegram and Discord skills now resolve
$STATE_DIRfrom their respective env vars before any file operations, falling back to the default path when unset.No behavior change for single-channel setups (env var is unset → same default path).
Changes
Telegram (commit 1):
skills/access/SKILL.md— replaced 6 hardcoded paths, added state dir resolution blockskills/configure/SKILL.md— replaced 5 hardcoded paths, added state dir resolution blockDiscord (commit 2, reported by @gtapps):
skills/access/SKILL.md— replaced 6 hardcoded paths, added state dir resolution blockskills/configure/SKILL.md— replaced 5 hardcoded paths, added state dir resolution blockTest plan