aai-lark-bridge 0.2.43 → 0.2.45
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/cli.js +36 -7
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Command } from "commander";
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "aai-lark-bridge",
|
|
7
|
-
version: "0.2.
|
|
7
|
+
version: "0.2.45",
|
|
8
8
|
description: "Lark AI Native Bridge - Lark\u57FA\u7840\u8BBE\u65BD\u5C42\u548CCLI\u96C6\u6210",
|
|
9
9
|
type: "module",
|
|
10
10
|
main: "./dist/index.js",
|
|
@@ -15336,6 +15336,35 @@ async function removeReaction(channel, messageId, reactionId) {
|
|
|
15336
15336
|
var POSITIVE_EMOJIS = /* @__PURE__ */ new Set(["OK", "THUMBSUP", "DONE", "JIAYI", "LGTM"]);
|
|
15337
15337
|
var CONFIRM_WINDOW_MS = 45 * 6e4;
|
|
15338
15338
|
var SCOPE_MAX = 500;
|
|
15339
|
+
function extractText(content) {
|
|
15340
|
+
if (!content) return "";
|
|
15341
|
+
let tree;
|
|
15342
|
+
try {
|
|
15343
|
+
tree = JSON.parse(content);
|
|
15344
|
+
} catch {
|
|
15345
|
+
return content;
|
|
15346
|
+
}
|
|
15347
|
+
if (tree && typeof tree === "object" && tree.schema === "2.0") {
|
|
15348
|
+
const elements = tree.body?.elements;
|
|
15349
|
+
const parts = [];
|
|
15350
|
+
if (Array.isArray(elements)) {
|
|
15351
|
+
for (const el of elements) {
|
|
15352
|
+
const e = el;
|
|
15353
|
+
if (e?.tag === "markdown" && typeof e.content === "string" && e.text_size !== "notation") parts.push(e.content);
|
|
15354
|
+
}
|
|
15355
|
+
}
|
|
15356
|
+
return parts.join("\n");
|
|
15357
|
+
}
|
|
15358
|
+
const out = [];
|
|
15359
|
+
const walk = (v, key) => {
|
|
15360
|
+
if (typeof v === "string") {
|
|
15361
|
+
if (key === "text" || key === "content" || key === "title") out.push(v);
|
|
15362
|
+
} else if (Array.isArray(v)) v.forEach((x) => walk(x, key));
|
|
15363
|
+
else if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) walk(x, k);
|
|
15364
|
+
};
|
|
15365
|
+
walk(tree);
|
|
15366
|
+
return out.join("\n");
|
|
15367
|
+
}
|
|
15339
15368
|
function isConfirmQuestion(text) {
|
|
15340
15369
|
const tail = text.trim().split(/[。!!\n]/).map((s) => s.trim()).filter(Boolean).pop() ?? "";
|
|
15341
15370
|
return /[??]$/.test(tail) && /吗|是否|要不要|可不可以|对不对|行不行|可以不/.test(tail);
|
|
@@ -15371,20 +15400,20 @@ var ReactionConfirmer = class {
|
|
|
15371
15400
|
if (this.used.has(evt.messageId)) return reject4("already-used");
|
|
15372
15401
|
let bot;
|
|
15373
15402
|
try {
|
|
15374
|
-
bot = await channel.
|
|
15403
|
+
bot = (await channel.fetchRawMessage(evt.messageId, { cardContentType: "user_card_content" }))[0];
|
|
15375
15404
|
} catch (err) {
|
|
15376
15405
|
log.warn("reaction-confirm", "fetch-failed", { messageId: evt.messageId, err: String(err) });
|
|
15377
15406
|
return void 0;
|
|
15378
15407
|
}
|
|
15379
|
-
if (!bot) return reject4("message-not-found");
|
|
15380
|
-
if (bot.
|
|
15381
|
-
const parentId = bot.
|
|
15408
|
+
if (!bot?.message_id) return reject4("message-not-found");
|
|
15409
|
+
if (bot.sender?.sender_type !== "app" && bot.sender?.sender_type !== "bot") return reject4("not-bot-message");
|
|
15410
|
+
const parentId = bot.parent_id;
|
|
15382
15411
|
const handled = parentId ? this.byUserMsg.get(parentId) : void 0;
|
|
15383
15412
|
if (!handled || !parentId) return reject4("not-reply-to-handled-message");
|
|
15384
15413
|
if (this.latestByScope.get(handled.scope) !== parentId) return reject4("not-latest");
|
|
15385
|
-
if (handled.msg.chatId !== bot.
|
|
15414
|
+
if (handled.msg.chatId !== bot.chat_id) return reject4("chat-mismatch");
|
|
15386
15415
|
if (evt.operator.openId !== handled.msg.senderId) return reject4("not-asker");
|
|
15387
|
-
if (!isConfirmQuestion(bot.content)) return reject4("not-a-question");
|
|
15416
|
+
if (!isConfirmQuestion(extractText(bot.body?.content))) return reject4("not-a-question");
|
|
15388
15417
|
const t = this.now();
|
|
15389
15418
|
if (t - handled.msg.createTime > CONFIRM_WINDOW_MS) return reject4("expired");
|
|
15390
15419
|
this.used.add(evt.messageId);
|