dsh-chat-comprehension 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +20 -0
- package/README.md +20 -9
- package/client.js +30 -9
- package/lib/engines.mjs +136 -0
- package/lib/index.js +37 -4
- package/lib/qqbot-0.5.3-patches.json +75 -70
- package/lib/qqbot-patch.mjs +12 -7
- package/lib/video.mjs +11 -2
- package/package.json +7 -23
- package/vendor/dsh-agent-md/LICENSE +21 -0
- package/vendor/dsh-agent-md/cordis.patch.yml +8 -0
- package/vendor/dsh-agent-md/lib/index.js +775 -0
- package/vendor/dsh-agent-md/lib/persona.js +634 -0
- package/vendor/dsh-agent-md/lib/qq.js +527 -0
- package/vendor/dsh-agent-md/package.json +50 -0
- package/vendor/dsh-bili-scroll/LICENSE +21 -0
- package/vendor/dsh-bili-scroll/NOTICE.md +18 -0
- package/vendor/dsh-bili-scroll/cordis.patch.yml +20 -0
- package/vendor/dsh-bili-scroll/index.js +3278 -0
- package/vendor/dsh-bili-scroll/lib/asr.py +141 -0
- package/vendor/dsh-bili-scroll/lib/diagnose.mjs +95 -0
- package/vendor/dsh-bili-scroll/lib/dm.mjs +110 -0
- package/vendor/dsh-bili-scroll/lib/favops.py +90 -0
- package/vendor/dsh-bili-scroll/lib/hostdeps.mjs +148 -0
- package/vendor/dsh-bili-scroll/lib/login.mjs +141 -0
- package/vendor/dsh-bili-scroll/lib/mcp.mjs +144 -0
- package/vendor/dsh-bili-scroll/lib/state.mjs +236 -0
- package/vendor/dsh-bili-scroll/lib/uid.mjs +61 -0
- package/vendor/dsh-bili-scroll/lib/uvfetch.mjs +217 -0
- package/vendor/dsh-bili-scroll/lib/verify.mjs +184 -0
- package/vendor/dsh-bili-scroll/package.json +84 -0
- package/vendor/dsh-bili-scroll/profile-template/bili-duty/cordis.patch.yml +116 -0
- package/vendor/dsh-bili-scroll/profile-template/bili-duty/cordis.yml +4 -0
- package/vendor/dsh-bili-scroll/profile-template/bili-duty/package.json +13 -0
- package/vendor/dsh-bili-scroll/prompts/duty.md +296 -0
- package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/LICENSE +21 -0
- package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/README.md +176 -0
- package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/mcp_server.py +2015 -0
- package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/requirements.txt +10 -0
- package/vendor/dsh-meme/.dsh/skills/dsh-meme-maintenance/SKILL.md +50 -0
- package/vendor/dsh-meme/LICENSE +21 -0
- package/vendor/dsh-meme/anim.js +588 -0
- package/vendor/dsh-meme/cordis.patch.yml +13 -0
- package/vendor/dsh-meme/icon.jpg +0 -0
- package/vendor/dsh-meme/index.js +2616 -0
- package/vendor/dsh-meme/locale/en.json +6 -0
- package/vendor/dsh-meme/locale/zh.json +6 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/index.db +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/manifest.json +13 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/angry/shengqi.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/baka/xianqi.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/color/huachi.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/confused/jiazai.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/confused/wenhao.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/cpu/jiaban.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/daily/ganfan.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/fool/buyao.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/givemoney/yaoqian.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/happy/deyi.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/happy/ok.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/happy/piaole.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/like/bixin.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/meow/maozhua.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/morning/zaoshanghao.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/sad/qiurao.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/sad/yun.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/see/zhenjing.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/shy/haixiu.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/shy/toukan.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/sigh/wuyu.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/sleep/shuijiao.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/surprised/xia.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/work/tangping.jpg +0 -0
- package/vendor/dsh-meme/memes.js +998 -0
- package/vendor/dsh-meme/package.json +67 -0
- package/vendor/dsh-meme/panel.html +210 -0
- package/vendor/dsh-video-storyboard/LICENSE +21 -0
- package/vendor/dsh-video-storyboard/NOTICE +12 -0
- package/vendor/dsh-video-storyboard/bin/_args.mjs +16 -0
- package/vendor/dsh-video-storyboard/bin/asr-check.mjs +85 -0
- package/vendor/dsh-video-storyboard/bin/scan-stats.mjs +43 -0
- package/vendor/dsh-video-storyboard/bin/scan-video.mjs +38 -0
- package/vendor/dsh-video-storyboard/bin/storyboard.mjs +195 -0
- package/vendor/dsh-video-storyboard/cordis.patch.yml +3 -0
- package/vendor/dsh-video-storyboard/dsh.plugin.json +12 -0
- package/vendor/dsh-video-storyboard/package.json +88 -0
- package/vendor/dsh-video-storyboard/scripts/check-syntax.mjs +56 -0
- package/vendor/dsh-video-storyboard/scripts/install-dev.mjs +104 -0
- package/vendor/dsh-video-storyboard/src/flicker.js +104 -0
- package/vendor/dsh-video-storyboard/src/index.js +82 -0
- package/vendor/dsh-video-storyboard/src/ocr_bridge.py +103 -0
- package/vendor/dsh-video-storyboard/src/storyboard/asr-lifecycle.js +262 -0
- package/vendor/dsh-video-storyboard/src/storyboard/asr.js +488 -0
- package/vendor/dsh-video-storyboard/src/storyboard/audio.js +168 -0
- package/vendor/dsh-video-storyboard/src/storyboard/binaries.js +69 -0
- package/vendor/dsh-video-storyboard/src/storyboard/board.js +121 -0
- package/vendor/dsh-video-storyboard/src/storyboard/browser-time.js +504 -0
- package/vendor/dsh-video-storyboard/src/storyboard/cache.js +143 -0
- package/vendor/dsh-video-storyboard/src/storyboard/cells.js +70 -0
- package/vendor/dsh-video-storyboard/src/storyboard/density.js +545 -0
- package/vendor/dsh-video-storyboard/src/storyboard/direct-url.js +130 -0
- package/vendor/dsh-video-storyboard/src/storyboard/fetch.js +373 -0
- package/vendor/dsh-video-storyboard/src/storyboard/flash.js +180 -0
- package/vendor/dsh-video-storyboard/src/storyboard/format.js +573 -0
- package/vendor/dsh-video-storyboard/src/storyboard/frames.js +212 -0
- package/vendor/dsh-video-storyboard/src/storyboard/index.js +32 -0
- package/vendor/dsh-video-storyboard/src/storyboard/injection.js +76 -0
- package/vendor/dsh-video-storyboard/src/storyboard/layout-order.js +176 -0
- package/vendor/dsh-video-storyboard/src/storyboard/locate.js +113 -0
- package/vendor/dsh-video-storyboard/src/storyboard/media-store.js +106 -0
- package/vendor/dsh-video-storyboard/src/storyboard/memory.js +94 -0
- package/vendor/dsh-video-storyboard/src/storyboard/ocr-subs.js +107 -0
- package/vendor/dsh-video-storyboard/src/storyboard/ocr.js +167 -0
- package/vendor/dsh-video-storyboard/src/storyboard/pipeline.js +853 -0
- package/vendor/dsh-video-storyboard/src/storyboard/plan.js +400 -0
- package/vendor/dsh-video-storyboard/src/storyboard/probe.js +132 -0
- package/vendor/dsh-video-storyboard/src/storyboard/provenance.js +44 -0
- package/vendor/dsh-video-storyboard/src/storyboard/python.js +84 -0
- package/vendor/dsh-video-storyboard/src/storyboard/register.js +32 -0
- package/vendor/dsh-video-storyboard/src/storyboard/scan.js +486 -0
- package/vendor/dsh-video-storyboard/src/storyboard/segments.js +117 -0
- package/vendor/dsh-video-storyboard/src/storyboard/sheet.js +507 -0
- package/vendor/dsh-video-storyboard/src/storyboard/storage.js +93 -0
- package/vendor/dsh-video-storyboard/src/storyboard/subtitles.js +181 -0
- package/vendor/dsh-video-storyboard/src/storyboard/tool-spec.js +544 -0
- package/vendor/dsh-video-storyboard/src/storyboard/transcript-file.js +146 -0
- package/vendor/dsh-video-storyboard/src/storyboard/url.js +69 -0
- package/vendor/dsh-video-storyboard/src/storyboard/ytdlp.js +289 -0
- package/vendor/dsh-video-storyboard/src/tool-spec.js +17 -0
- package/vendor/dsh-video-storyboard/src/tools/locate.js +39 -0
- package/vendor/dsh-video-storyboard/src/tools/probe.js +23 -0
- package/vendor/dsh-video-storyboard/src/tools/shared.js +39 -0
- package/vendor/dsh-video-storyboard/src/tools/storyboard.js +20 -0
- package/vendor/dsh-video-storyboard/src/tools/zoom.js +56 -0
- package/vendor/dsh-world/LICENSE +21 -0
- package/vendor/dsh-world/assets/qq-card.png +0 -0
- package/vendor/dsh-world/cordis.patch.yml +6 -0
- package/vendor/dsh-world/lib/archive.d.ts +6 -0
- package/vendor/dsh-world/lib/archive.js +49 -0
- package/vendor/dsh-world/lib/archiveSelection.d.ts +8 -0
- package/vendor/dsh-world/lib/archiveSelection.js +20 -0
- package/vendor/dsh-world/lib/compaction.d.ts +124 -0
- package/vendor/dsh-world/lib/compaction.js +273 -0
- package/vendor/dsh-world/lib/compactionRegion.d.ts +42 -0
- package/vendor/dsh-world/lib/compactionRegion.js +210 -0
- package/vendor/dsh-world/lib/console/routes.d.ts +57 -0
- package/vendor/dsh-world/lib/console/routes.js +129 -0
- package/vendor/dsh-world/lib/console/snapshot.d.ts +39 -0
- package/vendor/dsh-world/lib/console/snapshot.js +51 -0
- package/vendor/dsh-world/lib/ecosystem/bridge/bridge.d.ts +36 -0
- package/vendor/dsh-world/lib/ecosystem/bridge/bridge.js +140 -0
- package/vendor/dsh-world/lib/ecosystem/bridge/route.d.ts +9 -0
- package/vendor/dsh-world/lib/ecosystem/bridge/route.js +46 -0
- package/vendor/dsh-world/lib/ecosystem/qq/bridge.d.ts +123 -0
- package/vendor/dsh-world/lib/ecosystem/qq/bridge.js +380 -0
- package/vendor/dsh-world/lib/ecosystem/qq/panel.d.ts +75 -0
- package/vendor/dsh-world/lib/ecosystem/qq/panel.js +187 -0
- package/vendor/dsh-world/lib/ecosystem/qq/route.d.ts +32 -0
- package/vendor/dsh-world/lib/ecosystem/qq/route.js +134 -0
- package/vendor/dsh-world/lib/ecosystem/qq/supervisor.d.ts +57 -0
- package/vendor/dsh-world/lib/ecosystem/qq/supervisor.js +188 -0
- package/vendor/dsh-world/lib/ecosystem/shared/context.d.ts +14 -0
- package/vendor/dsh-world/lib/ecosystem/shared/context.js +42 -0
- package/vendor/dsh-world/lib/ecosystem/shared/identity.d.ts +15 -0
- package/vendor/dsh-world/lib/ecosystem/shared/identity.js +36 -0
- package/vendor/dsh-world/lib/ecosystem/shared/outlets.d.ts +43 -0
- package/vendor/dsh-world/lib/ecosystem/shared/outlets.js +70 -0
- package/vendor/dsh-world/lib/ecosystem/shared/sessions.d.ts +16 -0
- package/vendor/dsh-world/lib/ecosystem/shared/sessions.js +52 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/archive.d.ts +24 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/archive.js +62 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/home.d.ts +21 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/home.js +111 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/images.d.ts +5 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/images.js +43 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/index.d.ts +41 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/index.js +166 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/messages.d.ts +24 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/messages.js +35 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/sending.d.ts +30 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/sending.js +216 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/supervisor.d.ts +39 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/supervisor.js +138 -0
- package/vendor/dsh-world/lib/faults.d.ts +10 -0
- package/vendor/dsh-world/lib/faults.js +13 -0
- package/vendor/dsh-world/lib/history.d.ts +16 -0
- package/vendor/dsh-world/lib/history.js +80 -0
- package/vendor/dsh-world/lib/hostContract.d.ts +19 -0
- package/vendor/dsh-world/lib/hostContract.js +1 -0
- package/vendor/dsh-world/lib/http.d.ts +18 -0
- package/vendor/dsh-world/lib/http.js +39 -0
- package/vendor/dsh-world/lib/index.d.ts +108 -0
- package/vendor/dsh-world/lib/index.js +356 -0
- package/vendor/dsh-world/lib/life/activity.d.ts +14 -0
- package/vendor/dsh-world/lib/life/activity.js +58 -0
- package/vendor/dsh-world/lib/life/alarm.d.ts +39 -0
- package/vendor/dsh-world/lib/life/alarm.js +132 -0
- package/vendor/dsh-world/lib/life/alarmTimer.d.ts +22 -0
- package/vendor/dsh-world/lib/life/alarmTimer.js +49 -0
- package/vendor/dsh-world/lib/life/diary.d.ts +4 -0
- package/vendor/dsh-world/lib/life/diary.js +9 -0
- package/vendor/dsh-world/lib/life/earlyStop.d.ts +19 -0
- package/vendor/dsh-world/lib/life/earlyStop.js +25 -0
- package/vendor/dsh-world/lib/life/home.d.ts +34 -0
- package/vendor/dsh-world/lib/life/home.js +91 -0
- package/vendor/dsh-world/lib/life/host.d.ts +22 -0
- package/vendor/dsh-world/lib/life/host.js +24 -0
- package/vendor/dsh-world/lib/life/journal.d.ts +20 -0
- package/vendor/dsh-world/lib/life/journal.js +59 -0
- package/vendor/dsh-world/lib/life/lifeStore.d.ts +16 -0
- package/vendor/dsh-world/lib/life/lifeStore.js +105 -0
- package/vendor/dsh-world/lib/life/messages.d.ts +17 -0
- package/vendor/dsh-world/lib/life/messages.js +53 -0
- package/vendor/dsh-world/lib/life/notify.d.ts +15 -0
- package/vendor/dsh-world/lib/life/notify.js +40 -0
- package/vendor/dsh-world/lib/life/pricing.d.ts +4 -0
- package/vendor/dsh-world/lib/life/pricing.js +30 -0
- package/vendor/dsh-world/lib/life/runtime.d.ts +52 -0
- package/vendor/dsh-world/lib/life/runtime.js +376 -0
- package/vendor/dsh-world/lib/life/toolRegistry.d.ts +22 -0
- package/vendor/dsh-world/lib/life/toolRegistry.js +64 -0
- package/vendor/dsh-world/lib/life/tools.d.ts +24 -0
- package/vendor/dsh-world/lib/life/tools.js +47 -0
- package/vendor/dsh-world/lib/life/types.d.ts +67 -0
- package/vendor/dsh-world/lib/life/types.js +1 -0
- package/vendor/dsh-world/lib/persona.d.ts +10 -0
- package/vendor/dsh-world/lib/persona.js +29 -0
- package/vendor/dsh-world/lib/promptSection.d.ts +30 -0
- package/vendor/dsh-world/lib/promptSection.js +81 -0
- package/vendor/dsh-world/lib/qqScope.d.ts +11 -0
- package/vendor/dsh-world/lib/qqScope.js +39 -0
- package/vendor/dsh-world/lib/runtime.d.ts +23 -0
- package/vendor/dsh-world/lib/runtime.js +206 -0
- package/vendor/dsh-world/lib/self.d.ts +10 -0
- package/vendor/dsh-world/lib/self.js +36 -0
- package/vendor/dsh-world/lib/sourceArchive.d.ts +28 -0
- package/vendor/dsh-world/lib/sourceArchive.js +156 -0
- package/vendor/dsh-world/lib/store.d.ts +30 -0
- package/vendor/dsh-world/lib/store.js +191 -0
- package/vendor/dsh-world/lib/timeContext.d.ts +3 -0
- package/vendor/dsh-world/lib/timeContext.js +13 -0
- package/vendor/dsh-world/lib/types.d.ts +118 -0
- package/vendor/dsh-world/lib/types.js +1 -0
- package/vendor/dsh-world/lib/worldPrompt.d.ts +47 -0
- package/vendor/dsh-world/lib/worldPrompt.js +49 -0
- package/vendor/dsh-world/lib/worldSwitch.d.ts +44 -0
- package/vendor/dsh-world/lib/worldSwitch.js +78 -0
- package/vendor/dsh-world/package-lock.json +1088 -0
- package/vendor/dsh-world/package.json +88 -0
- package/vendor/dsh-world/scripts/enable-tool-free-compaction.ps1 +33 -0
- package/vendor/dsh-world/src/archive.ts +45 -0
- package/vendor/dsh-world/src/archiveSelection.ts +27 -0
- package/vendor/dsh-world/src/compaction.ts +260 -0
- package/vendor/dsh-world/src/compactionRegion.ts +172 -0
- package/vendor/dsh-world/src/console/routes.ts +125 -0
- package/vendor/dsh-world/src/console/snapshot.ts +84 -0
- package/vendor/dsh-world/src/ecosystem/README.md +14 -0
- package/vendor/dsh-world/src/ecosystem/bridge/bridge.ts +121 -0
- package/vendor/dsh-world/src/ecosystem/bridge/route.ts +35 -0
- package/vendor/dsh-world/src/ecosystem/qq/bridge.ts +456 -0
- package/vendor/dsh-world/src/ecosystem/qq/panel.ts +178 -0
- package/vendor/dsh-world/src/ecosystem/qq/route.ts +130 -0
- package/vendor/dsh-world/src/ecosystem/qq/supervisor.ts +262 -0
- package/vendor/dsh-world/src/ecosystem/shared/context.ts +38 -0
- package/vendor/dsh-world/src/ecosystem/shared/identity.ts +42 -0
- package/vendor/dsh-world/src/ecosystem/shared/outlets.ts +75 -0
- package/vendor/dsh-world/src/ecosystem/shared/sessions.ts +47 -0
- package/vendor/dsh-world/src/ecosystem/wechat/archive.ts +66 -0
- package/vendor/dsh-world/src/ecosystem/wechat/home.ts +94 -0
- package/vendor/dsh-world/src/ecosystem/wechat/images.ts +38 -0
- package/vendor/dsh-world/src/ecosystem/wechat/index.ts +101 -0
- package/vendor/dsh-world/src/ecosystem/wechat/messages.ts +43 -0
- package/vendor/dsh-world/src/ecosystem/wechat/sending.ts +177 -0
- package/vendor/dsh-world/src/ecosystem/wechat/supervisor.ts +116 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/README.md +117 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/adapter.py +572 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/binding.py +52 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/LICENSE +43 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/NOTICE.md +10 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/bridge.cpp +229 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/build.ps1 +19 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/profile.json +28 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/groups.py +42 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/incoming.py +157 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/native.py +168 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/outgoing.py +95 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/requirements.txt +1 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/sender.py +157 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/snapshot.py +32 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/stickers.py +60 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/wechat.ps1 +75 -0
- package/vendor/dsh-world/src/faults.ts +12 -0
- package/vendor/dsh-world/src/history.ts +77 -0
- package/vendor/dsh-world/src/hostContract.ts +9 -0
- package/vendor/dsh-world/src/http.ts +34 -0
- package/vendor/dsh-world/src/index.ts +286 -0
- package/vendor/dsh-world/src/life/activity.ts +48 -0
- package/vendor/dsh-world/src/life/alarm.ts +119 -0
- package/vendor/dsh-world/src/life/alarmTimer.ts +45 -0
- package/vendor/dsh-world/src/life/diary.ts +10 -0
- package/vendor/dsh-world/src/life/earlyStop.ts +27 -0
- package/vendor/dsh-world/src/life/home.ts +85 -0
- package/vendor/dsh-world/src/life/host.ts +50 -0
- package/vendor/dsh-world/src/life/journal.ts +44 -0
- package/vendor/dsh-world/src/life/lifeStore.ts +70 -0
- package/vendor/dsh-world/src/life/messages.ts +44 -0
- package/vendor/dsh-world/src/life/notify.ts +47 -0
- package/vendor/dsh-world/src/life/pricing.ts +37 -0
- package/vendor/dsh-world/src/life/runtime.ts +318 -0
- package/vendor/dsh-world/src/life/toolRegistry.ts +48 -0
- package/vendor/dsh-world/src/life/tools.ts +61 -0
- package/vendor/dsh-world/src/life/types.ts +19 -0
- package/vendor/dsh-world/src/persona.ts +26 -0
- package/vendor/dsh-world/src/promptSection.ts +71 -0
- package/vendor/dsh-world/src/qqScope.ts +51 -0
- package/vendor/dsh-world/src/runtime.ts +172 -0
- package/vendor/dsh-world/src/self.ts +32 -0
- package/vendor/dsh-world/src/sourceArchive.ts +132 -0
- package/vendor/dsh-world/src/store.ts +170 -0
- package/vendor/dsh-world/src/timeContext.ts +13 -0
- package/vendor/dsh-world/src/types.ts +112 -0
- package/vendor/dsh-world/src/worldPrompt.ts +64 -0
- package/vendor/dsh-world/src/worldSwitch.ts +82 -0
- package/vendor/dsh-world/templates/alarm.md +49 -0
- package/vendor/dsh-world/templates/world-prompt.md +7 -0
- package/vendor/dsh-world/tests/archive.test.ts +57 -0
- package/vendor/dsh-world/tests/archiveScope.test.ts +86 -0
- package/vendor/dsh-world/tests/bridge.test.ts +211 -0
- package/vendor/dsh-world/tests/channelSessions.test.ts +79 -0
- package/vendor/dsh-world/tests/clientHooks.test.ts +103 -0
- package/vendor/dsh-world/tests/compaction.test.ts +141 -0
- package/vendor/dsh-world/tests/console.test.ts +202 -0
- package/vendor/dsh-world/tests/consoleClient.test.ts +101 -0
- package/vendor/dsh-world/tests/enableCompaction.test.ts +19 -0
- package/vendor/dsh-world/tests/fixtures.ts +6 -0
- package/vendor/dsh-world/tests/history.test.ts +100 -0
- package/vendor/dsh-world/tests/hostFixture.ts +46 -0
- package/vendor/dsh-world/tests/lifeActivity.test.ts +70 -0
- package/vendor/dsh-world/tests/lifeAlarm.test.ts +87 -0
- package/vendor/dsh-world/tests/lifeDiary.test.ts +33 -0
- package/vendor/dsh-world/tests/lifeMessages.test.ts +61 -0
- package/vendor/dsh-world/tests/lifeNotify.test.ts +46 -0
- package/vendor/dsh-world/tests/lifeParts.test.ts +45 -0
- package/vendor/dsh-world/tests/lifeRuntime.test.ts +660 -0
- package/vendor/dsh-world/tests/lifeStore.test.ts +90 -0
- package/vendor/dsh-world/tests/lifeTools.test.ts +53 -0
- package/vendor/dsh-world/tests/outlets.test.ts +85 -0
- package/vendor/dsh-world/tests/panel.test.ts +85 -0
- package/vendor/dsh-world/tests/plugin.test.ts +614 -0
- package/vendor/dsh-world/tests/pricing.test.ts +21 -0
- package/vendor/dsh-world/tests/qq.test.ts +121 -0
- package/vendor/dsh-world/tests/qqSessionMode.test.ts +97 -0
- package/vendor/dsh-world/tests/qqSupervisor.test.ts +149 -0
- package/vendor/dsh-world/tests/sourceArchive.test.ts +58 -0
- package/vendor/dsh-world/tests/store.test.ts +82 -0
- package/vendor/dsh-world/tests/storeWriter.ts +5 -0
- package/vendor/dsh-world/tests/timeContext.test.ts +15 -0
- package/vendor/dsh-world/tests/wechat.test.ts +254 -0
- package/vendor/dsh-world/tests/wechatImages.test.ts +130 -0
- package/vendor/dsh-world/tests/wechatSending.test.ts +142 -0
- package/vendor/dsh-world/tests/wechatSupervisor.test.ts +91 -0
- package/vendor/dsh-world/tests/worldPrompt.test.ts +201 -0
- package/vendor/dsh-world/tsconfig.build.json +5 -0
- package/vendor/dsh-world/tsconfig.json +8 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
The version-specific Weixin ABI facts and native message-construction approach
|
|
2
|
+
were researched using Prometheus-first/helper (native/core_version.h,
|
|
3
|
+
native/selftest_bridge.cpp, native/text_bridge.cpp, native/image_send.h and
|
|
4
|
+
native/emoticon_send.h). See the adjacent LICENSE for that project's
|
|
5
|
+
noncommercial terms. This directory is separately licensed, not covered by
|
|
6
|
+
the MIT license at the dsh-world repository root.
|
|
7
|
+
|
|
8
|
+
This is a tailored send-only bridge. It has its own request ABI and lifecycle;
|
|
9
|
+
it does not include helper's bot framework, model, user interface, receive
|
|
10
|
+
hooks, recall handling, account discovery or group management.
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// Native ABI research attribution and separate license: see NOTICE.md and LICENSE.
|
|
2
|
+
#define WIN32_LEAN_AND_MEAN
|
|
3
|
+
#include <windows.h>
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <cstring>
|
|
6
|
+
#include <functional>
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include <algorithm>
|
|
9
|
+
|
|
10
|
+
enum Call { Application, Scheduler, Schedule, Context, Provider, Manager, Text,
|
|
11
|
+
Image, Emoticon, CopyWide, ValidateGif, ProbeGif, ReleaseProbe, Send, Allocate,
|
|
12
|
+
Free, AccountRoot, ContextVtable, EmoticonVtable, CallCount };
|
|
13
|
+
struct Request {
|
|
14
|
+
uint32_t size, pid, ownerPid, kind, timestamp, imageSize;
|
|
15
|
+
uint32_t rva[CallCount];
|
|
16
|
+
char account[128], target[128], value[4096];
|
|
17
|
+
uint32_t status, stage, exception;
|
|
18
|
+
};
|
|
19
|
+
static_assert(sizeof(Request) == 4464);
|
|
20
|
+
struct Shared { unsigned char* object; unsigned char* owner; };
|
|
21
|
+
struct String { char data[16]{}; uint64_t length = 0, capacity = 15; };
|
|
22
|
+
struct Wide { const wchar_t* data; uint64_t unused, length, capacity; };
|
|
23
|
+
struct Probe { uint8_t valid, pad[7]; unsigned char image[16]; uint32_t width, height; };
|
|
24
|
+
struct Job {
|
|
25
|
+
Request request;
|
|
26
|
+
uintptr_t base;
|
|
27
|
+
HANDLE done = CreateEventW(nullptr, TRUE, FALSE, nullptr);
|
|
28
|
+
HANDLE owner;
|
|
29
|
+
volatile LONG cancelled = 0;
|
|
30
|
+
ULONGLONG deadline = GetTickCount64() + 60000;
|
|
31
|
+
explicit Job(const Request& input, uintptr_t address): request(input), base(address), owner(OpenProcess(SYNCHRONIZE, FALSE, input.ownerPid)) {}
|
|
32
|
+
~Job() { if (done) CloseHandle(done); if (owner) CloseHandle(owner); }
|
|
33
|
+
bool expired() { return InterlockedCompareExchange(&cancelled, 0, 0) || GetTickCount64() >= deadline || !owner || WaitForSingleObject(owner, 0) != WAIT_TIMEOUT; }
|
|
34
|
+
template<class F> F call(Call index) const { return reinterpret_cast<F>(base + request.rva[index]); }
|
|
35
|
+
void finish(uint32_t status) { request.status = status; SetEvent(done); }
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
static void release(Shared& value) {
|
|
39
|
+
auto owner = value.owner;
|
|
40
|
+
value = {};
|
|
41
|
+
if (!owner) return;
|
|
42
|
+
auto count = reinterpret_cast<volatile LONG*>(owner + 8);
|
|
43
|
+
using Destroy = void(*)(void*);
|
|
44
|
+
if (InterlockedDecrement(count) == 0) {
|
|
45
|
+
(*reinterpret_cast<Destroy**>(owner))[0](owner);
|
|
46
|
+
if (InterlockedDecrement(count + 1) == 0) (*reinterpret_cast<Destroy**>(owner))[1](owner);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
static bool assign(Job* job, String& destination, const char* text) {
|
|
50
|
+
auto length = strnlen_s(text, 4096);
|
|
51
|
+
if (length >= 4095 || destination.length || destination.capacity != 15) return false;
|
|
52
|
+
char* bytes = destination.data;
|
|
53
|
+
if (length > 15) {
|
|
54
|
+
bytes = static_cast<char*>(job->call<void*(*)(size_t)>(Allocate)(length + 1));
|
|
55
|
+
if (!bytes) return false;
|
|
56
|
+
memcpy(destination.data, &bytes, sizeof(bytes));
|
|
57
|
+
destination.capacity = length;
|
|
58
|
+
}
|
|
59
|
+
memcpy(bytes, text, length + 1);
|
|
60
|
+
destination.length = length;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
static void clear(Job* job, String& value) {
|
|
64
|
+
if (value.capacity > 15) {
|
|
65
|
+
void* data = *reinterpret_cast<void**>(value.data);
|
|
66
|
+
auto bytes = value.capacity + 1;
|
|
67
|
+
if (bytes >= 4096) { data = *(reinterpret_cast<void**>(data) - 1); bytes += 39; }
|
|
68
|
+
job->call<void(*)(void*, size_t)>(Free)(data, bytes);
|
|
69
|
+
}
|
|
70
|
+
value = {};
|
|
71
|
+
}
|
|
72
|
+
static bool accountMatches(Job* job, const Shared& context) {
|
|
73
|
+
if (!context.object || !context.owner) return false;
|
|
74
|
+
auto root = *job->call<uintptr_t*>(AccountRoot);
|
|
75
|
+
if (!root || *reinterpret_cast<void**>(root + 0x68) != context.object ||
|
|
76
|
+
*reinterpret_cast<uintptr_t*>(context.object) != job->base + job->request.rva[ContextVtable]) return false;
|
|
77
|
+
const auto& name = *reinterpret_cast<const String*>(context.object + 0x48);
|
|
78
|
+
auto length = strlen(job->request.account);
|
|
79
|
+
if (name.length != length || name.capacity < length || name.capacity > 1024 * 1024) return false;
|
|
80
|
+
const char* data = name.capacity > 15 ? *reinterpret_cast<const char* const*>(name.data) : name.data;
|
|
81
|
+
return data && memcmp(data, job->request.account, length) == 0 &&
|
|
82
|
+
*job->call<uintptr_t*>(AccountRoot) == root && *reinterpret_cast<void**>(root + 0x68) == context.object;
|
|
83
|
+
}
|
|
84
|
+
struct Completion {
|
|
85
|
+
volatile LONG references = 1;
|
|
86
|
+
uint32_t padding = 0;
|
|
87
|
+
void (*invoke)(Completion*, const unsigned char*);
|
|
88
|
+
void (*destroy)(Completion*);
|
|
89
|
+
std::shared_ptr<Job> job;
|
|
90
|
+
};
|
|
91
|
+
static void textCompleted(Completion* value, const unsigned char* result) {
|
|
92
|
+
value->job->finish(result && result[0] == 1 ? 0 : ERROR_GEN_FAILURE);
|
|
93
|
+
}
|
|
94
|
+
static void textDestroyed(Completion* value) { delete value; }
|
|
95
|
+
|
|
96
|
+
// The SEH boundary contains no C++ objects with destructors.
|
|
97
|
+
static void execute(Job* job, Completion* completion) {
|
|
98
|
+
Shared context{}, provider{}, manager{}, message{};
|
|
99
|
+
String description{};
|
|
100
|
+
struct { String receiver, body; } textRequest{};
|
|
101
|
+
alignas(16) unsigned char result[128]{};
|
|
102
|
+
struct { int32_t references, length; uint32_t allocation, padding; int64_t offset; wchar_t text[1024]; } qt{};
|
|
103
|
+
Probe probe{};
|
|
104
|
+
bool probeReady = false, textPending = false;
|
|
105
|
+
uint32_t status = ERROR_GEN_FAILURE;
|
|
106
|
+
__try {
|
|
107
|
+
job->request.stage = 1;
|
|
108
|
+
if (job->expired()) { status = ERROR_CANCELLED; __leave; }
|
|
109
|
+
job->call<Shared*(*)(Shared*)>(Context)(&context);
|
|
110
|
+
if (!accountMatches(job, context)) { status = ERROR_NOT_READY; __leave; }
|
|
111
|
+
if (!job->request.kind) { status = 0; __leave; }
|
|
112
|
+
if (job->request.kind == 1) {
|
|
113
|
+
if (!assign(job, textRequest.receiver, job->request.target) ||
|
|
114
|
+
!assign(job, textRequest.body, job->request.value) ||
|
|
115
|
+
!assign(job, description, "dsh.wechat")) { status = ERROR_INVALID_DATA; __leave; }
|
|
116
|
+
job->request.stage = 2;
|
|
117
|
+
if (job->expired() || !accountMatches(job, context)) { status = ERROR_CANCELLED; __leave; }
|
|
118
|
+
job->call<void(*)(void*, void*, String*, Completion**)>(Text)(nullptr, &textRequest, &description, &completion);
|
|
119
|
+
textPending = true;
|
|
120
|
+
status = 0;
|
|
121
|
+
__leave;
|
|
122
|
+
}
|
|
123
|
+
job->request.stage = 3;
|
|
124
|
+
int length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, job->request.value, -1, qt.text, 1024);
|
|
125
|
+
if (length <= 1 || GetFileAttributesW(qt.text) == INVALID_FILE_ATTRIBUTES) { status = ERROR_FILE_NOT_FOUND; __leave; }
|
|
126
|
+
qt.references = -1; qt.length = length - 1; qt.offset = 24;
|
|
127
|
+
if (job->request.kind == 3) {
|
|
128
|
+
Wide path{qt.text, 0, static_cast<uint64_t>(qt.length), 1023};
|
|
129
|
+
if (job->call<int(*)(Wide*)>(ValidateGif)(&path) != 2) { status = ERROR_NOT_SUPPORTED; __leave; }
|
|
130
|
+
probeReady = true;
|
|
131
|
+
job->call<Probe*(*)(Probe*, Wide*)>(ProbeGif)(&probe, &path);
|
|
132
|
+
if (!probe.valid || !probe.width || !probe.height || probe.width > 1024 || probe.height > 1024) {
|
|
133
|
+
status = ERROR_INVALID_DATA; __leave;
|
|
134
|
+
}
|
|
135
|
+
job->call<Shared*(*)(Shared*)>(Emoticon)(&message);
|
|
136
|
+
if (!message.object || !message.owner || *reinterpret_cast<uintptr_t*>(message.object) != job->base + job->request.rva[EmoticonVtable]) {
|
|
137
|
+
status = ERROR_INVALID_DATA; __leave;
|
|
138
|
+
}
|
|
139
|
+
*reinterpret_cast<uint32_t*>(message.object + 0x118) = 47;
|
|
140
|
+
*reinterpret_cast<uint64_t*>(message.object + 0x778) = probe.width | (static_cast<uint64_t>(probe.height) << 32);
|
|
141
|
+
job->call<void*(*)(void*, Wide*)>(CopyWide)(message.object + 0x120, &path);
|
|
142
|
+
} else {
|
|
143
|
+
void* path = &qt;
|
|
144
|
+
job->call<Shared*(*)(void*, Shared*, void*)>(Image)(nullptr, &message, &path);
|
|
145
|
+
if (!message.object || !message.owner || *reinterpret_cast<uint32_t*>(message.object + 0x118) != 3) { status = ERROR_INVALID_DATA; __leave; }
|
|
146
|
+
const auto& staged = *reinterpret_cast<const String*>(message.object + 0x120);
|
|
147
|
+
const wchar_t* destination = staged.capacity > 7 ? *reinterpret_cast<const wchar_t* const*>(staged.data) : reinterpret_cast<const wchar_t*>(staged.data);
|
|
148
|
+
if (!staged.length || staged.length >= 1024 || staged.capacity < staged.length || !CopyFileW(qt.text, destination, TRUE)) {
|
|
149
|
+
status = ERROR_WRITE_FAULT; __leave;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (!assign(job, *reinterpret_cast<String*>(message.object + 0xb0), job->request.target) || !accountMatches(job, context)) {
|
|
153
|
+
status = ERROR_NOT_READY; __leave;
|
|
154
|
+
}
|
|
155
|
+
job->call<Shared*(*)(void*, Shared*)>(Provider)(context.object, &provider);
|
|
156
|
+
if (!provider.object || !provider.owner) { status = ERROR_NOT_READY; __leave; }
|
|
157
|
+
job->call<Shared*(*)(void*, Shared*)>(Manager)(provider.object, &manager);
|
|
158
|
+
if (!manager.object || !manager.owner) { status = ERROR_NOT_READY; __leave; }
|
|
159
|
+
job->request.stage = 4;
|
|
160
|
+
if (job->expired() || !accountMatches(job, context)) { status = ERROR_CANCELLED; __leave; }
|
|
161
|
+
Shared transferred = message;
|
|
162
|
+
InterlockedIncrement(reinterpret_cast<volatile LONG*>(transferred.owner + 8));
|
|
163
|
+
job->call<void*(*)(void*, void*, Shared*, uint8_t)>(Send)(manager.object, result, &transferred, 1);
|
|
164
|
+
status = *reinterpret_cast<uint64_t*>(result) == 0 ? 0 : ERROR_GEN_FAILURE;
|
|
165
|
+
} __except (EXCEPTION_EXECUTE_HANDLER) { job->request.exception = GetExceptionCode(); status = ERROR_INVALID_DATA; }
|
|
166
|
+
__try {
|
|
167
|
+
if (completion) textDestroyed(completion);
|
|
168
|
+
clear(job, textRequest.receiver); clear(job, textRequest.body); clear(job, description);
|
|
169
|
+
release(*reinterpret_cast<Shared*>(result + 40));
|
|
170
|
+
clear(job, *reinterpret_cast<String*>(result + 8));
|
|
171
|
+
release(message);
|
|
172
|
+
if (probeReady) job->call<void(*)(void*)>(ReleaseProbe)(probe.image);
|
|
173
|
+
release(manager); release(provider); release(context);
|
|
174
|
+
} __except (EXCEPTION_EXECUTE_HANDLER) { job->request.exception = GetExceptionCode(); status = ERROR_INVALID_DATA; }
|
|
175
|
+
if (!textPending || status) job->finish(status);
|
|
176
|
+
}
|
|
177
|
+
static uint32_t enqueue(Job* job, std::function<void()>* task) {
|
|
178
|
+
Shared scheduler{}, future{};
|
|
179
|
+
struct { const char* function; const char* file; uint32_t line, padding; void* caller; } location{"dshWechat", "bridge.cpp", 1, 0, nullptr};
|
|
180
|
+
static_assert(sizeof(std::function<void()>) == 64);
|
|
181
|
+
uint32_t status = 0;
|
|
182
|
+
__try {
|
|
183
|
+
void* app = job->call<void*(*)()>(Application)();
|
|
184
|
+
if (!app) { status = ERROR_NOT_READY; __leave; }
|
|
185
|
+
job->call<Shared*(*)(void*, Shared*)>(Scheduler)(app, &scheduler);
|
|
186
|
+
if (!scheduler.object || !scheduler.owner) { status = ERROR_NOT_READY; __leave; }
|
|
187
|
+
job->call<Shared*(*)(void*, Shared*, void*, std::function<void()>*, uint32_t)>(Schedule)(scheduler.object, &future, &location, task, 1);
|
|
188
|
+
} __except (EXCEPTION_EXECUTE_HANDLER) { status = GetExceptionCode(); }
|
|
189
|
+
__try { release(future); release(scheduler); } __except (EXCEPTION_EXECUTE_HANDLER) { status = GetExceptionCode(); }
|
|
190
|
+
return status;
|
|
191
|
+
}
|
|
192
|
+
static bool valid(const Request& request, uintptr_t base) {
|
|
193
|
+
if (request.size != sizeof(Request) || request.pid != GetCurrentProcessId() || request.kind > 3 ||
|
|
194
|
+
!memchr(request.account, 0, sizeof(request.account)) || !request.account[0] ||
|
|
195
|
+
!memchr(request.target, 0, sizeof(request.target)) || !request.target[0] ||
|
|
196
|
+
!memchr(request.value, 0, sizeof(request.value))) return false;
|
|
197
|
+
__try {
|
|
198
|
+
auto dos = reinterpret_cast<const IMAGE_DOS_HEADER*>(base);
|
|
199
|
+
if (dos->e_magic != IMAGE_DOS_SIGNATURE || dos->e_lfanew < 64 || dos->e_lfanew > 1048576) return false;
|
|
200
|
+
auto header = reinterpret_cast<const IMAGE_NT_HEADERS64*>(base + dos->e_lfanew);
|
|
201
|
+
if (header->Signature != IMAGE_NT_SIGNATURE || header->FileHeader.Machine != IMAGE_FILE_MACHINE_AMD64 ||
|
|
202
|
+
header->FileHeader.TimeDateStamp != request.timestamp || header->OptionalHeader.SizeOfImage != request.imageSize) return false;
|
|
203
|
+
for (auto rva: request.rva) if (!rva || rva >= request.imageSize) return false;
|
|
204
|
+
return true;
|
|
205
|
+
} __except (EXCEPTION_EXECUTE_HANDLER) { return false; }
|
|
206
|
+
}
|
|
207
|
+
extern "C" __declspec(dllexport) DWORD WINAPI DshWechatSend(void* parameter) {
|
|
208
|
+
if (!parameter) return ERROR_INVALID_PARAMETER;
|
|
209
|
+
auto input = static_cast<Request*>(parameter);
|
|
210
|
+
auto core = reinterpret_cast<uintptr_t>(GetModuleHandleW(L"Weixin.dll"));
|
|
211
|
+
if (!core || !valid(*input, core)) return ERROR_NOT_SUPPORTED;
|
|
212
|
+
try {
|
|
213
|
+
auto job = std::make_shared<Job>(*input, core);
|
|
214
|
+
if (!job->done || !job->owner) return ERROR_NOT_ENOUGH_MEMORY;
|
|
215
|
+
std::function<void()> task = [job]() {
|
|
216
|
+
Completion* completion = job->request.kind == 1 ? new Completion{1, 0, textCompleted, textDestroyed, job} : nullptr;
|
|
217
|
+
execute(job.get(), completion);
|
|
218
|
+
};
|
|
219
|
+
auto status = enqueue(job.get(), &task);
|
|
220
|
+
if (status) return status;
|
|
221
|
+
if (WaitForSingleObject(job->done, 60000) != WAIT_OBJECT_0) {
|
|
222
|
+
InterlockedExchange(&job->cancelled, 1);
|
|
223
|
+
return WAIT_TIMEOUT;
|
|
224
|
+
}
|
|
225
|
+
input->status = job->request.status; input->stage = job->request.stage; input->exception = job->request.exception;
|
|
226
|
+
return input->status;
|
|
227
|
+
} catch (...) { return ERROR_GEN_FAILURE; }
|
|
228
|
+
}
|
|
229
|
+
BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID) { return TRUE; }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
$ErrorActionPreference = 'Stop'
|
|
2
|
+
$workspaceRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '../../../../..'))
|
|
3
|
+
$runtimeDir = Join-Path $workspaceRoot '.host\wechat\engine'
|
|
4
|
+
$source = Join-Path $PSScriptRoot 'bridge.cpp'
|
|
5
|
+
$sourceHash = (Get-FileHash -LiteralPath $source -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
6
|
+
$outputDir = Join-Path $runtimeDir $sourceHash.Substring(0,12)
|
|
7
|
+
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
|
|
8
|
+
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
|
|
9
|
+
$installation = & $vswhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
|
|
10
|
+
if (-not $installation) { throw '需要 Visual Studio C++ x64 构建工具' }
|
|
11
|
+
$vcvars = Join-Path $installation 'VC\Auxiliary\Build\vcvars64.bat'
|
|
12
|
+
$dll = Join-Path $outputDir 'dsh-wechat.dll'
|
|
13
|
+
$command = 'cl /nologo /std:c++17 /O2 /MT /EHsc /LD /utf-8 "' + $source + '" /Fo"' + (Join-Path $outputDir 'bridge.obj') + '" /link /OUT:"' + $dll + '" /IMPLIB:"' + (Join-Path $outputDir 'bridge.lib') + '"'
|
|
14
|
+
$buildScript = Join-Path $outputDir 'build.cmd'
|
|
15
|
+
@('@echo off', ('call "' + $vcvars + '" >nul'), 'if errorlevel 1 exit /b 1', $command, 'exit /b %errorlevel%') | Set-Content -LiteralPath $buildScript -Encoding utf8
|
|
16
|
+
& $env:ComSpec /d /c $buildScript
|
|
17
|
+
if ($LASTEXITCODE -ne 0) { throw '原生桥构建失败' }
|
|
18
|
+
@{file=$dll; sha256=(Get-FileHash -LiteralPath $dll -Algorithm SHA256).Hash.ToLowerInvariant(); sourceSha256=$sourceHash} | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $runtimeDir 'current.json') -Encoding utf8
|
|
19
|
+
Write-Output $dll
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "4.1.15.13",
|
|
3
|
+
"size": 201552944,
|
|
4
|
+
"sha256": "10f8e995453e2da46d4f2b5080cd6da1f13cc5147746adc119ceae38cb039de5",
|
|
5
|
+
"timestamp": 1789961080,
|
|
6
|
+
"imageSize": 202039296,
|
|
7
|
+
"addresses": {
|
|
8
|
+
"application": 285968,
|
|
9
|
+
"scheduler": 291600,
|
|
10
|
+
"schedule": 3125264,
|
|
11
|
+
"context": 291360,
|
|
12
|
+
"provider": 3589952,
|
|
13
|
+
"manager": 7294352,
|
|
14
|
+
"text": 88802032,
|
|
15
|
+
"image": 64608656,
|
|
16
|
+
"emoticon": 29340096,
|
|
17
|
+
"copyWide": 636368,
|
|
18
|
+
"validateGif": 15182048,
|
|
19
|
+
"probeGif": 5441984,
|
|
20
|
+
"releaseProbe": 5137248,
|
|
21
|
+
"send": 24703232,
|
|
22
|
+
"allocate": 122337436,
|
|
23
|
+
"free": 122337504,
|
|
24
|
+
"accountRoot": 194061968,
|
|
25
|
+
"contextVtable": 148890360,
|
|
26
|
+
"emoticonVtable": 151891960
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Group triggers use WeChat source metadata; context is bounded, read-only and paginated."""
|
|
2
|
+
import json
|
|
3
|
+
from xml.etree import ElementTree
|
|
4
|
+
|
|
5
|
+
MAX_CONTEXT_MESSAGES = 8
|
|
6
|
+
MAX_CONTEXT_BYTES = 16 * 1024
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def mentionedIds(source):
|
|
10
|
+
if source in (None, b'', ''):
|
|
11
|
+
return []
|
|
12
|
+
if isinstance(source, bytes):
|
|
13
|
+
if source.startswith(bytes.fromhex('28b52ffd')):
|
|
14
|
+
import zstandard
|
|
15
|
+
source = zstandard.ZstdDecompressor().decompress(source, max_output_size=128 * 1024)
|
|
16
|
+
source = source.decode('utf-8')
|
|
17
|
+
if not isinstance(source, str) or len(source.encode('utf-8')) > 128 * 1024:
|
|
18
|
+
raise ValueError('微信消息来源格式无效')
|
|
19
|
+
root = ElementTree.fromstring(source)
|
|
20
|
+
return [value.strip() for value in (root.findtext('atuserlist') or '').split(',') if value.strip()]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def recentContext(database, chatId, current, normalize, pageSize=50, limit=MAX_CONTEXT_MESSAGES):
|
|
24
|
+
def order(row):
|
|
25
|
+
return int(row['sort_seq']), row['shard'], int(row['local_id'])
|
|
26
|
+
boundary = order(current)
|
|
27
|
+
offset, found = 0, {}
|
|
28
|
+
while True:
|
|
29
|
+
page = database.get_messages(chatId, limit=pageSize, offset=offset)
|
|
30
|
+
for row in page:
|
|
31
|
+
if order(row) < boundary:
|
|
32
|
+
message = normalize(row)
|
|
33
|
+
if message:
|
|
34
|
+
found[order(row)] = message
|
|
35
|
+
keys = sorted(found)[-limit:]
|
|
36
|
+
if len(page) < pageSize or (len(keys) == limit and int(page[-1]['sort_seq']) < keys[0][0]):
|
|
37
|
+
break
|
|
38
|
+
offset += len(page)
|
|
39
|
+
result = [found[key] for key in keys]
|
|
40
|
+
while result and len(json.dumps(result, ensure_ascii=False).encode('utf-8')) > MAX_CONTEXT_BYTES:
|
|
41
|
+
result.pop(0)
|
|
42
|
+
return result
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""Read pictures from the explicitly selected account/chat cache, without UI downloads."""
|
|
2
|
+
import hashlib
|
|
3
|
+
import io
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import struct
|
|
7
|
+
import tempfile
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from wechatauto.media import MediaDownloader, V2_MAGIC, aligned_aes_block_size
|
|
10
|
+
from snapshot import fileStamp, SnapshotBusy
|
|
11
|
+
from stickers import StickerUnavailable, fetchSticker
|
|
12
|
+
|
|
13
|
+
MAX_IMAGE_BYTES = 10 * 1024 * 1024
|
|
14
|
+
MAX_IMAGE_PIXELS = 32_000_000
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ImageUnavailable(RuntimeError):
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def saveImage(source, root, selfId, chatId, quality):
|
|
22
|
+
from PIL import Image, ImageOps, UnidentifiedImageError
|
|
23
|
+
if Path(source).stat().st_size > MAX_IMAGE_BYTES:
|
|
24
|
+
raise ImageUnavailable('图片超过当前大小限制')
|
|
25
|
+
try:
|
|
26
|
+
with Image.open(source) as image:
|
|
27
|
+
if image.format not in ('PNG', 'JPEG', 'WEBP', 'GIF') or image.width * image.height > MAX_IMAGE_PIXELS:
|
|
28
|
+
raise ImageUnavailable('图片格式或像素数量暂不支持')
|
|
29
|
+
output = io.BytesIO()
|
|
30
|
+
ImageOps.exif_transpose(image).convert('RGBA').save(output, format='PNG')
|
|
31
|
+
data = output.getvalue()
|
|
32
|
+
except (UnidentifiedImageError, Image.DecompressionBombError) as error:
|
|
33
|
+
raise ImageUnavailable('微信缓存尚未形成可解码图片') from error
|
|
34
|
+
if len(data) > MAX_IMAGE_BYTES:
|
|
35
|
+
raise ImageUnavailable('转换后的图片超过当前大小限制')
|
|
36
|
+
key = hashlib.sha256(json.dumps(['wechat', selfId, 'group' if chatId.endswith('@chatroom') else 'private', chatId], ensure_ascii=False, separators=(',', ':')).encode()).hexdigest()
|
|
37
|
+
directory = Path(root) / key
|
|
38
|
+
directory.mkdir(parents=True, exist_ok=True)
|
|
39
|
+
name = hashlib.sha256(data).hexdigest() + '.png'
|
|
40
|
+
temporary = None
|
|
41
|
+
try:
|
|
42
|
+
with tempfile.NamedTemporaryFile(dir=directory, suffix='.tmp', delete=False) as stream:
|
|
43
|
+
temporary = Path(stream.name)
|
|
44
|
+
stream.write(data)
|
|
45
|
+
stream.flush()
|
|
46
|
+
os.fsync(stream.fileno())
|
|
47
|
+
os.replace(temporary, directory / name)
|
|
48
|
+
finally:
|
|
49
|
+
if temporary and temporary.exists(): temporary.unlink()
|
|
50
|
+
return dict(file=name, quality=quality)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class ScopedMedia(MediaDownloader):
|
|
54
|
+
def __init__(self, database, checkProcess):
|
|
55
|
+
super().__init__(database)
|
|
56
|
+
self.checkProcess = checkProcess
|
|
57
|
+
self.probeFile = None
|
|
58
|
+
self.templates = []
|
|
59
|
+
self.cfgAttempted = False
|
|
60
|
+
|
|
61
|
+
def _derive_cfg_key(self):
|
|
62
|
+
if not self.cfgAttempted:
|
|
63
|
+
self.cfgAttempted = True
|
|
64
|
+
self.checkProcess()
|
|
65
|
+
config = self.db.extract_master_key()
|
|
66
|
+
self.checkProcess()
|
|
67
|
+
if config:
|
|
68
|
+
if config[2] != self.db.wxid: raise RuntimeError('图片配置与绑定账号不符')
|
|
69
|
+
self._cfg_dword = config[1]
|
|
70
|
+
return super()._derive_cfg_key()
|
|
71
|
+
|
|
72
|
+
def _probe_ct(self, dat_path=None):
|
|
73
|
+
if not self.probeFile:
|
|
74
|
+
raise ImageUnavailable('没有选中图片缓存')
|
|
75
|
+
return super()._probe_ct(str(self.probeFile))
|
|
76
|
+
|
|
77
|
+
def _collect_templates(self, limit=32, keep=16):
|
|
78
|
+
return self.templates
|
|
79
|
+
|
|
80
|
+
def _scan_aes_key(self, monitor=False, monitor_timeout=120):
|
|
81
|
+
self.checkProcess()
|
|
82
|
+
return super()._scan_aes_key(monitor=False)
|
|
83
|
+
|
|
84
|
+
def _install_xor_key(self):
|
|
85
|
+
if self._xor_key is not None: return self._xor_key
|
|
86
|
+
derived = self._derive_cfg_key()
|
|
87
|
+
key = derived[1] if derived else self._get_xor_key(self.templates)
|
|
88
|
+
if key is None: raise ImageUnavailable('这张图片的缓存解密参数尚不可用')
|
|
89
|
+
self._xor_key = key
|
|
90
|
+
return key
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class IncomingImages:
|
|
94
|
+
def __init__(self, database, config, checkProcess):
|
|
95
|
+
self.database, self.config, self.checkProcess = database, config, checkProcess
|
|
96
|
+
self.media = None
|
|
97
|
+
|
|
98
|
+
def read(self, chatId, row):
|
|
99
|
+
if not any(chat['id'] == chatId for chat in self.config['chats']):
|
|
100
|
+
raise ValueError('图片必须来自已配置的聊天')
|
|
101
|
+
self.checkProcess()
|
|
102
|
+
if self.media is None: self.media = ScopedMedia(self.database, self.checkProcess)
|
|
103
|
+
raw = self.database.get_message_row(chatId, row['local_id'], local_type=3, shard=row['shard'])
|
|
104
|
+
if not raw or raw.get('local_type') != 3 or raw.get('sender_username') != row.get('sender_username'):
|
|
105
|
+
raise ImageUnavailable('图片的消息来源无法核对')
|
|
106
|
+
digest = self.media._img_md5(raw)
|
|
107
|
+
if not digest: raise ImageUnavailable('图片缺少有效缓存标识')
|
|
108
|
+
files = self.media._image_files(chatId, digest)
|
|
109
|
+
tier = next((tier for tier in ('original', 'mid', 'thumb') if tier in files and
|
|
110
|
+
(self.media.original_ready(files[tier][1]) if tier == 'original' else files[tier][1] > 0)), None)
|
|
111
|
+
if not tier: raise ImageUnavailable('图片尚未下载到这台电脑')
|
|
112
|
+
path = Path(files[tier][0]).resolve()
|
|
113
|
+
allowed = Path(self.database.account_dir).resolve() / 'msg' / 'attach' / self.media._chat_md5(chatId)
|
|
114
|
+
if not path.is_relative_to(allowed): raise ValueError('图片缓存越过当前聊天目录')
|
|
115
|
+
if path.stat().st_size > MAX_IMAGE_BYTES: raise ImageUnavailable('微信图片缓存超过当前大小限制')
|
|
116
|
+
self.media.probeFile = path
|
|
117
|
+
self.media._key_probe = None
|
|
118
|
+
self.media.templates = [entry[0] for kind, entry in files.items() if kind in ('thumb', tier)]
|
|
119
|
+
stamp = fileStamp(path)
|
|
120
|
+
with path.open('rb') as stream: header = stream.read(15)
|
|
121
|
+
xorKey = None
|
|
122
|
+
aesKey = None
|
|
123
|
+
if header.startswith(V2_MAGIC):
|
|
124
|
+
if len(header) < 15: raise ImageUnavailable('图片加密缓存尚未写完整')
|
|
125
|
+
aesSize, xorSize = struct.unpack_from('<LL', header, 6)
|
|
126
|
+
if 15 + aligned_aes_block_size(aesSize) + xorSize > stamp[1]:
|
|
127
|
+
raise ImageUnavailable('图片加密缓存尚未写完整')
|
|
128
|
+
xorKey = 0 if xorSize == 0 else None
|
|
129
|
+
aesKey = self.media._resolve_aes_key()
|
|
130
|
+
if not aesKey: raise ImageUnavailable('当前登录进程尚未提供有效图片解密密钥')
|
|
131
|
+
target = Path(self.config['moduleFile']).parent / 'wechat-incoming'
|
|
132
|
+
scratch = target / '.decoded' / self.media._chat_md5(chatId)
|
|
133
|
+
result = self.media.download_image(chatId, row['local_id'], save_dir=str(scratch), aes_key=aesKey, xor_key=xorKey, tier=tier, shard=row['shard'])
|
|
134
|
+
self.checkProcess()
|
|
135
|
+
if stamp != fileStamp(path): raise SnapshotBusy('读取期间图片缓存变化,稍后重读')
|
|
136
|
+
if not result: raise ImageUnavailable('图片缓存尚不可用')
|
|
137
|
+
return saveImage(result, target, self.config['selfId'], chatId, {'original': 'original', 'mid': 'cached', 'thumb': 'thumbnail'}[tier])
|
|
138
|
+
|
|
139
|
+
def readSticker(self, chatId, row):
|
|
140
|
+
if not any(chat['id'] == chatId for chat in self.config['chats']):
|
|
141
|
+
raise ValueError('表情包必须来自已配置的聊天')
|
|
142
|
+
if not self.config.get('fetchStickers', True): raise ImageUnavailable('未开启表情包下载')
|
|
143
|
+
self.checkProcess()
|
|
144
|
+
raw = self.database.get_message_row(chatId, row['local_id'], shard=row['shard'])
|
|
145
|
+
if not raw or raw.get('sender_username') != row.get('sender_username'):
|
|
146
|
+
raise ImageUnavailable('表情包的消息来源无法核对')
|
|
147
|
+
try: data = fetchSticker(raw['content'])
|
|
148
|
+
except StickerUnavailable as error: raise ImageUnavailable(str(error)) from error
|
|
149
|
+
self.checkProcess()
|
|
150
|
+
target = Path(self.config['moduleFile']).parent / 'wechat-incoming'
|
|
151
|
+
scratch = target / '.decoded'
|
|
152
|
+
scratch.mkdir(parents=True, exist_ok=True)
|
|
153
|
+
with tempfile.NamedTemporaryFile(dir=scratch, suffix='.sticker', delete=False) as stream:
|
|
154
|
+
path = Path(stream.name)
|
|
155
|
+
stream.write(data)
|
|
156
|
+
try: return saveImage(path, target, self.config['selfId'], chatId, 'original')
|
|
157
|
+
finally: path.unlink(missing_ok=True)
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""Account-scoped use of the pinned dependency; no automatic account selection."""
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import time
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from snapshot import SnapshotBusy, checkedSnapshot, fileStamp
|
|
7
|
+
from binding import findAccountProcess, checkAccountProcess, WechatOffline
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def connect(config, stateDir):
|
|
11
|
+
import psutil
|
|
12
|
+
from wechatauto.db import WeChatDB
|
|
13
|
+
from wechatauto.param import WxParam
|
|
14
|
+
WxParam.ENABLE_FILE_LOGGER = False
|
|
15
|
+
|
|
16
|
+
root = Path(config['dbDir']).resolve()
|
|
17
|
+
account = config['account']
|
|
18
|
+
process = findAccountProcess(config)
|
|
19
|
+
config = {**config, 'processId': process.pid}
|
|
20
|
+
started = process.create_time()
|
|
21
|
+
|
|
22
|
+
def checkProcess():
|
|
23
|
+
try:
|
|
24
|
+
checkAccountProcess(psutil.Process(config['processId']), config, started)
|
|
25
|
+
except (psutil.NoSuchProcess, psutil.ZombieProcess) as error:
|
|
26
|
+
raise WechatOffline('原微信进程已退出') from error
|
|
27
|
+
|
|
28
|
+
checkProcess()
|
|
29
|
+
|
|
30
|
+
class ScopedDatabase(WeChatDB):
|
|
31
|
+
def _open_unlocked(self, rel):
|
|
32
|
+
checkProcess()
|
|
33
|
+
try:
|
|
34
|
+
return checkedSnapshot(self, rel, super()._open_unlocked)
|
|
35
|
+
except Exception:
|
|
36
|
+
checkProcess()
|
|
37
|
+
raise
|
|
38
|
+
|
|
39
|
+
def _warn_once(self, key, message, *args):
|
|
40
|
+
if key[0] == 'shard':
|
|
41
|
+
raise RuntimeError('消息分片读取不完整,停止且不推进消息位置')
|
|
42
|
+
return super()._warn_once(key, message, *args)
|
|
43
|
+
|
|
44
|
+
def _refresh_db_files(self):
|
|
45
|
+
list((Path(self.account_dir) / 'db_storage' / 'message').iterdir())
|
|
46
|
+
super()._refresh_db_files()
|
|
47
|
+
if self.unkeyed:
|
|
48
|
+
raise RuntimeError('新增数据库密钥不完整,请重新绑定')
|
|
49
|
+
|
|
50
|
+
def get_messages(self, user, limit=20, offset=0):
|
|
51
|
+
checkProcess()
|
|
52
|
+
def versions():
|
|
53
|
+
return [(rel, fileStamp(self._db_path(rel)), fileStamp(wal) if (wal := self._wal_path(rel)) else None)
|
|
54
|
+
for rel in self._message_dbs()]
|
|
55
|
+
try:
|
|
56
|
+
before = versions()
|
|
57
|
+
rows = super().get_messages(user, limit, offset)
|
|
58
|
+
if not before or before != versions():
|
|
59
|
+
raise SnapshotBusy('读取期间消息分片发生变化,本轮不推进消息位置')
|
|
60
|
+
return rows
|
|
61
|
+
except Exception:
|
|
62
|
+
checkProcess()
|
|
63
|
+
raise
|
|
64
|
+
|
|
65
|
+
def _auto_diagnose_key_failure(self, rel):
|
|
66
|
+
raise RuntimeError('她的账号数据库密钥校验失败,请重新绑定;不扫描其他账号')
|
|
67
|
+
|
|
68
|
+
def _collect_db_files(self):
|
|
69
|
+
return [(rel, path, size) for rel, path, size in super()._collect_db_files()
|
|
70
|
+
if rel.replace('\\', '/').startswith(('contact/', 'message/', 'session/'))]
|
|
71
|
+
|
|
72
|
+
def _find_weixin_pids(self):
|
|
73
|
+
checkProcess()
|
|
74
|
+
return [config['processId']]
|
|
75
|
+
|
|
76
|
+
def _load_or_extract_keys(self, master_key=None):
|
|
77
|
+
self.master_key = self.cfg_dword = None
|
|
78
|
+
path = Path(self.keys_file)
|
|
79
|
+
if path.is_file():
|
|
80
|
+
self._keys = {name: bytes.fromhex(value) for name, value in json.loads(path.read_text(encoding='utf-8')).items()}
|
|
81
|
+
self._keys = {name: key for name, key in self._keys.items() if self._key_works(name)}
|
|
82
|
+
if any(not self._key_works(name) for name, _, _ in self._db_files):
|
|
83
|
+
self._keys.update(self.extract_keys())
|
|
84
|
+
missing = [name for name, _, _ in self._db_files if not self._key_works(name)]
|
|
85
|
+
self.unkeyed = missing
|
|
86
|
+
if missing:
|
|
87
|
+
raise RuntimeError('她的账号数据库密钥不完整;不改选其他账号')
|
|
88
|
+
self._save_keys()
|
|
89
|
+
|
|
90
|
+
def _save_keys(self):
|
|
91
|
+
if not self._keys:
|
|
92
|
+
return
|
|
93
|
+
path = Path(self.keys_file)
|
|
94
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
95
|
+
temporary = path.with_suffix('.tmp')
|
|
96
|
+
with temporary.open('w', encoding='utf-8') as stream:
|
|
97
|
+
json.dump({name: key.hex() for name, key in self._keys.items()}, stream)
|
|
98
|
+
stream.flush()
|
|
99
|
+
os.fsync(stream.fileno())
|
|
100
|
+
os.replace(temporary, path)
|
|
101
|
+
|
|
102
|
+
try:
|
|
103
|
+
database = ScopedDatabase(db_dir=str(root), account=account, workdir=str(stateDir / 'decrypted'), keys_file=str(stateDir / 'keys.json'))
|
|
104
|
+
except Exception:
|
|
105
|
+
checkProcess()
|
|
106
|
+
raise
|
|
107
|
+
if database.account != account or database.wxid != config['selfId']:
|
|
108
|
+
raise RuntimeError('账号标识与配置不符')
|
|
109
|
+
from incoming import IncomingImages
|
|
110
|
+
images = IncomingImages(database, config, checkProcess)
|
|
111
|
+
database.readImage = images.read
|
|
112
|
+
database.readSticker = images.readSticker
|
|
113
|
+
|
|
114
|
+
sender = None
|
|
115
|
+
def getSender():
|
|
116
|
+
nonlocal sender
|
|
117
|
+
if sender is None:
|
|
118
|
+
from sender import NativeSender
|
|
119
|
+
sender = NativeSender(config, checkProcess)
|
|
120
|
+
return sender
|
|
121
|
+
|
|
122
|
+
def close():
|
|
123
|
+
nonlocal sender
|
|
124
|
+
if sender is not None:
|
|
125
|
+
sender.close()
|
|
126
|
+
sender = None
|
|
127
|
+
|
|
128
|
+
def send(chat, item):
|
|
129
|
+
import hashlib
|
|
130
|
+
from outgoing import mediaDigestMatches, serverConfirmed
|
|
131
|
+
checkProcess()
|
|
132
|
+
item = dict(type='text', text=item) if isinstance(item, str) else item
|
|
133
|
+
kind = {'text': 1, 'image': 2, 'sticker': 3}[item['type']]
|
|
134
|
+
value = item['text'] if kind == 1 else item['path']
|
|
135
|
+
def stableRows(deadline):
|
|
136
|
+
while time.monotonic() < deadline:
|
|
137
|
+
try:
|
|
138
|
+
return database.get_messages(chat['id'], limit=50)
|
|
139
|
+
except SnapshotBusy:
|
|
140
|
+
time.sleep(0.2)
|
|
141
|
+
raise RuntimeError('未能获取稳定的目标聊天快照,请人工核对本次发送')
|
|
142
|
+
before = {(row['shard'], row['local_id']) for row in stableRows(time.monotonic() + 20)}
|
|
143
|
+
getSender().send(chat['id'], kind, value)
|
|
144
|
+
digest = None
|
|
145
|
+
if kind != 1:
|
|
146
|
+
with open(value, 'rb') as stream:
|
|
147
|
+
digest = hashlib.file_digest(stream, 'md5').hexdigest()
|
|
148
|
+
deadline = time.monotonic() + 20
|
|
149
|
+
while time.monotonic() < deadline:
|
|
150
|
+
checkProcess()
|
|
151
|
+
rows = stableRows(deadline)
|
|
152
|
+
for row in rows:
|
|
153
|
+
if (row['shard'], row['local_id']) in before or row.get('sender_username') != config['selfId']:
|
|
154
|
+
continue
|
|
155
|
+
if row['type'] != {1: '文本', 2: '图片', 3: '动画表情'}[kind]:
|
|
156
|
+
continue
|
|
157
|
+
raw = database.get_message_row(chat['id'], row['local_id'], shard=row['shard'])
|
|
158
|
+
if raw is None or not serverConfirmed(raw):
|
|
159
|
+
continue
|
|
160
|
+
if (kind == 1 and str(row['content']) == value) or (kind != 1 and mediaDigestMatches(row, digest, raw)):
|
|
161
|
+
return
|
|
162
|
+
time.sleep(0.5)
|
|
163
|
+
raise RuntimeError('原生操作已提交但目标聊天尚未确认,需人工核对;不自动重发')
|
|
164
|
+
|
|
165
|
+
send.probe = lambda: getSender().send(config['chats'][0]['id'], 0)
|
|
166
|
+
send.close = close
|
|
167
|
+
send.processId = config['processId']
|
|
168
|
+
return database, send
|