Nicotinamide/dsh-plugin-tg-bridge ↗★ 0
dsh-plugin-tg-bridge
DSH <-> Telegram bridge as a profile plugin: forward session activity, replies, and question/approval button flows to Telegram, with a persistent GUI card in 插件配置.
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Nicotinamide/dsh-plugin-tg-bridge说明文档
阅读完整 README ↗配置(二选一,env 优先)
方式 A:cordis.patch.yml(推荐日常使用)
在 /cordis.patch.yml(默认 $DSH_HOME/profiles/web/cordis.patch.yml)追加:
- insert:
- id: tg-bridge
name: 'dsh-plugin-tg-bridge'
config:
botToken: '' # @BotFather 创建 bot 后获取
allowedChat: '' # 和 bot 私聊后 @userinfobot 可查
tgApiBase: 'https://api.telegram.org' # 默认官方;被墙时换成自己的代理
pollTimeoutSeconds: 25 # 官方长轮询 25 正常;走代理建议 2
方式 B:环境变量(token 不进文件,适合分享/部署)
export TG_BOT_TOKEN=''
export TG_ALLOWED_CHAT=''
export TG_API_BASE='https://api.telegram.org' # 被墙时换成自己的代理
export TG_POLL_TIMEOUT_SECONDS=25 # 走代理建议 2
dsh web # 或你的启动脚本
优先级:环境变量 > settings 用户层 > patch 配置 > 默认值。
方式 A:cordis.patch.yml(推荐日常使用)
在 /cordis.patch.yml(默认 $DSH_HOME/profiles/web/cordis.patch.yml)追加:
- insert:
- id: tg-bridge
name: 'dsh-plugin-tg-bridge'
config:
botToken: '' # @BotFather 创建 bot 后获取
allowedChat: '' # 和 bot 私聊后 @userinfobot 可查
tgApiBase: 'https://api.telegram.org' # 默认官方;被墙时换成自己的代理
pollTimeoutSeconds: 25 # 官方长轮询 25 正常;走代理建议 2
配置项
| 字段 | 环境变量 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
botToken | TG_BOT_TOKEN | ✅ | — | Telegram bot token(@BotFather) |
allowedChat | TG_ALLOWED_CHAT | — | 允许的 chat id(旧版单用户写法;配置了 allowedUsers 可留空) | |
allowedUsers | — | [] | 多用户:[{chatId, label?}],每个 chat id 拥有独立的会话空间;label 仅为可选备注(显示名默认取 Telegram 真实名称,无需配置) | |
adminChatIds | — | [] | 管理员 chat id:可查看/操作所有用户的会话,可执行 /restart | |
askerRequired | — | true | 提问/审批按钮只能由发起者本人点击,群组里其他人点击会被拒绝 | |
tgApiBase | TG_API_BASE | https://api.telegram.org | Bot API 基址(被墙时换成自己的代理) | |
pollTimeoutSeconds | TG_POLL_TIMEOUT_SECONDS | 25 | getUpdates 轮询超时;走代理建议 2 | |
dshBaseUrl | TG_DSH_BASE_URL | 自动检测 | DSH 客户端 API 基址;默认自动使用运行进程的实际端口(端口每次启动可能变化),显式配置(env/patch)优先 | |
muxUrl | TG_MUX_URL | 自动检测 | DSH 事件流地址;同样默认随实际端口自动推导,显式配置优先 | |
stateFile | TG_STATE_FILE | $DSH_HOME/tg-bridge-state.json | 状态持久化文件 | |
turnTimeoutMs | TG_TURN_TIMEOUT_MS | 600000 | 回合超时提醒 | |
tgTimeoutMs | TG_TG_TIMEOUT_MS | 30000 | Telegram API 超时 | |
dshTimeoutMs | TG_DSH_TIMEOUT_MS | 15000 | DSH API 超时 |
GUI(插件配置页)
包内自带持久 client 半部:设置 → 插件 → 插件配置 出现「Telegram 遥控 / Telegram Remote」双语卡片(跟随系统语言),可编辑 Bot Token(留空保持不变)、Allowed Users/Groups(每行一个 chatId,即授权用户/群组)、Admin Chat IDs(每行一个)、提问/审批按钮归属开关、Telegram API Base、Poll Timeout;保存即热重载,无需重启。重启后依然存在(无需重新激活)。注意:GUI 列表字段留空保存不会清空已有条目(与 token 的"留空不变"一致)——移除授权请在 TG 用 /revoke。