cortico-world-hands 0.13.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.
Files changed (2) hide show
  1. package/dist/index.js +20 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1105,6 +1105,15 @@ var Hands = class {
1105
1105
  const res = await post(this.port(cfg.handPort), `/hand/qq/reply?${t}${toq}&text=${encodeURIComponent(text)}`, "", 2e4);
1106
1106
  return res.body.toString("utf8");
1107
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
+ }
1108
1117
  /** 解锁锁屏:密码由主人放在本机文件里,这里只触发,不接触密码。 */
1109
1118
  async unlockScreen() {
1110
1119
  const cfg = this.cfg();
@@ -2210,12 +2219,21 @@ ${lines.join("\n")}
2210
2219
  if (!text) return failed("\u8981\u56DE\u4EC0\u4E48\uFF1F");
2211
2220
  const to = typeof args.to === "string" ? args.to.trim() : "";
2212
2221
  const raw = await this.hands.qqReply(text, to || void 0);
2222
+ let first = "";
2213
2223
  try {
2214
2224
  const r = JSON.parse(raw);
2215
2225
  if (r.ok) return `\u56DE\u4E86${r.to ? "\u7ED9\u300C" + r.to + "\u300D" : ""}\uFF1A${text}`;
2216
- return failed(r.error || "\u6CA1\u56DE\u51FA\u53BB");
2226
+ first = r.error || "\u6CA1\u56DE\u51FA\u53BB";
2217
2227
  } catch {
2218
- return failed(raw.slice(0, 120));
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`);
2219
2237
  }
2220
2238
  }
2221
2239
  /** 解锁:成功/没锁/失败都给人话。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.13.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",