@kyan-du/agent-wechat-openclaw 0.14.6 → 0.15.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/dist/index.js +13 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1158,6 +1158,14 @@ function getWeChatRuntime() {
|
|
|
1158
1158
|
// src/monitor.ts
|
|
1159
1159
|
import { unlink } from "node:fs/promises";
|
|
1160
1160
|
|
|
1161
|
+
// src/monitor-open-chat.ts
|
|
1162
|
+
function requireVerifiedChatOpen(result, chatId) {
|
|
1163
|
+
if (result?.ok !== true || result.verified !== true || result.username !== chatId) {
|
|
1164
|
+
const code = result?.errorCode ?? "TARGET_CONFIRMATION_FAILED";
|
|
1165
|
+
throw new Error(`Chat open not confirmed: ${code}`);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1161
1169
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
1162
1170
|
var external_exports = {};
|
|
1163
1171
|
__export(external_exports, {
|
|
@@ -8578,16 +8586,18 @@ async function processUnreadChat(client, chat, lastSeenId, equalCursorUnreadHand
|
|
|
8578
8586
|
});
|
|
8579
8587
|
let opened = false;
|
|
8580
8588
|
const openChatIfNeeded = async () => {
|
|
8581
|
-
if (skipOpen || opened) return;
|
|
8582
|
-
opened = true;
|
|
8589
|
+
if (skipOpen || opened) return true;
|
|
8583
8590
|
log?.info?.(`[wechat:${liveAccount.accountId}] Opening chat ${chatId}...`);
|
|
8584
8591
|
try {
|
|
8585
|
-
await client.openChat(chatId, true);
|
|
8592
|
+
requireVerifiedChatOpen(await client.openChat(chatId, true), chatId);
|
|
8593
|
+
opened = true;
|
|
8586
8594
|
log?.info?.(`[wechat:${liveAccount.accountId}] Opened chat ${chatId}`);
|
|
8595
|
+
return true;
|
|
8587
8596
|
} catch (err) {
|
|
8588
8597
|
log?.error?.(
|
|
8589
8598
|
`[wechat:${liveAccount.accountId}] Failed to open chat ${chatId}: ${err}`
|
|
8590
8599
|
);
|
|
8600
|
+
return false;
|
|
8591
8601
|
}
|
|
8592
8602
|
};
|
|
8593
8603
|
const firstPoll = !lastSeenId.has(chatId);
|