mirror of
https://github.com/anthropics/claude-plugins-official.git
synced 2026-03-22 12:13:09 +00:00
Compare commits
1 Commits
kenneth/te
...
kenneth/ch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14927ff475 |
@@ -55,7 +55,9 @@ Install the plugin:
|
|||||||
/discord:configure MTIz...
|
/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.**
|
**6. Relaunch with the channel flag.**
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync, statSync,
|
|||||||
import { homedir } from 'os'
|
import { homedir } from 'os'
|
||||||
import { join, sep } from 'path'
|
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 ACCESS_FILE = join(STATE_DIR, 'access.json')
|
||||||
const APPROVED_DIR = join(STATE_DIR, 'approved')
|
const APPROVED_DIR = join(STATE_DIR, 'approved')
|
||||||
const ENV_FILE = join(STATE_DIR, '.env')
|
const ENV_FILE = join(STATE_DIR, '.env')
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ Install the plugin:
|
|||||||
/telegram:configure 123456789:AAHfiqksKZ8...
|
/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.**
|
**4. Relaunch with the channel flag.**
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync, statSync,
|
|||||||
import { homedir } from 'os'
|
import { homedir } from 'os'
|
||||||
import { join, extname, sep } from 'path'
|
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 ACCESS_FILE = join(STATE_DIR, 'access.json')
|
||||||
const APPROVED_DIR = join(STATE_DIR, 'approved')
|
const APPROVED_DIR = join(STATE_DIR, 'approved')
|
||||||
const ENV_FILE = join(STATE_DIR, '.env')
|
const ENV_FILE = join(STATE_DIR, '.env')
|
||||||
@@ -304,7 +304,7 @@ function checkApprovals(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!STATIC) setInterval(checkApprovals, 5000).unref()
|
if (!STATIC) setInterval(checkApprovals, 5000)
|
||||||
|
|
||||||
// Telegram caps messages at 4096 chars. Split long replies, preferring
|
// Telegram caps messages at 4096 chars. Split long replies, preferring
|
||||||
// paragraph boundaries when chunkMode is 'newline'.
|
// paragraph boundaries when chunkMode is 'newline'.
|
||||||
@@ -507,24 +507,6 @@ mcp.setRequestHandler(CallToolRequestSchema, async req => {
|
|||||||
|
|
||||||
await mcp.connect(new StdioServerTransport())
|
await mcp.connect(new StdioServerTransport())
|
||||||
|
|
||||||
// When Claude Code closes the MCP connection, stdin gets EOF. Without this
|
|
||||||
// the bot keeps polling forever as a zombie, holding the token and blocking
|
|
||||||
// the next session with 409 Conflict.
|
|
||||||
let shuttingDown = false
|
|
||||||
function shutdown(): void {
|
|
||||||
if (shuttingDown) return
|
|
||||||
shuttingDown = true
|
|
||||||
process.stderr.write('telegram channel: shutting down\n')
|
|
||||||
// bot.stop() signals the poll loop to end; the current getUpdates request
|
|
||||||
// may take up to its long-poll timeout to return. Force-exit after 2s.
|
|
||||||
setTimeout(() => process.exit(0), 2000)
|
|
||||||
void Promise.resolve(bot.stop()).finally(() => process.exit(0))
|
|
||||||
}
|
|
||||||
process.stdin.on('end', shutdown)
|
|
||||||
process.stdin.on('close', shutdown)
|
|
||||||
process.on('SIGTERM', shutdown)
|
|
||||||
process.on('SIGINT', shutdown)
|
|
||||||
|
|
||||||
bot.on('message:text', async ctx => {
|
bot.on('message:text', async ctx => {
|
||||||
await handleInbound(ctx, ctx.message.text, undefined)
|
await handleInbound(ctx, ctx.message.text, undefined)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user