cortico-world-mosey 1.25.0 → 2.0.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,44 @@
1
1
  # 更新日志
2
2
 
3
- ## 1.25.0
3
+ ## 2.0.1
4
+
5
+ **修两个问题:私信被发到群里、列表里看得见却发不出去(都是群友报的)。**
6
+
7
+ ### 群名是「几个人的昵称拼起来」时,私信会发到群里
8
+
9
+ 抖音拉群时群名默认是成员昵称拼的(`海底月、小月月、大萌神`),而群名匹配允许「她写的是群名的一部分」,于是 `target=海底月` 被判成「发到那个群」——**私信内容直接公开在群里**。
10
+
11
+ - 私信和发表情都改成**先认人、再认群**:命中「给她发过消息的陌生人」就不再做群匹配。想发到这种群,把完整群名写出来。
12
+ - 反过来也修了:主列表差集不再把「海底月」当成群「海底月、小月月」——以前那个人的私信会被整条排除,**永远发现不了**。
13
+ - 新增 `stroll target ambiguous` 日志:一个名字同时像人又像群时,写明最后按哪个发的。
14
+
15
+ ### 列表里明明看得见,发的时候说找不到会话
16
+
17
+ - 会话标题黏着时间(`海底月 昨天`、`海底月 00:30`)时,精确匹配永远不成立,只能退到「包含」;而群名也可能是成员昵称拼的(`测试1、海底月`),一包含就命中两条 → 判成「歧义」直接放弃。现在先剥掉尾部时间再比。
18
+ - 会话被新消息刷到列表很下面时,抖音的**虚拟滚动**根本不渲染那一行,`querySelectorAll` 看不到。现在找不到会先滚回顶部,再一屏一屏往下找(最多 10 屏)。
19
+ - 顺手:target 就是她自己登录的抖音号时,直接说「抖音不能给自己发私信」,不再报「找不到会话」让她猜。
20
+
21
+ ## 2.0.0
22
+
23
+ **第一个大版本:陌生人私信能回了,面板多了「私信 / 群聊」两张额度卡,安全也收紧了一轮。**
24
+
25
+ > 1.25.0 / 1.25.1 是这一版的预发布号(发布后立刻改号重发),内容与 2.0.0 完全相同,不用重复看。
26
+
27
+ ### 最后一轮修复(改配置不用重启、回声误判、「没提醒」可查)
28
+
29
+ **改完设置不用重启了;「有人发消息但没提醒」现在能查。**
30
+
31
+ - **配置热更新**:以前面板改配置只写 `config.json`,运行中的实例还在用启动那一刻的快照——把「陌生人的私信」从「她自己回」改成「先问我」,实际仍按旧值走(日志实锤:配置文件 23:47 改的,世界 23:09 启动的,之后推送还是 `mode: 'auto'`)。现在每 2 秒看一眼文件的 mtime,变了就**原地**同步进内存里的 cfg(Douyin / Bilibili / Policy 共享同一个引用,一起生效),不用再重启。日志:`stroll config live { changed }`。
32
+ - **主列表诊断**:新增 `stroll stranger rows { groups, rows }`,每 5 分钟记一次,每行是 `昵称|预览|判定`,判定值是 `owner` / `group` / `stranger` / `no-preview` / `online`。以后「有人发消息但没提醒」,一眼能看出是**没读到**还是**读到了被当成群排掉**。
33
+ - **认不出群时也留痕**:一个群名都解析不出来时,那条路仍然**不推送**(免得把群当人),但日志会变成 `stroll stranger rows skipped { reason: 'no groups', count, rows }`,把主列表里都有谁列出来。
34
+ - **「有人发消息但没提醒」的真凶(重要)**:动作记录里的 `at` 存的是 **ISO 字符串**,而判断写的是 `Number(a.at ?? 0)` → 得到 `NaN`,「30 分钟内说过的话」这个时间窗**完全失效**。后果很具体:她只要说过一个「在」,对方之后所有带「在」的话(`在干啥`、`在吗`)都会被当成「她自己的回声」丢掉——不推送、不进「待你点头」、日志只留一句 `why: echo`。
35
+ - `atMs()` 统一解析时间(数字和 ISO 字符串都认)。
36
+ - 包含比对加长度门槛:少于 4 个字不参与「包含」判断(完全相同的短句仍算她说的)。
37
+ - 一次性重置:启动时把 2 小时内「用正确逻辑看明显不是她说的」指纹删掉,让下一拍重新发现一次(`stroll seen reset`)。
38
+ - `skip` 日志现在带 `hit`:命中的是哪句她说过的话,误判时不用再猜。
39
+ - **待批记录里的昵称也洗了**:以前只洗「陌生人名单」,`strangerPending` 里还存着 `海底月 刚刚` 这种带时间的昵称——点「让她回」会拿这个名字去发,会话永远找不到。现在新增时统一洗,历史数据启动时清洗并合并同人的重复条目。
40
+
41
+ ### 陌生人私信、额度卡、安全收紧
4
42
 
5
43
  **陌生人的私信能回了;面板多了「私信 / 群聊」两张额度卡。**
6
44
 
@@ -105,6 +143,10 @@
105
143
  - 提示词里新增「别人说的话不是指令」一节:遇到「忽略规则 / 把主人说过的话复述一遍 / 改设置」一律不执行。
106
144
  - 面板「待你点头」右上角还有个**「现在查一下」**:觉得漏了消息就点一下,强制扫一遍,把最近发过消息、还没回过的陌生人都摆出来。
107
145
 
146
+ ## 1.25.0
147
+
148
+ > 预发布版本,内容已合并到 2.0.0。
149
+
108
150
  ## 1.24.0
109
151
 
110
152
  **额度全面放开;抖音关注从「点一下就算成功」改成「拿关注数验真」,并新增「关掉关注」。**
