cortico-world-hands 0.12.0 → 0.14.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/dist/index.js +56 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1096,6 +1096,24 @@ var Hands = class {
|
|
|
1096
1096
|
} catch {
|
|
1097
1097
|
}
|
|
1098
1098
|
}
|
|
1099
|
+
/** QQ 快速回复:不打开 QQ 也不抢屏。 */
|
|
1100
|
+
async qqReply(text, to) {
|
|
1101
|
+
const cfg = this.cfg();
|
|
1102
|
+
const credential = this.readToken();
|
|
1103
|
+
const t = credential ? `t=${encodeURIComponent(credential)}` : "";
|
|
1104
|
+
const toq = to ? `&to=${encodeURIComponent(to)}` : "";
|
|
1105
|
+
const res = await post(this.port(cfg.handPort), `/hand/qq/reply?${t}${toq}&text=${encodeURIComponent(text)}`, "", 2e4);
|
|
1106
|
+
return res.body.toString("utf8");
|
|
1107
|
+
}
|
|
1108
|
+
/** QQ 兜底:打开 QQ → 找到对话 → 粘贴 → 发送 → 切回。 */
|
|
1109
|
+
async qqOpenReply(text, to) {
|
|
1110
|
+
const cfg = this.cfg();
|
|
1111
|
+
const credential = this.readToken();
|
|
1112
|
+
const t = credential ? `t=${encodeURIComponent(credential)}` : "";
|
|
1113
|
+
const toq = to ? `&to=${encodeURIComponent(to)}` : "";
|
|
1114
|
+
const res = await post(this.port(cfg.handPort), `/hand/qq/open_reply?${t}${toq}&text=${encodeURIComponent(text)}`, "", 9e4);
|
|
1115
|
+
return res.body.toString("utf8");
|
|
1116
|
+
}
|
|
1099
1117
|
/** 解锁锁屏:密码由主人放在本机文件里,这里只触发,不接触密码。 */
|
|
1100
1118
|
async unlockScreen() {
|
|
1101
1119
|
const cfg = this.cfg();
|
|
@@ -1491,6 +1509,19 @@ var HANDS_TOOL_DECLS = [
|
|
|
1491
1509
|
description: "\u770B\u624B\u81EA\u5DF1\u7684\u72B6\u6001\uFF1A\u8D70\u54EA\u6761\u901A\u9053\u3001\u901A\u4E0D\u901A\u3001\u8FD9\u4E00\u5206\u949F\u52A8\u4E86\u51E0\u4E2A\u52A8\u4F5C\u3001\u521A\u624D\u90A3\u4E00\u4E0B\u6210\u4E86\u6CA1\u6709\u3002\u5BF9\u65B9\u95EE\u300C\u624B\u80FD\u7528\u5417\u300D\u300C\u4F60\u521A\u624D\u70B9\u4E86\u4EC0\u4E48\u300D\u65F6\u7528\u5B83\u3002",
|
|
1492
1510
|
parameters: { type: "object", properties: {}, required: [] }
|
|
1493
1511
|
},
|
|
1512
|
+
{
|
|
1513
|
+
name: "qq_reply",
|
|
1514
|
+
tags: ["act"],
|
|
1515
|
+
description: "\u5728 QQ \u91CC\u7528\u300C\u5FEB\u901F\u56DE\u590D\u300D\u56DE\u4E00\u53E5\uFF08\u4E0D\u6253\u5F00 QQ\u3001\u4E0D\u62A2\u5C4F\uFF09\uFF1A\u7ED9\u8981\u56DE\u7684\u8BDD\uFF1Bto \u53EF\u9009\uFF0C\u586B\u5BF9\u8BDD\u6807\u9898\u7684\u4E00\u90E8\u5206\u7528\u6765\u6307\u5B9A\u56DE\u7ED9\u8C01\u3002\u901A\u77E5\u91CC\u6CA1\u6709\u5FEB\u901F\u56DE\u590D\u5165\u53E3\u65F6\u4F1A\u5931\u8D25\u5E76\u8BF4\u660E\u3002",
|
|
1516
|
+
parameters: {
|
|
1517
|
+
type: "object",
|
|
1518
|
+
properties: {
|
|
1519
|
+
text: { type: "string", description: "\u8981\u56DE\u7684\u8BDD" },
|
|
1520
|
+
to: { type: "string", description: "\u53EF\u9009\uFF1A\u5BF9\u8BDD\u6807\u9898\u91CC\u7684\u4E00\u6BB5\uFF0C\u6BD4\u5982\u7FA4\u540D\u6216\u4EBA\u540D" }
|
|
1521
|
+
},
|
|
1522
|
+
required: ["text"]
|
|
1523
|
+
}
|
|
1524
|
+
},
|
|
1494
1525
|
{
|
|
1495
1526
|
name: "media_clean",
|
|
1496
1527
|
tags: ["act"],
|
|
@@ -2039,6 +2070,8 @@ ${lines.join("\n")}
|
|
|
2039
2070
|
return await this.mediaClean(args);
|
|
2040
2071
|
case "screen_wake":
|
|
2041
2072
|
return await this.screenWake();
|
|
2073
|
+
case "qq_reply":
|
|
2074
|
+
return await this.qqReply(args);
|
|
2042
2075
|
case "screen_unlock":
|
|
2043
2076
|
return await this.screenUnlock();
|
|
2044
2077
|
case "screen_sleep":
|
|
@@ -2180,6 +2213,29 @@ ${lines.join("\n")}
|
|
|
2180
2213
|
return failed(raw.slice(0, 120));
|
|
2181
2214
|
}
|
|
2182
2215
|
}
|
|
2216
|
+
/** 在 QQ 里回一句(快速回复,不抢屏)。 */
|
|
2217
|
+
async qqReply(args) {
|
|
2218
|
+
const text = typeof args.text === "string" ? args.text.trim() : "";
|
|
2219
|
+
if (!text) return failed("\u8981\u56DE\u4EC0\u4E48\uFF1F");
|
|
2220
|
+
const to = typeof args.to === "string" ? args.to.trim() : "";
|
|
2221
|
+
const raw = await this.hands.qqReply(text, to || void 0);
|
|
2222
|
+
let first = "";
|
|
2223
|
+
try {
|
|
2224
|
+
const r = JSON.parse(raw);
|
|
2225
|
+
if (r.ok) return `\u56DE\u4E86${r.to ? "\u7ED9\u300C" + r.to + "\u300D" : ""}\uFF1A${text}`;
|
|
2226
|
+
first = r.error || "\u6CA1\u56DE\u51FA\u53BB";
|
|
2227
|
+
} catch {
|
|
2228
|
+
first = raw.slice(0, 120);
|
|
2229
|
+
}
|
|
2230
|
+
const second = await this.hands.qqOpenReply(text, to || void 0);
|
|
2231
|
+
try {
|
|
2232
|
+
const r2 = JSON.parse(second);
|
|
2233
|
+
if (r2.ok) return `\u6253\u5F00 QQ \u56DE\u4E86${to ? "\u7ED9\u300C" + to + "\u300D" : ""}\uFF1A${text}\uFF08\u5FEB\u901F\u56DE\u590D\u4E0D\u53EF\u7528\uFF0C\u5DF2\u5207\u56DE\u6765\uFF09`;
|
|
2234
|
+
return failed(`\u5FEB\u901F\u56DE\u590D\u4E0D\u884C\uFF08${first}\uFF09\uFF0C\u6253\u5F00 QQ \u4E5F\u6CA1\u6210\uFF08${r2.error || "\u539F\u56E0\u4E0D\u660E"}\uFF09`);
|
|
2235
|
+
} catch {
|
|
2236
|
+
return failed(`\u5FEB\u901F\u56DE\u590D\u4E0D\u884C\uFF08${first}\uFF09\uFF0C\u6253\u5F00 QQ \u4E5F\u6CA1\u6210`);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2183
2239
|
/** 解锁:成功/没锁/失败都给人话。 */
|
|
2184
2240
|
async screenUnlock() {
|
|
2185
2241
|
const raw = await this.hands.unlockScreen();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-hands",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
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",
|