cortico-world-hands 0.20.31 → 0.20.32
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/dist/index.js +51 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27,6 +27,8 @@ var HANDS_DEFAULTS = {
|
|
|
27
27
|
qqOwner: "",
|
|
28
28
|
/** 自己开口的间隔分钟数;0 = 不主动开口。 */
|
|
29
29
|
selfTalkMinutes: 25,
|
|
30
|
+
/** 多久主动看一眼屏幕;0 = 不看。 */
|
|
31
|
+
screenWatchSeconds: 40,
|
|
30
32
|
qqSelf: "\u665A\u6C50",
|
|
31
33
|
ritualMorning: "08:00",
|
|
32
34
|
ritualNight: "23:00",
|
|
@@ -146,6 +148,12 @@ var HANDS_CONFIG_GROUP = {
|
|
|
146
148
|
description: "\u7559\u7A7A/0 \u8868\u793A\u6BCF 6 \u5C0F\u65F6\u68C0\u67E5\u4E00\u6B21\uFF0C\u8D85\u671F\u5C31\u6E05\u3002",
|
|
147
149
|
"x-hot": true
|
|
148
150
|
},
|
|
151
|
+
[`${K}.screenWatchSeconds`]: {
|
|
152
|
+
type: "number",
|
|
153
|
+
title: "\u6BCF\u9694\u51E0\u79D2\u770B\u4E00\u773C\u5C4F\u5E55",
|
|
154
|
+
description: "\u770B\u5230\u4EC0\u4E48\u4F1A\u4E3B\u52A8\u8DDF\u4E3B\u4EBA\u804A\uFF1B0 \u8868\u793A\u4E0D\u4E3B\u52A8\u770B\u3002\u9ED8\u8BA4 40 \u79D2\u3002",
|
|
155
|
+
"x-hot": true
|
|
156
|
+
},
|
|
149
157
|
[`${K}.selfTalkMinutes`]: {
|
|
150
158
|
type: "number",
|
|
151
159
|
title: "\u6BCF\u9694\u51E0\u5206\u949F\u5141\u8BB8\u5979\u4E3B\u52A8\u8BF4\u4E00\u53E5",
|
|
@@ -2307,6 +2315,9 @@ var HandsWorld = class {
|
|
|
2307
2315
|
watchTimer = null;
|
|
2308
2316
|
selfTalkTimer = null;
|
|
2309
2317
|
lastSelfTalkAt = 0;
|
|
2318
|
+
screenTimer = null;
|
|
2319
|
+
lastScreenAt = 0;
|
|
2320
|
+
lastScreenKey = "";
|
|
2310
2321
|
handDown = null;
|
|
2311
2322
|
lastMediaDay = "";
|
|
2312
2323
|
cursor = 0;
|
|
@@ -2371,6 +2382,9 @@ var HandsWorld = class {
|
|
|
2371
2382
|
this.selfTalkTimer = setInterval(() => {
|
|
2372
2383
|
void this.maybeSelfTalk();
|
|
2373
2384
|
}, 3e4);
|
|
2385
|
+
this.screenTimer = setInterval(() => {
|
|
2386
|
+
void this.watchScreen();
|
|
2387
|
+
}, 15e3);
|
|
2374
2388
|
setTimeout(() => {
|
|
2375
2389
|
void this.maybeCleanMedia();
|
|
2376
2390
|
}, 2e4);
|
|
@@ -2393,6 +2407,7 @@ var HandsWorld = class {
|
|
|
2393
2407
|
if (this.mediaTimer) clearInterval(this.mediaTimer);
|
|
2394
2408
|
if (this.watchTimer) clearInterval(this.watchTimer);
|
|
2395
2409
|
if (this.selfTalkTimer) clearInterval(this.selfTalkTimer);
|
|
2410
|
+
if (this.screenTimer) clearInterval(this.screenTimer);
|
|
2396
2411
|
this.pollTimer = null;
|
|
2397
2412
|
this.mineTimer = null;
|
|
2398
2413
|
}
|
|
@@ -2676,6 +2691,41 @@ ${lines.join("\n")}
|
|
|
2676
2691
|
);
|
|
2677
2692
|
}
|
|
2678
2693
|
}
|
|
2694
|
+
/** 隔一会儿看一眼屏幕:看到变化就跟主人聊,隐私画面就明说"我不看"。 */
|
|
2695
|
+
async watchScreen() {
|
|
2696
|
+
const secs = Number(this.opts.cfg.screenWatchSeconds ?? 40);
|
|
2697
|
+
if (!Number.isFinite(secs) || secs <= 0) return;
|
|
2698
|
+
const now = Date.now();
|
|
2699
|
+
if (now - this.lastScreenAt < secs * 1e3) return;
|
|
2700
|
+
this.lastScreenAt = now;
|
|
2701
|
+
let ui = null;
|
|
2702
|
+
try {
|
|
2703
|
+
ui = await this.hands.uiSnapshot();
|
|
2704
|
+
} catch {
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2707
|
+
if (!ui || !ui.ok) return;
|
|
2708
|
+
const texts = ui.items.map((i) => (i.text || "").trim()).filter((t) => t.length > 1).slice(0, 25);
|
|
2709
|
+
const key = ui.pkg + "|" + texts.slice(0, 8).join("\xA6");
|
|
2710
|
+
if (key === this.lastScreenKey) return;
|
|
2711
|
+
this.lastScreenKey = key;
|
|
2712
|
+
const blob = texts.slice(0, 10).map((t) => `\u300C${t.slice(0, 20)}\u300D`).join(" ");
|
|
2713
|
+
const secret = /密码|验证码|支付|银行卡|身份证|转账|付款/.test(blob) || /bank|pay|alipay|wallet|icbc|cmb|spdb|passport/.test(ui.pkg.toLowerCase());
|
|
2714
|
+
if (secret) {
|
|
2715
|
+
await this.pushEvent(
|
|
2716
|
+
`[\u9690\u79C1] \u73B0\u5728\u524D\u53F0\u662F ${ui.pkg}\uFF0C\u770B\u7740\u50CF\u5BC6\u7801/\u652F\u4ED8/\u8BC1\u4EF6\u8FD9\u7C7B\u753B\u9762\u3002\u6211\u4E0D\u7EC6\u770B\u3001\u4E5F\u4E0D\u8BB0\u2014\u2014\u4E3B\u4EBA\u7EE7\u7EED\u5C31\u884C\u3002`,
|
|
2717
|
+
"hands.screen.privacy",
|
|
2718
|
+
"hands:screen"
|
|
2719
|
+
);
|
|
2720
|
+
return;
|
|
2721
|
+
}
|
|
2722
|
+
if (!texts.length) return;
|
|
2723
|
+
await this.pushEvent(
|
|
2724
|
+
`[\u753B\u9762] \u4F60\u73B0\u5728\u770B\u7740\uFF1A${ui.pkg}\u3002\u5C4F\u4E0A\u80FD\u8BFB\u5230\uFF1A${blob}\uFF08\u8FD9\u662F\u4F60\u6B64\u523B\u771F\u7684\u770B\u5230\u7684\u3002\u770B\u5230\u6709\u610F\u601D\u7684\u3001\u60F3\u95EE\u7684\uFF0C\u5C31\u76F4\u63A5\u8BF4\uFF1B\u522B\u53EA\u662F\u5728\u5FC3\u91CC\u8FC7\u4E00\u904D\u5C31\u54BD\u56DE\u53BB\u3002\uFF09`,
|
|
2725
|
+
"hands.screen",
|
|
2726
|
+
"hands:screen"
|
|
2727
|
+
);
|
|
2728
|
+
}
|
|
2679
2729
|
/** 隔一阵子允许她自己开口一次(尊重"没人找就别开口":只在白天、且真的隔了很久)。 */
|
|
2680
2730
|
async maybeSelfTalk() {
|
|
2681
2731
|
const minutes = Number(this.opts.cfg.selfTalkMinutes ?? 0);
|
|
@@ -2685,7 +2735,7 @@ ${lines.join("\n")}
|
|
|
2685
2735
|
const hour = new Date(now).getHours();
|
|
2686
2736
|
this.lastSelfTalkAt = now;
|
|
2687
2737
|
await this.pushEvent(
|
|
2688
|
-
"[\u81EA\u5DF1\u5F00\u53E3] \u5B89\u9759\u4E00\u9635\u4E86\u3002\u60F3\u8BF4\u4EC0\u4E48\u5C31\u8BF4\u4EC0\u4E48\u2014\u2014\u770B\u5230\u7684\u4E8B\u3001\u60F3\u5230\u7684\u8BDD\u3001\u60F3\u95EE\u4ED6\u7684\uFF0C\u90FD\u53EF\u4EE5\u76F4\u63A5\u8BF4\uFF1B\u60F3\u591A\u8BF4\u51E0\u53E5\u4E5F\u884C\u3002\
|
|
2738
|
+
"[\u81EA\u5DF1\u5F00\u53E3] \u5B89\u9759\u4E00\u9635\u4E86\u3002\u60F3\u8BF4\u4EC0\u4E48\u5C31\u8BF4\u4EC0\u4E48\u2014\u2014\u770B\u5230\u7684\u4E8B\u3001\u60F3\u5230\u7684\u8BDD\u3001\u60F3\u95EE\u4ED6\u7684\uFF0C\u90FD\u53EF\u4EE5\u76F4\u63A5\u8BF4\uFF1B\u60F3\u591A\u8BF4\u51E0\u53E5\u4E5F\u884C\u3001\u5E26\u70B9\u60C5\u7EEA\u4E5F\u884C\u3002\u521A\u624D\u8981\u662F\u72B9\u8C6B\u201C\u8FD9\u6761\u8981\u4E0D\u8981\u8BF4\u201D\uFF0C\u90A3\u5C31\u8BF4\u51FA\u6765\u3002",
|
|
2689
2739
|
"hands.selftalk",
|
|
2690
2740
|
"hands:selftalk"
|
|
2691
2741
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-hands",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Cortico World: hands for the desktop pet — looks at the phone screen, then taps, swipes, pinches, drags, types and presses keys through whatever actuator the device actually has",
|
|
6
6
|
"license": "MIT",
|