@zhin.js/adapter-qq 6.0.6 → 6.0.7
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/CHANGELOG.md +8 -0
- package/lib/protocol.d.ts +4 -2
- package/lib/ws.js +6 -3
- package/package.json +4 -4
- package/src/protocol.ts +4 -2
- package/src/ws.ts +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @zhin.js/adapter-qq
|
|
2
2
|
|
|
3
|
+
## 6.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7249733: fix(qq): 群消息 @ 判定改为统一按 mentions 检查,不再按 channelKind 直接视为 @
|
|
8
|
+
|
|
9
|
+
`GROUP_MESSAGE_CREATE` 与 `GROUP_AT_MESSAGE_CREATE` 在 SDK 中都映射为 `message.group`,前者会下发非 @ 的普通群消息;此前 `channelKind === 'group'` 一律置 `mentioned`,导致所有群消息都触发 AI。现统一按 `mentions` 判定:群场景只认 `is_you === true`(精确标识当前机器人;群里 @ 另一个机器人时 `bot: true` 但无 `is_you`,不误判),`bot === true` 回退仅限频道 `AT_MESSAGE_CREATE`(该事件仅 @ 当前机器人时下发,mentions 无 `is_you`)。非 @ 群消息将回到旁听(Passive Group Context)路径。
|
|
10
|
+
|
|
3
11
|
## 6.0.6
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/lib/protocol.d.ts
CHANGED
|
@@ -66,8 +66,10 @@ export interface QqInboundMessage {
|
|
|
66
66
|
readonly guildId?: string;
|
|
67
67
|
readonly rawMessage?: string;
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
69
|
+
* 入站是否 @ 当前机器人:统一按 mentions 判定。群场景只认 is_you(@ 另一个
|
|
70
|
+
* 机器人时 bot:true 但无 is_you,不误判);bot 回退仅限频道 AT 事件。
|
|
71
|
+
* 群 GROUP_MESSAGE_CREATE 的非 @ 消息不置位。新 Runtime 纯文本 content 需经
|
|
72
|
+
* metadata 传递。
|
|
71
73
|
*/
|
|
72
74
|
readonly mentioned?: boolean;
|
|
73
75
|
}
|
package/lib/ws.js
CHANGED
|
@@ -63,9 +63,12 @@ export function normalizeQqMessage(raw) {
|
|
|
63
63
|
const content = extractTextContent(msg.message) || msg.raw_message || '';
|
|
64
64
|
const rawRoles = msg.member?.roles ?? msg.sender?.roles;
|
|
65
65
|
const authorRoles = Array.isArray(rawRoles) ? rawRoles.map(String) : undefined;
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
// 统一按 mentions 判定 @:is_you 精确标识当前机器人(群载荷实测字段)。
|
|
67
|
+
// 群里 @ 另一个机器人时 mentions 带 bot:true 但无 is_you,不能误判为 @ 当前机器人,
|
|
68
|
+
// 故群场景只认 is_you;bot 回退仅限频道 AT_MESSAGE_CREATE(该事件仅 @ 当前
|
|
69
|
+
// 机器人时下发,其 mentions 无 is_you)。
|
|
70
|
+
const mentioned = Array.isArray(msg.mentions)
|
|
71
|
+
&& msg.mentions.some((m) => m?.is_you === true || (m?.bot === true && channelKind !== 'group'));
|
|
69
72
|
return {
|
|
70
73
|
id: String(msg.message_id),
|
|
71
74
|
content,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-qq",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.7",
|
|
4
4
|
"description": "Zhin.js QQ Official adapter for Plugin Runtime (WebSocket gateway)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"qq-official-bot": "^1.2.3",
|
|
38
38
|
"@zhin.js/adapter": "1.1.2",
|
|
39
39
|
"@zhin.js/command": "1.0.4",
|
|
40
|
+
"@zhin.js/logger": "1.0.75",
|
|
40
41
|
"@zhin.js/core": "1.4.3",
|
|
41
42
|
"@zhin.js/host-http": "1.0.4",
|
|
42
|
-
"@zhin.js/logger": "1.0.75",
|
|
43
43
|
"@zhin.js/plugin-runtime": "1.1.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@zhin.js/adapter": "1.1.2",
|
|
48
48
|
"@zhin.js/agent": "1.0.10",
|
|
49
49
|
"@zhin.js/core": "1.4.3",
|
|
50
|
-
"
|
|
51
|
-
"zhin.js": "
|
|
50
|
+
"zhin.js": "5.0.3",
|
|
51
|
+
"@zhin.js/plugin-runtime": "1.1.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"zhin.js": {
|
package/src/protocol.ts
CHANGED
|
@@ -77,8 +77,10 @@ export interface QqInboundMessage {
|
|
|
77
77
|
readonly guildId?: string;
|
|
78
78
|
readonly rawMessage?: string;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
80
|
+
* 入站是否 @ 当前机器人:统一按 mentions 判定。群场景只认 is_you(@ 另一个
|
|
81
|
+
* 机器人时 bot:true 但无 is_you,不误判);bot 回退仅限频道 AT 事件。
|
|
82
|
+
* 群 GROUP_MESSAGE_CREATE 的非 @ 消息不置位。新 Runtime 纯文本 content 需经
|
|
83
|
+
* metadata 传递。
|
|
82
84
|
*/
|
|
83
85
|
readonly mentioned?: boolean;
|
|
84
86
|
}
|
package/src/ws.ts
CHANGED
|
@@ -94,8 +94,8 @@ export function normalizeQqMessage(raw: unknown): QqInboundMessage | null {
|
|
|
94
94
|
sender?: { user_id?: string | number; user_name?: string; roles?: (string | number)[] };
|
|
95
95
|
member?: { roles?: (string | number)[] };
|
|
96
96
|
author?: { member_openid?: string; user_openid?: string; id?: string; username?: string };
|
|
97
|
-
/**
|
|
98
|
-
mentions?: Array<{ id?: string | number; bot?: boolean }>;
|
|
97
|
+
/** AT 事件载荷:被 @ 的用户列表;is_you 标识当前机器人,bot 标识机器人账号 */
|
|
98
|
+
mentions?: Array<{ id?: string | number; bot?: boolean; is_you?: boolean; member_openid?: string; member_role?: string }>;
|
|
99
99
|
};
|
|
100
100
|
if (msg.message_id == null) return null;
|
|
101
101
|
|
|
@@ -132,9 +132,12 @@ export function normalizeQqMessage(raw: unknown): QqInboundMessage | null {
|
|
|
132
132
|
const content = extractTextContent(msg.message) || msg.raw_message || '';
|
|
133
133
|
const rawRoles = msg.member?.roles ?? msg.sender?.roles;
|
|
134
134
|
const authorRoles = Array.isArray(rawRoles) ? rawRoles.map(String) : undefined;
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
// 统一按 mentions 判定 @:is_you 精确标识当前机器人(群载荷实测字段)。
|
|
136
|
+
// 群里 @ 另一个机器人时 mentions 带 bot:true 但无 is_you,不能误判为 @ 当前机器人,
|
|
137
|
+
// 故群场景只认 is_you;bot 回退仅限频道 AT_MESSAGE_CREATE(该事件仅 @ 当前
|
|
138
|
+
// 机器人时下发,其 mentions 无 is_you)。
|
|
139
|
+
const mentioned = Array.isArray(msg.mentions)
|
|
140
|
+
&& msg.mentions.some((m) => m?.is_you === true || (m?.bot === true && channelKind !== 'group'));
|
|
138
141
|
|
|
139
142
|
return {
|
|
140
143
|
id: String(msg.message_id),
|