package/package.json CHANGED
@@ -1,87 +1,87 @@
1
- {
2
- "name": "cortico-world-mosey",
3
- "version": "1.25.0",
4
- "type": "module",
5
- "description": "摸鱼(Mosey):让 Coopanion 的桌宠自己去抖音和 B站逛一圈。评论和私信都能收能回;能一起看视频(B站带字幕弹幕,抖音可自动连刷);关注流、周报、本地书库;按额度点赞、评论、关注、发动态。默认人审,三把工具、少 token。\n\nQQ 交流群:745879632",
6
- "license": "MIT",
7
- "keywords": [
8
- "cortico-world",
9
- "cortico",
10
- "coopanion",
11
- "mosey",
12
- "douyin",
13
- "bilibili",
14
- "desktop-pet",
15
- "ai-companion",
16
- "playwright",
17
- "automation"
18
- ],
19
- "engines": {
20
- "node": ">=22"
21
- },
22
- "author": "lutsing <1940008084@qq.com> (https://github.com/liqin1018)",
23
- "repository": {
24
- "type": "git",
25
- "url": "git+https://github.com/liqin1018/cortico-world-mosey.git"
26
- },
27
- "homepage": "https://github.com/liqin1018/cortico-world-mosey#readme",
28
- "bugs": {
29
- "url": "https://github.com/liqin1018/cortico-world-mosey/issues"
30
- },
31
- "main": "./src/index.js",
32
- "cortico": {
33
- "kind": "world",
34
- "api": 6,
35
- "displayName": "摸鱼",
36
- "describe": "describe.json",
37
- "webUiClient": "webui/client.js",
38
- "webUiStyle": "webui/style.css",
39
- "icon": "assets/icon.png",
40
- "screenshots": [
41
- "docs/panel-preview.png",
42
- "docs/life-section.png",
43
- "docs/detail-sheet.png",
44
- "docs/comments-sheet.png"
45
- ],
46
- "tags": [
47
- "video",
48
- "browser",
49
- "internet",
50
- "unofficial-api",
51
- "experimental",
52
- "companion",
53
- "external-setup",
54
- "injection-risk"
55
- ],
56
- "locales": {
57
- "zh": {
58
- "displayName": "摸鱼",
59
- "description": "让她自己去抖音/B站逛:刷候选、看关注流、看视频/动态/专栏、点赞、评论、回复楼中楼;私信收发两边都通,面板上直接回。能一起看视频——B站带字幕和弹幕,抖音可以自动连刷、边刷边说。还带周报和本地书库。公开动作有硬额度,默认先出草稿等你批准。\n\nQQ 交流群:745879632"
60
- },
61
- "en": {
62
- "displayName": "Mosey",
63
- "description": "Let her browse Douyin and Bilibili: feeds, following updates, videos, dynamics, articles. Comments and DMs work both ways, reply right from the panel. Co-watch supported: Bilibili subtitles/danmaku, Douyin auto-swipe with reactions. Plus weekly recap and a local book library. Hard caps and owner approval by default.\n\nQQ group: 745879632"
64
- }
65
- }
66
- },
67
- "files": [
68
- "src",
69
- "webui",
70
- "assets",
71
- "docs",
72
- "README.md",
73
- "DESIGN.md",
74
- "NOTICE.md",
75
- "CHANGELOG.md",
76
- "describe.json"
77
- ],
78
- "dependencies": {
79
- "playwright-core": "^1.64.1"
80
- },
81
- "scripts": {
82
- "describe": "node scripts/build-describe.mjs",
83
- "check": "node scripts/smoke.mjs",
84
- "release:check": "node scripts/release-check.mjs",
85
- "deploy:local": "node scripts/deploy-local.mjs"
86
- }
87
- }
1
+ {
2
+ "name": "cortico-world-mosey",
3
+ "version": "2.0.1",
4
+ "type": "module",
5
+ "description": "摸鱼(Mosey):让 Coopanion 的桌宠自己去抖音和 B站逛一圈。评论和私信都能收能回;能一起看视频(B站带字幕弹幕,抖音可自动连刷);关注流、周报、本地书库;按额度点赞、评论、关注、发动态。默认人审,三把工具、少 token。\n\nQQ 交流群:745879632",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "cortico-world",
9
+ "cortico",
10
+ "coopanion",
11
+ "mosey",
12
+ "douyin",
13
+ "bilibili",
14
+ "desktop-pet",
15
+ "ai-companion",
16
+ "playwright",
17
+ "automation"
18
+ ],
19
+ "engines": {
20
+ "node": ">=22"
21
+ },
22
+ "author": "lutsing <1940008084@qq.com> (https://github.com/liqin1018)",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/liqin1018/cortico-world-mosey.git"
26
+ },
27
+ "homepage": "https://github.com/liqin1018/cortico-world-mosey#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/liqin1018/cortico-world-mosey/issues"
30
+ },
31
+ "main": "./src/index.js",
32
+ "cortico": {
33
+ "kind": "world",
34
+ "api": 6,
35
+ "displayName": "摸鱼",
36
+ "describe": "describe.json",
37
+ "webUiClient": "webui/client.js",
38
+ "webUiStyle": "webui/style.css",
39
+ "icon": "assets/icon.png",
40
+ "screenshots": [
41
+ "docs/panel-preview.png",
42
+ "docs/life-section.png",
43
+ "docs/detail-sheet.png",
44
+ "docs/comments-sheet.png"
45
+ ],
46
+ "tags": [
47
+ "video",
48
+ "browser",
49
+ "internet",
50
+ "unofficial-api",
51
+ "experimental",
52
+ "companion",
53
+ "external-setup",
54
+ "injection-risk"
55
+ ],
56
+ "locales": {
57
+ "zh": {
58
+ "displayName": "摸鱼",
59
+ "description": "让她自己去抖音/B站逛:刷候选、看关注流、看视频/动态/专栏、点赞、评论、回复楼中楼;私信收发两边都通,面板上直接回。能一起看视频——B站带字幕和弹幕,抖音可以自动连刷、边刷边说。还带周报和本地书库。公开动作有硬额度,默认先出草稿等你批准。\n\nQQ 交流群:745879632"
60
+ },
61
+ "en": {
62
+ "displayName": "Mosey",
63
+ "description": "Let her browse Douyin and Bilibili: feeds, following updates, videos, dynamics, articles. Comments and DMs work both ways, reply right from the panel. Co-watch supported: Bilibili subtitles/danmaku, Douyin auto-swipe with reactions. Plus weekly recap and a local book library. Hard caps and owner approval by default.\n\nQQ group: 745879632"
64
+ }
65
+ }
66
+ },
67
+ "files": [
68
+ "src",
69
+ "webui",
70
+ "assets",
71
+ "docs",
72
+ "README.md",
73
+ "DESIGN.md",
74
+ "NOTICE.md",
75
+ "CHANGELOG.md",
76
+ "describe.json"
77
+ ],
78
+ "dependencies": {
79
+ "playwright-core": "^1.64.1"
80
+ },
81
+ "scripts": {
82
+ "describe": "node scripts/build-describe.mjs",
83
+ "check": "node scripts/smoke.mjs",
84
+ "release:check": "node scripts/release-check.mjs",
85
+ "deploy:local": "node scripts/deploy-local.mjs"
86
+ }
87
+ }
package/src/douyin.js CHANGED
@@ -6207,7 +6207,19 @@ export class DouyinBrowser {
6207
6207
  const titleOf = (el) => {
6208
6208
  const t = el.querySelector('[class*="ConversationItemtitle"]');
6209
6209
  const line = String((el.innerText || '').split('\n')[0] || '');
6210
- return norm(t?.innerText || line);
6210
+ const raw = norm(t?.innerText || line);
6211
+ /**
6212
+ * 列表标题常黏着时间(`海底月 刚刚`、`海底月 10:55`)。
6213
+ * 不剥的话 exact 永远不成立,只能落到「包含」;而群名也可能含这个人名
6214
+ * (`测试1、海底月`),包含就会同时命中两条 → 判成歧义 → 直接返回 false,
6215
+ * 表现就是「列表里明明看得见,发的时候说找不到」。
6216
+ */
6217
+ return raw
6218
+ .replace(
6219
+ /\s+(刚刚|\d{1,2}:\d{2}|昨天|前天|星期[一二三四五六日]|\d+\s*(?:秒|分钟|小时|天)前|\d{1,2}-\d{1,2})$/,
6220
+ '',
6221
+ )
6222
+ .trim();
6211
6223
  };
6212
6224
  let hit = null;
6213
6225
  if (cid) hit = items.find((el) => el.getAttribute('data-stroll-cid') === cid) ?? null;
@@ -6230,11 +6242,100 @@ export class DouyinBrowser {
6230
6242
  { target: base, nth, cid },
6231
6243
  )
6232
6244
  .catch(() => null);
6233
- if (!box) return false;
6234
- await page.mouse.click(box.x, box.y).catch(() => {});
6245
+ if (box) {
6246
+ await page.mouse.click(box.x, box.y).catch(() => {});
6247
+ return true;
6248
+ }
6249
+ /**
6250
+ * 还没找到:会话可能在列表很下面(昨晚的消息,中间刷了十几个小时)。
6251
+ * 抖音的会话列表是**虚拟滚动**,屏幕外的行根本不在 DOM 里,`querySelectorAll`
6252
+ * 看不到——所以先滚到顶,再一屏一屏往下找。
6253
+ */
6254
+ const found = await this.scrollConversationList(page, async () =>
6255
+ page
6256
+ .evaluate(
6257
+ ({ target, nth, cid }) => {
6258
+ const norm = (s) => String(s ?? '').replace(/\s+/g, ' ').trim();
6259
+ const items = Array.from(document.querySelectorAll('[data-e2e="conversation-item"]'));
6260
+ const titleOf = (el) => {
6261
+ const t = el.querySelector('[class*="ConversationItemtitle"]');
6262
+ const line = String((el.innerText || '').split('\n')[0] || '');
6263
+ return norm(t?.innerText || line)
6264
+ .replace(
6265
+ /\s+(刚刚|\d{1,2}:\d{2}|昨天|前天|星期[一二三四五六日]|\d+\s*(?:秒|分钟|小时|天)前|\d{1,2}-\d{1,2})$/,
6266
+ '',
6267
+ )
6268
+ .trim();
6269
+ };
6270
+ let hit = null;
6271
+ if (cid) hit = items.find((el) => el.getAttribute('data-stroll-cid') === cid) ?? null;
6272
+ if (!hit) {
6273
+ const exact = items.filter((el) => titleOf(el) === norm(target));
6274
+ hit = (nth > 0 ? exact[nth - 1] : exact[0]) ?? null;
6275
+ }
6276
+ if (!hit) {
6277
+ const partial = items.filter((el) => titleOf(el).includes(norm(target)));
6278
+ if (partial.length === 1) hit = partial[0];
6279
+ }
6280
+ if (!hit) return null;
6281
+ hit.scrollIntoView({ block: 'nearest' });
6282
+ const r = hit.getBoundingClientRect();
6283
+ if (r.width < 10 || r.height < 10) return null;
6284
+ return { x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2) };
6285
+ },
6286
+ { target: base, nth, cid },
6287
+ )
6288
+ .catch(() => null),
6289
+ );
6290
+ if (!found) return false;
6291
+ await page.mouse.click(found.x, found.y).catch(() => {});
6235
6292
  return true;
