mirror of
https://github.com/anthropics/claude-plugins-official.git
synced 2026-03-20 23:43:07 +00:00
Compare commits
1 Commits
kenneth/ch
...
kenneth/te
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f2a4feab9 |
@@ -55,9 +55,7 @@ Install the plugin:
|
||||
/discord:configure MTIz...
|
||||
```
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
**6. Relaunch with the channel flag.**
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync, statSync,
|
||||
import { homedir } from 'os'
|
||||
import { join, sep } from 'path'
|
||||
|
||||
const STATE_DIR = process.env.DISCORD_STATE_DIR ?? join(homedir(), '.claude', 'channels', 'discord')
|
||||
const 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')
|
||||
|
||||
@@ -35,9 +35,7 @@ Install the plugin:
|
||||
/telegram:configure 123456789:AAHfiqksKZ8...
|
||||
```
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
**4. Relaunch with the channel flag.**
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync, statSync,
|
||||
import { homedir } from 'os'
|
||||
import { join, extname, sep } from 'path'
|
||||
|
||||
const STATE_DIR = process.env.TELEGRAM_STATE_DIR ?? join(homedir(), '.claude', 'channels', 'telegram')
|
||||
const 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')
|
||||
@@ -51,6 +51,15 @@ if (!TOKEN) {
|
||||
}
|
||||
const INBOX_DIR = join(STATE_DIR, 'inbox')
|
||||
|
||||
// Last-resort safety net — without these the process dies silently on any
|
||||
// unhandled promise rejection. With them it logs and keeps serving tools.
|
||||
process.on('unhandledRejection', err => {
|
||||
process.stderr.write(`telegram channel: unhandled rejection: ${err}\n`)
|
||||
})
|
||||
process.on('uncaughtException', err => {
|
||||
process.stderr.write(`telegram channel: uncaught exception: ${err}\n`)
|
||||
})
|
||||
|
||||
const bot = new Bot(TOKEN)
|
||||
let botUsername = ''
|
||||
|
||||
@@ -577,7 +586,7 @@ async function handleInbound(
|
||||
|
||||
// image_path goes in meta only — an in-content "[image attached — read: PATH]"
|
||||
// annotation is forgeable by any allowlisted sender typing that string.
|
||||
void mcp.notification({
|
||||
mcp.notification({
|
||||
method: 'notifications/claude/channel',
|
||||
params: {
|
||||
content: text,
|
||||
@@ -590,12 +599,25 @@ async function handleInbound(
|
||||
...(imagePath ? { image_path: imagePath } : {}),
|
||||
},
|
||||
},
|
||||
}).catch(err => {
|
||||
process.stderr.write(`telegram channel: failed to deliver inbound to Claude: ${err}\n`)
|
||||
})
|
||||
}
|
||||
|
||||
void bot.start({
|
||||
// Without this, any throw in a message handler stops polling permanently
|
||||
// (grammy's default error handler calls bot.stop() and rethrows).
|
||||
bot.catch(err => {
|
||||
process.stderr.write(`telegram channel: handler error (polling continues): ${err.error}\n`)
|
||||
})
|
||||
|
||||
bot.start({
|
||||
onStart: info => {
|
||||
botUsername = info.username
|
||||
process.stderr.write(`telegram channel: polling as @${info.username}\n`)
|
||||
},
|
||||
}).catch(err => {
|
||||
// bot.start() only rejects if polling can't begin or dies unrecoverably —
|
||||
// bad token, 409 conflict, network gone. Log it so the user isn't left
|
||||
// wondering why messages stopped arriving.
|
||||
process.stderr.write(`telegram channel: polling stopped: ${err}\n`)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user