diff options
| author | Kenneth Lien <kenneth@anthropic.com> | 2026-03-20 10:56:57 -0700 |
|---|---|---|
| committer | Kenneth Lien <kenneth@anthropic.com> | 2026-03-20 10:56:57 -0700 |
| commit | 14927ff475758115791aceb4b53c0aadce8db4d8 (patch) | |
| tree | 7e22acd57b7b086463a2693f8422f824a66b293d | |
| parent | 90accf6fd2008fe0ee9578ebc088740c3a754d58 (diff) | |
telegram/discord: make state dir configurable via env varkenneth/channels-state-dir
Hardcoded ~/.claude/channels/<name>/ meant only one bot per machine.
Respect TELEGRAM_STATE_DIR / DISCORD_STATE_DIR so users can run
multiple bots with separate tokens and allowlists.
Also fixed README path ('in your project' -> '~/...') to match the code.
Fixes #792
| -rw-r--r-- | external_plugins/discord/README.md | 4 | ||||
| -rw-r--r-- | external_plugins/discord/server.ts | 2 | ||||
| -rw-r--r-- | external_plugins/telegram/README.md | 4 | ||||
| -rw-r--r-- | external_plugins/telegram/server.ts | 2 |
4 files changed, 8 insertions, 4 deletions
diff --git a/external_plugins/discord/README.md b/external_plugins/discord/README.md index 3cbdf2b8..ad04f6fa 100644 --- a/external_plugins/discord/README.md +++ b/external_plugins/discord/README.md @@ -55,7 +55,9 @@ Install the plugin: /discord:configure MTIz... ``` -Writes `DISCORD_BOT_TOKEN=...` to `.claude/channels/discord/.env` in your project. You can also write that file by hand, or set the variable in your shell environment — shell takes precedence. +Writes `DISCORD_BOT_TOKEN=...` to `~/.claude/channels/discord/.env`. You can also write that file by hand, or set the variable in your shell environment — shell takes precedence. + +> To run multiple bots on one machine (different tokens, separate allowlists), point `DISCORD_STATE_DIR` at a different directory per instance. **6. Relaunch with the channel flag.** diff --git a/external_plugins/discord/server.ts b/external_plugins/discord/server.ts index 078c29ab..4d220bea 100644 --- a/external_plugins/discord/server.ts +++ b/external_plugins/discord/server.ts @@ -29,7 +29,7 @@ import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync, statSync, import { homedir } from 'os' import { join, sep } from 'path' -const STATE_DIR = join(homedir(), '.claude', 'channels', 'discord') +const STATE_DIR = process.env.DISCORD_STATE_DIR ?? join(homedir(), '.claude', 'channels', 'discord') const ACCESS_FILE = join(STATE_DIR, 'access.json') const APPROVED_DIR = join(STATE_DIR, 'approved') const ENV_FILE = join(STATE_DIR, '.env') diff --git a/external_plugins/telegram/README.md b/external_plugins/telegram/README.md index 8d5632e3..d72dbc1a 100644 --- a/external_plugins/telegram/README.md +++ b/external_plugins/telegram/README.md @@ -35,7 +35,9 @@ Install the plugin: /telegram:configure 123456789:AAHfiqksKZ8... ``` -Writes `TELEGRAM_BOT_TOKEN=...` to `.claude/channels/telegram/.env` in your project. You can also write that file by hand, or set the variable in your shell environment — shell takes precedence. +Writes `TELEGRAM_BOT_TOKEN=...` to `~/.claude/channels/telegram/.env`. You can also write that file by hand, or set the variable in your shell environment — shell takes precedence. + +> To run multiple bots on one machine (different tokens, separate allowlists), point `TELEGRAM_STATE_DIR` at a different directory per instance. **4. Relaunch with the channel flag.** diff --git a/external_plugins/telegram/server.ts b/external_plugins/telegram/server.ts index 8acd52a2..98271d0d 100644 --- a/external_plugins/telegram/server.ts +++ b/external_plugins/telegram/server.ts @@ -22,7 +22,7 @@ import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync, statSync, import { homedir } from 'os' import { join, extname, sep } from 'path' -const STATE_DIR = join(homedir(), '.claude', 'channels', 'telegram') +const STATE_DIR = process.env.TELEGRAM_STATE_DIR ?? join(homedir(), '.claude', 'channels', 'telegram') const ACCESS_FILE = join(STATE_DIR, 'access.json') const APPROVED_DIR = join(STATE_DIR, 'approved') const ENV_FILE = join(STATE_DIR, '.env') |