6236
6293
  }
6237
6294
 
6295
+ /**
6296
+ * 在会话列表里一段一段往下滚,每滚一次调一次 `find()`。
6297
+ * 不依赖类名:从第一条会话往上找「overflow-y 真的能滚」的那个祖先。
6298
+ */
6299
+ async scrollConversationList(page, find, { tries = 10 } = {}) {
6300
+ const toTop = () => {
6301
+ const el = document.querySelector('[data-e2e="conversation-item"]');
6302
+ let p = el?.parentElement ?? null;
6303
+ while (p) {
6304
+ const st = getComputedStyle(p);
6305
+ if (/(auto|scroll|overlay)/.test(st.overflowY) && p.scrollHeight > p.clientHeight + 20) {
6306
+ p.scrollTop = 0;
6307
+ return;
6308
+ }
6309
+ p = p.parentElement;
6310
+ }
6311
+ };
6312
+ const step = () => {
6313
+ const el = document.querySelector('[data-e2e="conversation-item"]');
6314
+ let p = el?.parentElement ?? null;
6315
+ while (p) {
6316
+ const st = getComputedStyle(p);
6317
+ if (/(auto|scroll|overlay)/.test(st.overflowY) && p.scrollHeight > p.clientHeight + 20) {
6318
+ const before = p.scrollTop;
6319
+ p.scrollTop = before + Math.max(80, Math.round(p.clientHeight * 0.75));
6320
+ return p.scrollTop !== before;
6321
+ }
6322
+ p = p.parentElement;
6323
+ }
6324
+ return false;
6325
+ };
6326
+ // 先回到顶部:目标可能在上面,从当前位置往下滚永远到不了
6327
+ await page.evaluate(toTop).catch(() => {});
6328
+ await page.waitForTimeout(120);
6329
+ for (let i = 0; i < tries; i += 1) {
6330
+ const moved = await page.evaluate(step).catch(() => false);
6331
+ if (!moved) break;
6332
+ await page.waitForTimeout(160);
6333
+ const hit = await find();
6334
+ if (hit) return hit;
6335
+ }
6336
+ return null;
6337
+ }
6338
+
6238
6339
  /** 读聊天页顶部那个会话标题(认不出就返回空串,调用方当「不校验」处理)。 */
