GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - weiza0v0/dsh-im-hold

This repository was archived by the owner on Nov 19, 2026. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

6 Commits
6 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
build
build
 
 
dist
dist
 
 
patches
patches
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
apply.sh
apply.sh
 
 

Repository files navigation

⚠️ 状态:已归档,不再维护(2026-11-20)

上游 @xmanrui/dsh-im 到 5.10.0 依然只提供「主动投递文字」,没有 sendProactiveFile, 也没有 /api/dsh-im/delivery/files。但这个补丁的做法(改 36 个源文件 + 重建 9 MB 的 lib/index.js)意味着每次上游升级都要重新 rebase 一遍,维护成本远高于收益。

现在改用另一条路:把文件投递从 dsh-im 里搬出来,由 weiza0v0/dsh-im-tools 直连目标平台的开放 API (v0.2.0 起内置飞书直连:tenant_access_token → im/v1/files|images → im/v1/messages)。 这样 dsh-im 可以跟着上游随便升,文件投递不会跟着坏,也不用再维护任何源码补丁。

本仓库因此归档:不再跟进上游版本,不再发布新 patch。下面的内容保留作为历史参考 (想看「/hold 图文暂存」和「delivery/files」当年是怎么在 dsh-im 里实现的,仍然有用)。 本机(5.4.0 基线)曾把该补丁 rebase 到 5.4.0 并跑通,那份改动只在本机归档,未发布到这里。

dsh-im-hold

@xmanrui/dsh-im 的本地补丁:/hold 图文暂存 + 主动投递文件接口。

这是对上游的补丁,不是独立插件。上游 issue 已在讨论(xmanrui/dsh-im#385); 如果被合并,本仓库即可弃用。

解决什么问题

微信个人号协议里图片和文字是两条消息。图片单独到达时,插件会自动用「请分析这张图片。」发起一个回合, 用户再补要求时那一轮已经跑完——「图 + 说明」永远变成两轮。

/hold 在消息进入批处理层之前把它们收在一起:

/hold             进入暂存:文字、图片、文件都只收不发
(发图 / 发文件 / 打字,回执「已暂存 N/10 项(文字 a 条、图片 b 张、文件 c 个)」)
/send             合成一条提交:文字按顺序作 [消息 N],媒体作为附件一起带上
/cancel           丢弃

限制:10 项;图片合计 ≤ 20 张、文件合计 ≤ 10 个;仅私聊。暂存时图片立即下载,避免短时效链接过期。

/reset:只重置推送额度窗口(不解除会话绑定)

/reset

三条命令的分工:

命令 作用 是否解除会话绑定 是否耗 token
/new 开启全新会话 ✅ 唯一解绑命令 ❌
/clear 清空当前会话的模型上下文 ❌ 保留绑定与历史 ❌
/reset 重新激活被风控的主动推送窗口 ❌ 保持不变 ❌
  • /reset 不清理任何会话/上下文状态,只回一条本地确认;
  • 它本身就是一条入站用户消息,微信侧被风控的推送窗口会随之重新激活 (机制见 xmanrui/dsh-im#151);
  • 顺带把 dsh-im-tools 的「自上次用户消息以来的发送数」归零(靠入站时间戳判断)。

说明:dsh-im 不是代理服务器,它在本机直接调用微信 iLink 的 HTTP 接口;「握手」在微信服务端, 唯一被验证有效的激活方式就是用户发一条消息——/reset 就是零 token 的激活姿势。

附带:主动投递文件

POST /api/dsh-im/delivery/files
{"botId":"...","targetId":"...","path":"/absolute/path/file.pdf"}
→ {"sent":true,"fileName":"file.pdf"}

绝对路径、普通文件、≤ 30 MB;图片走 sendImage,其它走 sendFile。

覆盖渠道:微信、飞书(仅群聊目标)、企微、企微自建应用、钉钉、QQ、Telegram、Slack、Discord、 WhatsApp、Email、Matrix;iMessage 仅文字。

兼容性

dsh-im 版本 状态
5.0.2 ✅ 本补丁目标版本
5.1.0+ ❌ 需要 rebase(上游改动较大,见 issue)

安装

git clone https://github.com/weiza0v0/dsh-im-hold.git
cd dsh-im-hold
bash apply.sh
# 然后重启 dsh web

apply.sh 会:

  1. 校验已安装版本是 5.0.2;
  2. 备份并 patch -p1 应用 patches/dsh-im-5.0.2.patch(36 个源文件);
  3. 把预先构建好的 dist/lib-index-5.0.2.js 安装为 lib/index.js(校验 SHA-256);
  4. 提示重启。

自定义安装位置:

DSH_IM_PKG_DIR=/path/to/node_modules/@xmanrui/dsh-im bash apply.sh

卸载 / 回滚

cd ~/.dsh/profiles/web
rm -rf node_modules/@xmanrui/dsh-im
pnpm install --force

或者恢复安装时生成的 *.bak_hold_<时间戳> 备份文件。

与 pnpm install 的关系

pnpm install 可能把 dsh-im 重装成原版并冲掉补丁。装完插件/升级依赖后重新跑一次 apply.sh, 或在 profile 的 package.json 里加:

"scripts": { "postinstall": "bash patches/dsh-im-hold/apply.sh || true" }

从源码重建

lib/index.js 是 esbuild 打出来的单文件 bundle,改 src/ 必须重建:

cd build
npm install
DSH_IM_PKG_DIR="$HOME/.dsh/profiles/web/node_modules/@xmanrui/dsh-im" node build.mjs

细节见 build/README.md。

改动范围

  • src/channels/shared/batch-input.mjs:/hold 状态机、条目结构、上限;
  • src/channels/shared/text-harness-bridge.mjs:媒体接入收集器;
  • 微信 / 飞书 / 企微 / 企微应用 / 钉钉 / QQ 六个桥的批处理入口;
  • plugin-src/host/delivery-{adapter,service,rpc,http}.mjs:文件投递接口;
  • 各渠道 runtime/controller:sendProactiveFile;
  • 命令目录与英文翻译。

完整 diff 见 patches/dsh-im-5.0.2.patch。

常见问题

  • 发文件/文字返回 502 / iLink {"ret":-2,"errmsg":"prepare failed"}:这是微信侧限制——连续主动发送约 10 条后会被拒绝, 让用户先给机器人发一条消息即可恢复。上游讨论:xmanrui/dsh-im#151。
  • /hold 不生效:确认已重启 dsh web,且安装的 bundle 校验和与本仓库 dist/SHA256SUMS 一致。
  • pnpm install 后补丁消失:重跑 apply.sh,或按 README 在 profile 里加 postinstall 钩子。

安全

  • 文件接口没有鉴权、也没有 CORS,只应在本机使用;
  • 接口接受任意本地绝对路径(≤ 30 MB),不可信环境请自行加目录白名单或不要暴露 3080。

配套工具

想在 agent 里直接调用「发到微信」而不是手写 curl,可以配合 weiza0v0/dsh-im-tools(提供 im_send_text / im_send_file 工具)。

许可

MIT。修改与分发基于 @xmanrui/dsh-im(MIT),保留其版权声明。

About

No description, website, or topics provided.

Resources

Readme
License
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.