@lih-x-x/kmr 1.0.17 → 1.0.18
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 +9 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19,7 +19,8 @@ async function getBotOpenId(client) {
|
|
|
19
19
|
method: "GET",
|
|
20
20
|
url: "/open-apis/bot/v3/info"
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
console.log(`[bot] bot info response:`, JSON.stringify(res?.data || res, null, 2));
|
|
23
|
+
const openId = res.data?.bot?.open_id || res.bot?.open_id || "";
|
|
23
24
|
if (openId) {
|
|
24
25
|
console.log(`[bot] \u673A\u5668\u4EBA open_id: ${openId}`);
|
|
25
26
|
} else {
|
|
@@ -66,7 +67,13 @@ function createEventDispatcher(botOpenId, onMessage) {
|
|
|
66
67
|
let text = content.text || "";
|
|
67
68
|
const chatId = message.chat_id;
|
|
68
69
|
const mentions = message.mentions || [];
|
|
69
|
-
|
|
70
|
+
if (mentions.length > 0) {
|
|
71
|
+
console.log(`[recv] mentions:`, JSON.stringify(mentions));
|
|
72
|
+
}
|
|
73
|
+
const isMentioned = mentions.length > 0 && (!botOpenId || mentions.some((m) => {
|
|
74
|
+
const mentionOpenId = m.id?.open_id || m.id_str || "";
|
|
75
|
+
return mentionOpenId === botOpenId;
|
|
76
|
+
}));
|
|
70
77
|
const isGroup = message.chat_type === "group";
|
|
71
78
|
if (mentions.length > 0) {
|
|
72
79
|
for (const mention of mentions) {
|