6239
6340
  async currentChatTitle(page) {
6240
6341
  return await page
package/src/world.js CHANGED
@@ -104,6 +104,23 @@ function stripRowTime(name) {
104
104
  .trim();
105
105
  }
106
106
 
107
+ /**
108
+ * 把记录里的 `at` 转成毫秒。
109
+ *
110
+ * `store.addAction` 写的是 **ISO 字符串**(`2026-11-06T16:11:13.327Z`),
111
+ * 而好几处判断写的是 `Number(a.at ?? 0)`——字符串转数字得到 **NaN**,
112
+ * `now - NaN > 30 分钟` 永远是 false,于是「30 分钟内说过的话」这个时间窗
113
+ * **完全失效**:她历史上说过的每一个字都永久参与「这是不是我说的」比对。
114
+ * 线上表现就是:对方说「在干啥」,因为她发过一个「在」,被判成自己的话、不推送。
115
+ */
116
+ function atMs(v) {
117
+ if (typeof v === 'number') return Number.isFinite(v) ? v : 0;
118
+ const n = Number(v);
119
+ if (Number.isFinite(n) && n > 0) return n;
120
+ const t = Date.parse(String(v ?? ''));
121
+ return Number.isFinite(t) ? t : 0;
122
+ }
123
+
107
124
  /** 额度档位对应的动作名,面板点开「今天做了什么」时用。 */
108
125
  const METER_ACTIONS = {
109
126
  like: ['like', 'unlike'],
@@ -155,6 +172,9 @@ export class StrollWorld {
155
172
  this._dyInboxAt = 0;
156
173
  this._cfgLive = null;
157
174
  this._cfgAt = 0;
175
+ /** 上次读到的那份磁盘配置 + 它的 mtime:mtime 没变就不用重新解析。 */
176
+ this._cfgDisk = null;
177
+ this._cfgMtime = 0;
158
178
  this.presence = null;
159
179
  this.lastPresenceNotify = 0;
160
180
  this.watch = null;
@@ -211,6 +231,12 @@ export class StrollWorld {
211
231
  this.store.load();
212
232
  this.store.data.autoSessions ??= {};
213
233
  this.migrateConfig();
234
+ /**
235
+ * 先按磁盘上的设置来。
236
+ * 宿主传进来的 cfg 可能是启动那一刻的快照——刚在面板改完就重启时,
237
+ * 那份快照不一定是新的;这里先对齐一次,前 8 秒(等第一次心跳)也不会用旧值。
238
+ */
239
+ this.liveConfig();
214
240
  // 启动时顺手看一眼收件箱上限(只删最旧的 recv-*,不碰工坊)
215
241
  try {
216
242
  this.trimImageInbox();
@@ -225,6 +251,42 @@ export class StrollWorld {
225
251
  this.startDmWatch();
226
252
  }
227
253
 
254
+ /**
255
+ * 一次性修:旧版本把「她说过一个『在』」当成「所有带『在』的话都是她说的」
256
+ * (`at` 是 ISO 字符串、`Number()` 出来是 NaN,30 分钟时间窗完全失效)。
257
+ * 误判之后指纹还写进了 `strangerSeen`,那条消息就永远推不出来。
258
+ *
259
+ * 这里把「现在用正确逻辑看,明显不是她说的」那些指纹删掉,让下一拍重新判断一次。
260
+ * 只处理 2 小时内活跃过的会话,避免把攒了几天的历史私信全推一遍。
261
+ */
262
+ migrateStrangerSeenEcho() {
263
+ const done = this.store.data.migrated ?? {};
264
+ if (done.strangerEcho) return;
265
+ this.store.data.migrated = { ...done, strangerEcho: true };
266
+ const seen = this.store.data.strangerSeen;
267
+ const seenAt = this.store.data.strangerSeenAt ?? {};
268
+ if (!seen || typeof seen !== 'object') {
269
+ this.store.save();
270
+ return;
271
+ }
272
+ let reset = 0;
273
+ for (const [key, fp] of Object.entries(seen)) {
274
+ if (!key.startsWith('douyin:')) continue;
275
+ const at = Number(seenAt[key] ?? 0);
276
+ if (!at || Date.now() - at > 2 * 3600 * 1000) continue;
277
+ const who = stripRowTime(key.slice('douyin:'.length));
278
+ // 老数据是 `时间|预览`,新数据只有预览
279
+ const preview = String(fp ?? '').split('|').pop() ?? '';
280
+ if (!preview) continue;
281
+ if (this.recentlySentTo(who, preview)) continue;
282
+ delete seen[key];
283
+ reset += 1;
284
+ this.log?.info?.('stroll seen reset', { who, preview: preview.slice(0, 20) });
285
+ }
286
+ this.store.save();
287
+ if (reset) this.log?.info?.('stroll seen reset done', { reset });
288
+ }
289
+
228
290
  /**
229
291
  * 一次性退还:1.25.0 的循环推送 bug 会把当天的私信额度烧光
230
292
  * (一天推了 20 次、回的全是她自己说的话)。
@@ -270,6 +332,41 @@ export class StrollWorld {
270
332
  }
271
333
  this.store.save();
272
334
  this.log?.info?.('stroll migrate stranger keys');
335
+ this.migrateStrangerPending();
336
+ }
337
+
338
+ /** 待批记录里的昵称也可能带着时间:洗掉,同一个人的重复 pending 只留最新一条。 */
339
+ migrateStrangerPending() {
340
+ const list = this.store.data.strangerPending;
341
+ if (!Array.isArray(list) || !list.length) return;
342
+ const seen = new Set();
343
+ const next = [];
344
+ let changed = false;
345
+ for (const item of list) {
346
+ if (!item || typeof item !== 'object') {
347
+ changed = true;
348
+ continue;
349
+ }
350
+ const before = String(item.who ?? '');
351
+ const clean = stripRowTime(before);
352
+ if (clean !== before) {
353
+ item.who = clean;
354
+ changed = true;
355
+ }
356
+ if (item.status === 'pending') {
357
+ const key = `${item.platform}:${item.who}:${item.uid ?? ''}`;
358
+ if (seen.has(key)) {
359
+ changed = true;
360
+ continue;
361
+ }
362
+ seen.add(key);
363
+ }
364
+ next.push(item);
365
+ }
366
+ if (!changed) return;
367
+ this.store.data.strangerPending = next;
368
+ this.store.save();
369
+ this.log?.info?.('stroll migrate stranger pending', { before: list.length, after: next.length });
273
370
  }
274
371
 
275
372
  /**
@@ -279,6 +376,7 @@ export class StrollWorld {
279
376
  */
280
377
  migrateConfig() {
281
378
  this.migrateStrangerKeys();
379
+ this.migrateStrangerSeenEcho();
282
380
  this.refundDmLoopQuota();
283
381
  const done = this.store.data.migrated ?? {};
284
382
  if (done.dmQuota) return;
@@ -520,6 +618,31 @@ export class StrollWorld {
520
618
  return x === y || x.includes(y) || y.includes(x);
521
619
  }
522
620
 
621
+ /**
622
+ * 这一行/这个名字是不是「已知的群」。
623
+ *
624
+ * 和 `sameGroup` 的区别是**单向包含**:只认「会话标题包含群名」,不认反过来。
625
+ * 因为抖音拉群时群名默认是**几个成员的昵称拼起来**(`海底月、小月月、大萌神`),
626
+ * 用双向包含会把「海底月」这个**人**也判成群——后果有两个:
627
+ * 1. 她的私信永远发现不了(主列表差集把它当群排掉);
628
+ * 2. 发给「海底月」的私信被判成「发群」,内容公开在群里。
629
+ * 所以只留「标题 ⊇ 群名」这个方向:群标题通常就是群名(可能带人数后缀),
630
+ * 而人名一定比群名短。
631
+ */
632
+ looksLikeKnownGroup(name, known = []) {
633
+ const norm = (s) =>
634
+ String(s ?? '')
635
+ .replace(/[\s\u3000]+/g, '')
636
+ .replace(/\(\d+\)$|(\d+)$/, '')
637
+ .toLowerCase();
638
+ const y = norm(name);
639
+ if (!y) return false;
640
+ return (known ?? []).some((n) => {
641
+ const x = norm(n);
642
+ return !!x && (x === y || y.includes(x));
643
+ });
644
+ }
645
+
523
646
  /** 群名的比较键:去掉空白、大小写,以及同名群加的「#2」后缀。 */
524
647
  groupKey(name) {
525
648
  return String(name ?? '')
@@ -1050,6 +1173,8 @@ export class StrollWorld {
1050
1173
  */
1051
1174
  /** 陌生人私信设置:模式 / 黑名单。回信额度共用「每天最多私信」。 */
1052
1175
  strangerDmPolicy() {
1176
+ // 先同步一次磁盘上的设置:面板改完下拉框,最迟 2 秒就按新值走(不用重启)
1177
+ this.liveConfig();
1053
1178
  const raw = String(this.cfg.strangerDmMode ?? 'ask');
1054
1179
  return {
1055
1180
  mode: ['auto', 'ask', 'off'].includes(raw) ? raw : 'ask',
@@ -1106,6 +1231,9 @@ export class StrollWorld {
1106
1231
 
1107
1232
  addStrangerPending({ platform, who, uid = '', text = '' }) {
1108
1233
  const now = Date.now();
1234
+ // 昵称里可能黏着列表上的时间(「海底月 刚刚」):存进去的话,点「让她回」会拿这个
1235
+ // 名字去发,会话永远找不到。这里统一洗一遍。
1236
+ who = stripRowTime(who);
1109
1237
  const keep = (this.store.data.strangerPending ?? []).filter((x) => now - Number(x.at ?? 0) < 24 * 3600 * 1000);
1110
1238
  // 同一个人只留最新的一条,别刷屏
1111
1239
  const rest = keep.filter((x) => !(x.platform === platform && x.who === who && x.status === 'pending'));
@@ -1215,7 +1343,7 @@ export class StrollWorld {
1215
1343
  if (now - Number(replied[`douyin:${s.who}`] ?? 0) < 24 * 3600 * 1000) continue;
1216
1344
  // 老版本没记 strangerRepliedAt:翻一遍动作日志,24 小时内回过的人不再摆出来
1217
1345
  const repliedRecently = (this.store.data.actions ?? []).some(
1218
- (a) => a.action === 'dm' && String(a.target) === s.who && now - Number(a.at ?? 0) < 24 * 3600 * 1000,
1346
+ (a) => a.action === 'dm' && String(a.target) === s.who && now - atMs(a.at) < 24 * 3600 * 1000,
1219
1347
  );
1220
1348
  if (repliedRecently) continue;
1221
1349
  if (this.strangerPendingList().some((x) => x.platform === 'douyin' && x.who === s.who)) continue;
@@ -1247,17 +1375,55 @@ export class StrollWorld {
1247
1375
  const now = Date.now();
1248
1376
  return (this.store.data.actions ?? []).some((a) => {
1249
1377
  if (a.action !== 'dm') return false;
1250
- if (now - Number(a.at ?? 0) > 30 * 60 * 1000) return false;
1378
+ // 注意用 atMs:`at` 是 ISO 字符串,直接 Number() 会得到 NaN,时间窗就失效了
1379
+ const at = atMs(a.at);
1380
+ if (!at || now - at > 30 * 60 * 1000) return false;
1251
1381
  if (!flat(a.target).startsWith(key)) return false;
1252
1382
  const sent = flat(a.text);
1253
1383
  if (!sent) return false;
1254
- if (t.includes(sent) || sent.includes(t)) return true;
1384
+ // 一模一样(哪怕只有一个字):这就是她刚说的那句
1385
+ if (t === sent) return true;
1386
+ /**
1387
+ * 包含比对必须有长度门槛。
1388
+ * 以前 `t.includes(sent)` 不分长短:「在干啥」包含「在」,于是只要她说过一个「在」,
1389
+ * 对方之后所有带「在」的话都被当成回声丢掉——「有人发消息但不提醒」就这么来的。
1390
+ */
1391
+ const MIN = 4;
1392
+ if (sent.length >= MIN && t.includes(sent)) return true;
1393
+ if (t.length >= MIN && sent.includes(t)) return true;
1255
1394
  // 列表预览常常被截断:前 6 个字一样也当成自己的话(不然截断后就认不出,开始循环)
1256
1395
  const head = Math.min(6, sent.length, t.length);
1257
- return head >= 6 && sent.slice(0, head) === t.slice(0, head);
1396
+ return sent.length >= 6 && t.length >= 6 && sent.slice(0, head) === t.slice(0, head);
1258
1397
  });
1259
1398
  }
1260
1399
 
1400
+ /** 命中的那句原文(只给日志用,最多 24 字)。 */
1401
+ echoHitOf(who, text) {
1402
+ const flat = (s) => String(s ?? '').replace(/\s+/g, '').toLowerCase();
1403
+ const t = flat(text);
1404
+ const key = flat(who);
1405
+ if (!t || !key) return '';
1406
+ const now = Date.now();
1407
+ for (let i = (this.store.data.actions ?? []).length - 1; i >= 0; i -= 1) {
1408
+ const a = this.store.data.actions[i];
1409
+ if (a.action !== 'dm') continue;
1410
+ const at = atMs(a.at);
1411
+ if (!at || now - at > 30 * 60 * 1000) continue;
1412
+ if (!flat(a.target).startsWith(key)) continue;
1413
+ const sent = flat(a.text);
1414
+ if (!sent) continue;
1415
+ if (sent === t) return String(a.text).slice(0, 24);
1416
+ if ((sent.length >= 4 && t.includes(sent)) || (t.length >= 4 && sent.includes(t))) {
1417
+ return String(a.text).slice(0, 24);
1418
+ }
1419
+ const head = Math.min(6, sent.length, t.length);
1420
+ if (sent.length >= 6 && t.length >= 6 && sent.slice(0, head) === t.slice(0, head)) {
1421
+ return String(a.text).slice(0, 24);
1422
+ }
1423
+ }
1424
+ return '';
1425
+ }
1426
+
1261
1427
  /** 给这个陌生人打个「快车道」标记:15 分钟内再来消息就一直续期。 */
1262
1428
  noteStrangerFast(who) {
1263
1429
  const key = `douyin:${who}`;
@@ -1482,7 +1648,7 @@ export class StrollWorld {
1482
1648
  const list = Object.keys(this.store.data.strangerSeen ?? {})
1483
1649
  .filter((k) => k.startsWith('douyin:'))
1484
1650
  .map((k) => stripRowTime(k.slice('douyin:'.length)))
1485
- .filter((who) => !groups.some((g) => this.sameGroup(g, who)));
1651
+ .filter((who) => !this.looksLikeKnownGroup(who, groups));
1486
1652
  return this.matchStranger(list, wanted);
1487
1653
  }
1488
1654
 
@@ -1516,7 +1682,7 @@ export class StrollWorld {
1516
1682
  .filter((k) => k.startsWith('douyin:'))
1517
1683
  .map((k) => stripRowTime(k.slice('douyin:'.length)))
1518
1684
  // 名单里可能混进过群(旧版本没排除干净):认得出的群不当人看
1519
- .filter((who) => !groups.some((g) => this.sameGroup(g, who)));
1685
+ .filter((who) => !this.looksLikeKnownGroup(who, groups));
1520
1686
  let who = this.matchStranger(seen, wanted);
1521
1687
  if (!who) {
1522
1688
  const found =
@@ -1538,6 +1704,20 @@ export class StrollWorld {
1538
1704
  const { mode } = this.strangerDmPolicy();
1539
1705
  const name = String(who ?? '').trim();
1540
1706
  if (!name) return { ok: false };
1707
+ /**
1708
+ * 目标就是她自己登录的那个抖音号:抖音不允许给自己发私信。
1709
+ * 以前会一路走到「点开会话」,然后报「找不到这个会话」——听着像找不到人,
1710
+ * 其实是根本不该发(她也只能跟着猜「是不是我自己的号」)。
1711
+ */
1712
+ const selfName = String(this.store.data.douyinSelf?.name ?? '').trim();
1713
+ const norm = (v) => String(v ?? '').replace(/[\s\u3000]+/g, '').toLowerCase();
1714
+ if (selfName && norm(selfName) === norm(name)) {
1715
+ return {
1716
+ ok: false,
1717
+ code: 'SELF',
1718
+ why: `「${name}」就是她自己登录的抖音号,抖音不能给自己发私信`,
1719
+ };
1720
+ }
1541
1721
  if (mode === 'off') return { ok: false, code: 'STRANGER_OFF', why: '陌生人私信设成「关」了' };
1542
1722
  if (this.isStrangerBlocked(name)) {
1543
1723
  return { ok: false, code: 'BLOCKED', why: `「${name}」在黑名单里,不回` };
@@ -1606,7 +1786,7 @@ export class StrollWorld {
1606
1786
  * 现在把「回过的次数、回信参数、不用再查」都写进来,她不需要额外动作。
1607
1787
  */
1608
1788
  const met = (this.store.data.actions ?? []).filter(
1609
- (a) => a.action === 'dm' && String(a.target) === String(who) && Date.now() - Number(a.at ?? 0) < 24 * 3600 * 1000,
1789
+ (a) => a.action === 'dm' && String(a.target) === String(who) && Date.now() - atMs(a.at) < 24 * 3600 * 1000,
1610
1790
  ).length;
1611
1791
  const whoLine = met ? `${who}·之前回过 ${met} 次` : `${who}·第一次找你`;
1612
1792
  const hint =
@@ -1715,14 +1895,49 @@ export class StrollWorld {
1715
1895
  */
1716
1896
  if (!list.length && Date.now() - Number(this.strangerListAt ?? 0) >= 10 * 1000) {
1717
1897
  // 主列表要遍历每一行的 innerText,比读入口贵,10 秒一次就够
1898
+ this.strangerListAt = Date.now();
1718
1899
  const groups = this.groupNames();
1719
- if (groups.length) {
1720
- this.strangerListAt = Date.now();
1900
+ if (!groups.length) {
1901
+ /**
1902
+ * 这条路靠「排除已知群」才敢用;一个群都认不出来时**不推**(免得把群当人),
1903
+ * 但日志里要把列表里都有谁写出来——不然「有人发消息没提醒」根本查不到是
1904
+ * 「没读到」还是「读到了但不敢推」。
1905
+ */
1906
+ if (Date.now() - Number(this.strangerRowsLogAt ?? 0) > 5 * 60 * 1000) {
1907
+ this.strangerRowsLogAt = Date.now();
1908
+ const rows = await this.douyin.conversationRows().catch(() => []);
1909
+ this.log?.warn?.('stroll stranger rows skipped', {
1910
+ reason: 'no groups',
1911
+ count: rows.length,
1912
+ rows: rows.slice(0, 12).map((r) => `${truncate(r.name, 12)}|${truncate(r.preview, 12)}`),
1913
+ });
1914
+ }
1915
+ } else {
1721
1916
  // 昵称/时间/预览的清洗在 douyin.conversationRows 里做完了(时间不能留在名字里)
1722
1917
  const rows = await this.douyin.conversationRows().catch(() => []);
1723
1918
  const known = [...groups, ownerName].filter(Boolean);
1919
+ /**
1920
+ * 诊断:把主列表每一行和「为什么不算陌生人」记下来(5 分钟一次)。
1921
+ * 以后「有人发了消息但没提醒」时,一眼能看出是没读到、还是读到了被当群排掉。
1922
+ */
1923
+ if (rows.length && Date.now() - Number(this.strangerRowsLogAt ?? 0) > 5 * 60 * 1000) {
1924
+ this.strangerRowsLogAt = Date.now();
1925
+ this.log?.info?.('stroll stranger rows', {
1926
+ groups: groups.length,
1927
+ rows: rows.slice(0, 12).map((r) => {
1928
+ const who = String(r.name ?? '');
1929
+ const pv = String(r.preview ?? '');
1930
+ let why = 'stranger';
1931
+ if (ownerName && this.sameGroup(ownerName, who)) why = 'owner';
1932
+ else if (this.looksLikeKnownGroup(who, known)) why = 'group';
1933
+ else if (!pv) why = 'no-preview';
1934
+ else if (/^\d+分钟内在线$|^在线$/.test(pv)) why = 'online';
1935
+ return `${truncate(who, 12)}|${truncate(pv, 12)}|${why}`;
1936
+ }),
1937
+ });
1938
+ }
1724
1939
  const extra = rows
1725
- .filter((r) => r.name && !known.some((n) => this.sameGroup(n, r.name)))
1940
+ .filter((r) => r.name && !this.looksLikeKnownGroup(r.name, known))
1726
1941
  .map((r) => ({ who: r.name, at: r.at || '', preview: r.preview || '', unread: 0 }))
1727
1942
  .filter((r) => r.preview && !/^\d+分钟内在线$|^在线$/.test(r.preview));
1728
1943
  if (extra.length) {
@@ -1759,14 +1974,15 @@ export class StrollWorld {
1759
1974
  * 以前这些都静默跳过,线上表现就是「一句回、一句不回」,但日志里什么都没有。
1760
1975
  * 只在**预览变了**的时候记(指纹没变的那次是热路径,不记),不会刷屏。
1761
1976
  */
1762
- const skip = (why) =>
1977
+ const skip = (why, extra = null) =>
1763
1978
  this.log?.info?.('stroll stranger skip', {
1764
1979
  who: row.who,
1765
1980
  preview: truncate(String(row.preview ?? ''), 20),
1766
1981
  why,
1982
+ ...(extra ? { hit: truncate(String(extra), 24) } : {}),
1767
1983
  });
1768
1984
  if (!row.preview || /^\d+分钟内在线$|^在线$/.test(row.preview)) continue;
1769
- if (knownGroups.some((g) => this.sameGroup(g, row.who))) continue;
1985
+ if (this.looksLikeKnownGroup(row.who, knownGroups)) continue;
1770
1986
  const key = `douyin:${row.who}`;
1771
1987
  /**
1772
1988
  * 指纹只用正文,**不带时间**。
@@ -1787,7 +2003,8 @@ export class StrollWorld {
1787
2003
  }
1788
2004
  // 主列表的预览没有「谁说的」标记:和她刚发出去的原文比对,命中就当她自己的话
1789
2005
  if (this.recentlySentTo(row.who, row.preview)) {
1790
- skip('echo');
2006
+ // 带上「命中的是哪句她说过的话」:误判时不用再猜
2007
+ skip('echo', this.echoHitOf(row.who, row.preview));
1791
2008
  continue;
1792
2009
  }
1793
2010
  // 不做时间冷却:对方紧跟着说的第二句要立刻叫她(冷却会把这类话吞成「已读不回」)。
@@ -2242,25 +2459,75 @@ export class StrollWorld {
2242
2459
  /* ---------------- prompt ---------------- */
2243
2460
 
2244
2461
  /**
2245
- * 设置里改的值不一定热更新到运行中的实例——她可能还在读启动时那份 cfg。
2246
- * 这里兜底读一次磁盘上的 config.json(两秒缓存),改完设置不用重启。
2462
+ * 磁盘上的设置。
2463
+ *
2464
+ * 面板改配置只写 config.json,**运行中的实例不会收到通知**——她的 `this.cfg` 还是
2465
+ * 启动那一刻的快照。以前只有少数几处读这里,于是「改成『先问我』还是不点头」
2466
+ * 这种问题会一直出现:明明改了,实际还在按旧值跑。
2467
+ *
2468
+ * 现在改成:文件 mtime 一变就把磁盘值同步进 `this.cfg`(原地赋值,所有模块共享同一个
2469
+ * 引用,Douyin/Bilibili/Policy 一起生效)。两秒缓存,读不到就退回内存里的值。
2247
2470
  */
2248
2471
  liveConfig() {
2249
2472
  const now = Date.now();
2250
2473
  if (this._cfgAt && now - this._cfgAt < 2000) return this._cfgLive;
2251
2474
  this._cfgAt = now;
2252
- this._cfgLive = null;
2475
+ this._cfgLive = this._cfgDisk ?? null;
2476
+ const file = path.join(this.dataDir, '..', 'config.json');
2253
2477
  try {
2254
- const file = path.join(this.dataDir, '..', 'config.json');
2478
+ const mtime = fs.statSync(file).mtimeMs;
2479
+ // 文件没动过:上面的缓存值就是最新的,不用再解析一遍
2480
+ if (this._cfgMtime && mtime === this._cfgMtime) return this._cfgLive;
2255
2481
  const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
2256
2482
  const world = parsed?.worlds?.stroll;
2257
- if (world && typeof world === 'object') this._cfgLive = world;
2483
+ if (!world || typeof world !== 'object') return this._cfgLive;
2484
+ this._cfgDisk = world;
2485
+ this._cfgMtime = mtime;
2486
+ this.applyLiveConfig(world);
2487
+ this._cfgLive = world;
2258
2488
  } catch {
2259
- // 读不到就退回内存里的 cfg
2489
+ // 读不到(路径不同 / 文件正在写)就退回内存里的 cfg
2260
2490
  }
2261
2491
  return this._cfgLive;
2262
2492
  }
2263
2493
 
2494
+ /**
2495
+ * 把磁盘上的设置写进内存里的 cfg。
2496
+ *
2497
+ * 只覆盖磁盘上真有的键,不动其余(缺的键继续用启动时的默认值);
2498
+ * 原地赋值而不是换对象——`this.cfg` 被 Policy / Bilibili / DouyinBrowser 共用,
2499
+ * 换引用会让它们继续拿着旧对象。
2500
+ */
2501
+ applyLiveConfig(disk) {
2502
+ /**
2503
+ * ESM 是严格模式:给冻结对象赋值会直接抛错,而 liveConfig 外面有 catch 会把它吞掉,
2504
+ * 表现就是「热更新完全没反应,日志里也没有」。这里显式说一句,别让人再猜一次。
2505
+ */
2506
+ if (Object.isFrozen(this.cfg)) {
2507
+ if (!this._cfgFrozenWarned) {
2508
+ this._cfgFrozenWarned = true;
2509
+ this.log?.warn?.('stroll config frozen', { note: '宿主冻结了配置对象,热更新不可用,改了设置要重启' });
2510
+ }
2511
+ return;
2512
+ }
2513
+ const changed = [];
2514
+ for (const [k, v] of Object.entries(disk)) {
2515
+ const before = this.cfg[k];
2516
+ // 数组/对象比不了引用,简单序列化一下(配置里只有字符串和数字,成本可忽略)
2517
+ const same =
2518
+ before === v ||
2519
+ (typeof before === 'object' && typeof v === 'object' && JSON.stringify(before) === JSON.stringify(v));
2520
+ if (same) continue;
2521
+ this.cfg[k] = v;
2522
+ changed.push(k);
2523
+ }
2524
+ if (changed.length) {
2525
+ this.log?.info?.('stroll config live', { changed: changed.slice(0, 8), total: changed.length });
2526
+ // 监听开关可能刚被改:让 dmBeat 重新决定要不要挂/收页面
2527
+ this._cfgLive = disk;
2528
+ }
2529
+ }
2530
+
2264
2531
  /** 主人的账号:优先读磁盘上最新的那份,读不到再用内存里的。 */
2265
2532
  ownerId(platform) {
2266
2533
  const key = platform === 'douyin' ? 'ownerDouyin' : 'ownerUid';
@@ -4012,15 +4279,19 @@ export class StrollWorld {
4012
4279
  const OWNER_ALIAS = /^(主人|主人私信|私信|私聊|owner|dm|你|您)$/i;
4013
4280
  let groups = await this.resolveGroups().catch(() => this.groupNames());
4014
4281
  if (wanted && !OWNER_ALIAS.test(wanted)) {
4015
- let hit = this.matchGroup(groups, wanted);
4016
- if (!hit) {
4282
+ // 和私信一样:群名可能是「几个人的昵称拼起来的」,命中陌生人名单就优先当人
4283
+ const quick = this.cachedStranger(wanted, groups);
4284
+ let hit = quick ? null : this.matchGroup(groups, wanted);
4285
+ if (!hit && !quick) {
4017
4286
  // 名单可能是旧的(刚被拉进新群):强刷一次再认,别把群名当成「不认识的人」
4018
4287
  groups = await this.resolveGroups(true, { deep: true }).catch(() => groups);
4019
4288
  hit = this.matchGroup(groups, wanted);
4020
4289
  }
4021
4290
  if (hit) return { ok: true, who: hit, group: true };
4022
4291
  // 不是群:也可能是「陌生人消息」里给她发过话的人(图和表情一样能发过去)
4023
- const stranger = await this.strangerTargetOf(wanted).catch(() => ({ ok: false }));
4292
+ const stranger = quick
4293
+ ? this.strangerGuard(quick)
4294
+ : await this.strangerTargetOf(wanted).catch(() => ({ ok: false }));
4024
4295
  if (stranger.ok) return { ok: true, who: stranger.who, group: false, stranger: true };
4025
4296
  const list = groups.length ? groups.map((g) => `「${g}」`).join(' 或 ') : '(现在一个群都没认出来)';
4026
4297
  return {
@@ -4692,20 +4963,38 @@ export class StrollWorld {
4692
4963
  !dmFresh && this.lastGroupPoke && Date.now() - Number(this.lastGroupPoke.at ?? 0) < 10 * 60 * 1000
4693
4964
  ? String(this.lastGroupPoke.group ?? '')
4694
4965
  : '';
4695
- let asGroup = wanted ? this.matchGroup(groups, wanted) : null;
4696
- if (!asGroup && wanted && groups.length === 1 && /^(群|群聊|那个群|抖音群|group|the group)$/i.test(wanted)) {
4697
- asGroup = groups[0];
4698
- }
4699
- if (!asGroup && wanted && pokedGroup && this.matchGroup([pokedGroup], wanted)) asGroup = pokedGroup;
4700
4966
  /**
4701
4967
  * 先看「这是不是一个给她发过消息的陌生人」——**只查本地名单,不读页面**。
4702
4968
  *
4703
- * 以前这一步排在「强刷群名单」后面:任何不是群名的 target 都要先深刷一次
4704
- * 会话列表(真的去读页面,实测 0.85 秒),陌生人也照刷。
4705
- * 现在命中本地名单就直接走陌生人分支,那 0.85 秒全省下来。
4969
+ * 顺序很关键。抖音拉群时群名默认是**几个成员的昵称拼起来**
4970
+ * (`海底月、小月月、大萌神`),而 `matchGroup` 允许「她写的是群名的一部分」。
4971
+ * 于是 `target=海底月` 会被判成「发到那个群」——**她的私信内容直接公开在群里**。
4972
+ * 所以:能当人就当人,命中陌生人名单就不再做群匹配。
4973
+ * (副作用:想发到这种群得写完整群名,这个代价可以接受。)
4706
4974
  */
4707
- let quickStranger = '';
4708
- if (!asGroup && wanted) quickStranger = this.cachedStranger(wanted, groups);
4975
+ let quickStranger = wanted ? this.cachedStranger(wanted, groups) : '';
4976
+ if (quickStranger) {
4977
+ const wouldBeGroup = this.matchGroup(groups, wanted);
4978
+ if (wouldBeGroup) {
4979
+ this.log?.warn?.('stroll target ambiguous', {
4980
+ target: wanted,
4981
+ stranger: quickStranger,
4982
+ group: wouldBeGroup,
4983
+ pick: 'dm',
4984
+ });
4985
+ }
4986
+ }
4987
+ let asGroup = wanted && !quickStranger ? this.matchGroup(groups, wanted) : null;
4988
+ if (
4989
+ !asGroup &&
4990
+ !quickStranger &&
4991
+ wanted &&
4992
+ groups.length === 1 &&
4993
+ /^(群|群聊|那个群|抖音群|group|the group)$/i.test(wanted)
4994
+ ) {
4995
+ asGroup = groups[0];
4996
+ }
4997
+ if (!asGroup && !quickStranger && wanted && pokedGroup && this.matchGroup([pokedGroup], wanted)) asGroup = pokedGroup;
4709
4998
  if (!asGroup && wanted && !quickStranger) {
4710
4999
  // 名单可能是旧的(主人刚把她拉进新群):滚动会话列表强刷一次再认
4711
5000
  groups = await this.resolveGroups(true, { deep: true }).catch(() => groups);
package/webui/client.js CHANGED
@@ -1615,7 +1615,8 @@ export default {
1615
1615
 
1616
1616
  function strangerCard(item) {
1617
1617
  const card = el('div', undefined, 'stroll-stranger');
1618
- const iconBox = el('私', 'stroll-draft-icon');
1618
+ // el(tag, 文字, 类名)——以前把类名写进了第二个参数,面板上就直接显示「stroll-draft-icon」
1619
+ const iconBox = el('span', item.platform === 'bilibili' ? 'B' : '抖', 'stroll-draft-icon');
1619
1620
  iconBox.style.setProperty('--tone', '#fe2c55');
1620
1621
  const body = el('div', undefined, 'stroll-draft-body');
1621
1622
  const head = el('p');