dsh-fish-soul 0.19.26 → 0.19.28
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/README.md +1 -1
- package/lib/channels/douyin-pure.js +40 -9
- package/lib/client.diag.js +13 -8
- package/lib/client.js +445 -21
- package/lib/client.models.js +10 -8
- package/lib/client.persona.js +2 -2
- package/lib/client.scheduled-tasks.js +2 -1
- package/lib/client.soul.js +30 -20
- package/lib/panel.css +288 -144
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -43,7 +43,11 @@ export function messageFingerprint(m) {
|
|
|
43
43
|
const i = src.indexOf('/obj/');
|
|
44
44
|
src = (i >= 0 ? src.slice(i) : src).split('?')[0].slice(-60);
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
// 🔴 表情名是**派生信息**,不是身份:`resolveEmojiNames` 在表情面板打不开时第一轮拿不到名字,
|
|
47
|
+
// 下一轮补上 —— 名字一进指纹,同一条表情就换一个 ID,照样重复入库(#286 真机报的就是表情)。
|
|
48
|
+
// 所以只在 src 为空(没有本体)时才拿名字当兜底身份。
|
|
49
|
+
const nameKey = src === '' ? String(media.name ?? '') : '';
|
|
50
|
+
return sha1([m?.fromMe ? 'me' : 'peer', String(m?.text ?? '').trim().slice(0, 120), m?.type ?? '', src, nameKey, m?.shareAweme ?? ''].join('|')).slice(0, 16);
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
/**
|
|
@@ -106,6 +110,16 @@ export function occurrenceIndexes(prints) {
|
|
|
106
110
|
});
|
|
107
111
|
}
|
|
108
112
|
|
|
113
|
+
/**
|
|
114
|
+
* 媒体消息(图片 / 表情 / 视频)有没有能当稳定键的源(data: 本体或图片地址)。
|
|
115
|
+
* 文本 / 分享卡片 / 没抓到源的媒体返回 false —— 那些走时间或卡片自己的路。
|
|
116
|
+
*/
|
|
117
|
+
export function hasStableMediaSource(m) {
|
|
118
|
+
const t = String(m?.type ?? '').trim();
|
|
119
|
+
if (t !== 'image' && t !== 'emoji' && t !== 'video') return false;
|
|
120
|
+
return String(m?.media?.data || m?.media?.src || '') !== '';
|
|
121
|
+
}
|
|
122
|
+
|
|
109
123
|
/**
|
|
110
124
|
* 一条入站消息的「时间 + 去重 ID」。
|
|
111
125
|
*
|
|
@@ -115,13 +129,25 @@ export function occurrenceIndexes(prints) {
|
|
|
115
129
|
* · **同一条消息重复读** ⇒ 同一个 ID(否则每次轮询都新入库一遍,重复回复 + 烧 token)
|
|
116
130
|
* · **同一个人后来又说了同样的话 / 又发了同一张图** ⇒ 不同的 ID(否则第二句被吞,等于失联)
|
|
117
131
|
*
|
|
118
|
-
*
|
|
132
|
+
* 所以分级,越靠前越准:
|
|
119
133
|
* ① 有 `seq`(接口路,平台序号) → `s<seq>`
|
|
120
|
-
* ②
|
|
121
|
-
* ③
|
|
134
|
+
* ② 分享卡片有作品 ID(跨轮询稳定、跨卡片唯一) → `c<作品ID>-<occ>`
|
|
135
|
+
* ③ 媒体消息有源(图片/表情/视频,指纹里已含归一化后的源) → `<指纹>-<occ>`
|
|
136
|
+
* ④ 有平台时间(接口路本来有;DOM 路现在从气泡文字反解) → `<指纹>-<timeMs>-<occ>`
|
|
137
|
+
* ⑤ 两者都没有(极少) → `<指纹>-<自然日>-<occ>`
|
|
138
|
+
*
|
|
139
|
+
* ⚠️ ③ 为什么媒体 ID 不能掺时间:DOM 路的「时间」是从气泡上「刚刚 / N 分钟前」反解的,
|
|
140
|
+
* 而「刚刚」那一档返回的是**当前时刻**,每轮询一次就变一个值(#286 真机:同一张表情
|
|
141
|
+
* 入库 8 次、每行 ID 里的时间戳都差几秒)。指纹里的媒体源(data: 本体 hash / URL 截
|
|
142
|
+
* `/obj/` 后去掉签名参数)跨轮询逐字节稳定,所以用「指纹-occ」当身份。
|
|
143
|
+
*
|
|
144
|
+
* `occ`(同指纹在**本次读到的列表**里第几次出现)在这里是安全的:正常轮询下
|
|
145
|
+
* `newFrom` 只把真正的新消息放进 fresh,同一条消息的 `occ` 就是确定的。
|
|
146
|
+
* 窗口整个对不齐时(中间来了 20+ 条)`occ` 可能变,代价是**重复入库一次**,
|
|
147
|
+
* 而不是漏收 —— 而且那条路本来就会记 gap 提示给用户。
|
|
148
|
+
* 「重复只是烦,漏回是失联」是这里的取舍依据。
|
|
122
149
|
*
|
|
123
|
-
*
|
|
124
|
-
* 别为了省事把 ② 也降级到 ③ —— 那会让「同一天说两次『在』」第二句收不到。
|
|
150
|
+
* ⚠️ ④→⑤ 别降级:那会让「同一天说两次『在』」第二句收不到。
|
|
125
151
|
*
|
|
126
152
|
* @param {object} m 入站消息(可能带 `time` / `seq`)
|
|
127
153
|
* @param {{occ?: number, fallbackTime?: number, dayKey?: string}} ctx
|
|
@@ -138,13 +164,18 @@ export function messageIdFor(m, { occ = 0, fallbackTime = Date.now(), dayKey = '
|
|
|
138
164
|
// 拿它当 ID 等于 UNIQUE(channel_id, message_id) 完全失效(真机:一张卡入库 13 次、回了 13 遍)。
|
|
139
165
|
// 作品 ID 跨轮询稳定、跨卡片唯一,比 seq 还准(DOM 路本来就没有 seq)。
|
|
140
166
|
const card = String(m?.shareAweme ?? '').trim();
|
|
167
|
+
// 媒体同病同修(#286):没 seq 的图片 / 表情走的也是反解时间,同一张表情入库 8 次。
|
|
168
|
+
// 指纹里的媒体源(data: 本体 hash / URL 去签名参数)跨轮询稳定 ⇒ 用「指纹-occ」,时间不进 ID。
|
|
169
|
+
const media = card === '' && seq === '' && hasStableMediaSource(m);
|
|
141
170
|
const messageId = card !== ''
|
|
142
171
|
? `c${card}-${occ}`
|
|
143
172
|
: seq !== ''
|
|
144
173
|
? `s${seq}`
|
|
145
|
-
:
|
|
146
|
-
? `${print}-${
|
|
147
|
-
:
|
|
174
|
+
: media
|
|
175
|
+
? `${print}-${occ}`
|
|
176
|
+
: hasTime
|
|
177
|
+
? `${print}-${timeMs}-${occ}`
|
|
178
|
+
: `${print}-${day}-${occ}`;
|
|
148
179
|
return { timeMs, messageId };
|
|
149
180
|
}
|
|
150
181
|
|
package/lib/client.diag.js
CHANGED
|
@@ -46,15 +46,17 @@ window.__ModuleLoader__.load({
|
|
|
46
46
|
const [level, setLevel] = react.useState("all");
|
|
47
47
|
const [data, load, err] = usePoll(api, "/diag-log", 15000);
|
|
48
48
|
const [confirm, confirmNode] = useConfirm();
|
|
49
|
+
const entries = data?.entries ?? [];
|
|
50
|
+
const shownEntries = level === "all" ? entries : entries.filter((e) => e.level === level);
|
|
51
|
+
const diagFlipKey = shownEntries.map((e, i) => `${e.at}-${e.key ?? i}`).join(",");
|
|
52
|
+
const diagListRef = typeof ui.useFlipList === "function" ? ui.useFlipList(diagFlipKey) : undefined;
|
|
49
53
|
if (!data) {
|
|
50
54
|
if (err) return h("div", { className: "fs-notice", role: "alert" }, h("b", null, "运行日志读取失败"), h("span", null, err), Button({ onClick: load }, "重试"));
|
|
51
55
|
return h("div", { className: "fs-empty" }, "加载中…");
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
const entries = data.entries ?? [];
|
|
55
58
|
const warnCount = entries.filter((e) => e.level === "warn").length;
|
|
56
59
|
const errCount = entries.filter((e) => e.level === "error").length;
|
|
57
|
-
const shownEntries = level === "all" ? entries : entries.filter((e) => e.level === level);
|
|
58
60
|
const pad = (n) => String(n).padStart(2, "0");
|
|
59
61
|
const fmtTime = (ms) => {
|
|
60
62
|
const d = new Date(ms);
|
|
@@ -106,12 +108,15 @@ window.__ModuleLoader__.load({
|
|
|
106
108
|
h("button", { type: "button", className: "fs-pill", "aria-pressed": level === "error", onClick: () => setLevel("error") }, `错误 ${errCount}`)),
|
|
107
109
|
shownEntries.length === 0
|
|
108
110
|
? h("div", { className: "fs-empty" }, "这个级别下没有日志。")
|
|
109
|
-
: h("div", { className: "fs-diag-list" },
|
|
110
|
-
shownEntries.map((e, i) =>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
: h("div", { className: "fs-diag-list", ref: diagListRef },
|
|
112
|
+
shownEntries.map((e, i) => {
|
|
113
|
+
const flipKey = `${e.at}-${e.key ?? i}`;
|
|
114
|
+
return h("div", { key: flipKey, "data-flip-key": flipKey, className: "fs-diag-row", "data-level": e.level },
|
|
115
|
+
h("span", { className: "fs-diag-time" }, fmtTime(e.at)),
|
|
116
|
+
e.level === "error" ? Tag("错误", "danger") : e.level === "warn" ? Tag("警告", "warning") : null,
|
|
117
|
+
h("span", { className: "fs-diag-label", "data-level": e.level }, e.label),
|
|
118
|
+
h("span", { className: "fs-diag-detail" }, describe(e)));
|
|
119
|
+
}))),
|
|
115
120
|
confirmNode);
|
|
116
121
|
}
|
|
117
122
|
|