mirror of
https://github.com/anthropics/claude-plugins-official.git
synced 2026-03-20 23:43:07 +00:00
Compare commits
1 Commits
kenneth/te
...
kenneth/ch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14927ff475 |
@@ -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.**
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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.**
|
||||
|
||||
|
||||
@@ -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')
|
||||
@@ -507,62 +507,6 @@ mcp.setRequestHandler(CallToolRequestSchema, async req => {
|
||||
|
||||
await mcp.connect(new StdioServerTransport())
|
||||
|
||||
// Commands are DM-only. Responding in groups would: (1) leak pairing codes via
|
||||
// /status to other group members, (2) confirm bot presence in non-allowlisted
|
||||
// groups, (3) spam channels the operator never approved. Silent drop matches
|
||||
// the gate's behavior for unrecognized groups.
|
||||
|
||||
bot.command('start', async ctx => {
|
||||
if (ctx.chat?.type !== 'private') return
|
||||
const access = loadAccess()
|
||||
if (access.dmPolicy === 'disabled') {
|
||||
await ctx.reply(`This bot isn't accepting new connections.`)
|
||||
return
|
||||
}
|
||||
await ctx.reply(
|
||||
`This bot bridges Telegram to a Claude Code session.\n\n` +
|
||||
`To pair:\n` +
|
||||
`1. DM me anything — you'll get a 6-char code\n` +
|
||||
`2. In Claude Code: /telegram:access pair <code>\n\n` +
|
||||
`After that, DMs here reach that session.`
|
||||
)
|
||||
})
|
||||
|
||||
bot.command('help', async ctx => {
|
||||
if (ctx.chat?.type !== 'private') return
|
||||
await ctx.reply(
|
||||
`Messages you send here route to a paired Claude Code session. ` +
|
||||
`Text and photos are forwarded; replies and reactions come back.\n\n` +
|
||||
`/start — pairing instructions\n` +
|
||||
`/status — check your pairing state`
|
||||
)
|
||||
})
|
||||
|
||||
bot.command('status', async ctx => {
|
||||
if (ctx.chat?.type !== 'private') return
|
||||
const from = ctx.from
|
||||
if (!from) return
|
||||
const senderId = String(from.id)
|
||||
const access = loadAccess()
|
||||
|
||||
if (access.allowFrom.includes(senderId)) {
|
||||
const name = from.username ? `@${from.username}` : senderId
|
||||
await ctx.reply(`Paired as ${name}.`)
|
||||
return
|
||||
}
|
||||
|
||||
for (const [code, p] of Object.entries(access.pending)) {
|
||||
if (p.senderId === senderId) {
|
||||
await ctx.reply(
|
||||
`Pending pairing — run in Claude Code:\n\n/telegram:access pair ${code}`
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
await ctx.reply(`Not paired. Send me a message to get a pairing code.`)
|
||||
})
|
||||
|
||||
bot.on('message:text', async ctx => {
|
||||
await handleInbound(ctx, ctx.message.text, undefined)
|
||||
})
|
||||
@@ -653,13 +597,5 @@ void bot.start({
|
||||
onStart: info => {
|
||||
botUsername = info.username
|
||||
process.stderr.write(`telegram channel: polling as @${info.username}\n`)
|
||||
void bot.api.setMyCommands(
|
||||
[
|
||||
{ command: 'start', description: 'Welcome and setup guide' },
|
||||
{ command: 'help', description: 'What this bot can do' },
|
||||
{ command: 'status', description: 'Check your pairing status' },
|
||||
],
|
||||
{ scope: { type: 'all_private_chats' } },
|
||||
).catch(() => {})
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user