cortico-world-hands 0.12.0 → 0.13.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.
Files changed (2) hide show
  1. package/dist/index.js +38 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1096,6 +1096,15 @@ 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
+ }
1099
1108
  /** 解锁锁屏:密码由主人放在本机文件里,这里只触发,不接触密码。 */
1100
1109
  async unlockScreen() {
1101
1110
  const cfg = this.cfg();
@@ -1491,6 +1500,19 @@ var HANDS_TOOL_DECLS = [
1491
1500
  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
1501
  parameters: { type: "object", properties: {}, required: [] }
1493
1502
  },
1503
+ {
1504
+ name: "qq_reply",
1505
+ tags: ["act"],
1506
+ 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",
1507
+ parameters: {
1508
+ type: "object",
1509
+ properties: {
1510
+ text: { type: "string", description: "\u8981\u56DE\u7684\u8BDD" },
1511
+ to: { type: "string", description: "\u53EF\u9009\uFF1A\u5BF9\u8BDD\u6807\u9898\u91CC\u7684\u4E00\u6BB5\uFF0C\u6BD4\u5982\u7FA4\u540D\u6216\u4EBA\u540D" }
1512
+ },
1513
+ required: ["text"]
1514
+ }
1515
+ },
1494
1516
  {
1495
1517
  name: "media_clean",
1496
1518
  tags: ["act"],
@@ -2039,6 +2061,8 @@ ${lines.join("\n")}
2039
2061
  return await this.mediaClean(args);
2040
2062
  case "screen_wake":
2041
2063
  return await this.screenWake();
2064
+ case "qq_reply":
2065
+ return await this.qqReply(args);
2042
2066
  case "screen_unlock":
2043
2067
  return await this.screenUnlock();
2044
2068
  case "screen_sleep":
@@ -2180,6 +2204,20 @@ ${lines.join("\n")}
2180
2204
  return failed(raw.slice(0, 120));
2181
2205
  }
2182
2206
  }
2207
+ /** 在 QQ 里回一句(快速回复,不抢屏)。 */
2208
+ async qqReply(args) {
2209
+ const text = typeof args.text === "string" ? args.text.trim() : "";
2210
+ if (!text) return failed("\u8981\u56DE\u4EC0\u4E48\uFF1F");
2211
+ const to = typeof args.to === "string" ? args.to.trim() : "";
2212
+ const raw = await this.hands.qqReply(text, to || void 0);
2213
+ try {
2214
+ const r = JSON.parse(raw);
2215
+ if (r.ok) return `\u56DE\u4E86${r.to ? "\u7ED9\u300C" + r.to + "\u300D" : ""}\uFF1A${text}`;
2216
+ return failed(r.error || "\u6CA1\u56DE\u51FA\u53BB");
2217
+ } catch {
2218
+ return failed(raw.slice(0, 120));
2219
+ }
2220
+ }
2183
2221
  /** 解锁:成功/没锁/失败都给人话。 */
2184
2222
  async screenUnlock() {
2185
2223
  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.12.0",
3
+ "version": "0.13.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",