fix(onebot): identify QQ automatic replies in private messages

Refs #663
This commit is contained in:
DrSmoothl committed 2026-11-06 22:49:52 +08:00
1 parent e031cd4108
commit b0612d8d12
17 files changed
+128 -6

No files matched your search

@@ -62,6 +62,14 @@ export const messageDataSchema = {
additionalProperties: true,
} satisfies JsonSchema;
export const messageWithAutoReplySchema = {
...messageDataSchema,
properties: {
...messageDataSchema.properties,
auto_reply: { const: true, description: '仅当 QQ 标记该私聊消息为自动回复时提供' },
},
} satisfies JsonSchema;
// Forward nodes carry their original identifiers, not locally hashed message IDs.
export const forwardNodeSchema: JsonSchema = {
...messageDataSchema,
+2 -1
View File
@@ -27,6 +27,7 @@ import { GROUP_MESSAGE_EVENT, hashMessageIdInt32 } from '../message-id';
import {
messageIdSchema,
messageDataSchema,
messageWithAutoReplySchema,
forwardNodeSchema,
messageSegmentSchema,
mediaInfoSchema,
@@ -1039,7 +1040,7 @@ export const actions = [
messages: {
type: 'array',
description: '消息对象数组;去除 post_type/self_id,附带 real_id',
items: messageDataSchema,
items: messageWithAutoReplySchema,
},
},
required: ['messages'],
+6 -2
View File
@@ -2,7 +2,11 @@ import { createLogger } from '@snowluma/common/logger';
import type { JsonObject, JsonValue } from '../types';
import { defineAction, groupAction, f, type Field } from '../action-kit';
import { RETCODE, failedResponse, okResponse } from '../types';
import { messageResultSchema, messageIdSchema, messageDataSchema } from '../action-result-schemas';
import {
messageResultSchema,
messageIdSchema,
messageWithAutoReplySchema,
} from '../action-result-schemas';
/** send_msg only (#426). Some clients send `group_id: ""` on private chats.
* Treat that exact empty string as absent. Do not change `f.groupId()`. */
@@ -210,7 +214,7 @@ export const actions = [
],
returnsSchema: {
allOf: [
messageDataSchema,
messageWithAutoReplySchema,
{
type: 'object',
properties: {
@@ -89,6 +89,10 @@ async function convertPrivateMessage(
sender,
};
if (event.autoReply) {
fields.auto_reply = true;
}
if (isSelf && sessionId > 0 && sessionId !== ctx.selfId) {
fields.target_id = sessionId;
}