fix(onebot): trace empty text placeholder normalization
Document the compatibility rule in action metadata and regenerate the MCP catalog.
This commit is contained in:
4 files changed
+63
-54
No files matched your search
@@ -323,7 +323,13 @@ export const f = {
|
||||
}
|
||||
}
|
||||
return ok(raw);
|
||||
}, { type: 'message', required: true, schema: { description: 'OneBot message: string | segment[] | object' } });
|
||||
}, {
|
||||
type: 'message',
|
||||
required: true,
|
||||
schema: {
|
||||
description: 'OneBot message: string | segment[] | object. In segment arrays, text segments whose text field is exactly "" are compatibility placeholders and do not count as sendable segments; missing, null, and whitespace-only text remain subject to normal validation.',
|
||||
},
|
||||
});
|
||||
},
|
||||
/** Homogeneous array; `.nonEmpty()` rejects []. */
|
||||
array<E>(el: Field<E>): Field<E[]> & { nonEmpty(): Field<E[]> } {
|
||||
|
||||
@@ -411,7 +411,10 @@ export async function parseMessage(message: JsonValue, autoEscape: boolean, opti
|
||||
// Some OneBot clients insert empty text between media as a separator.
|
||||
// Only the exact empty string is a no-op; malformed and whitespace text
|
||||
// must still pass through strict element validation.
|
||||
if (seg.type.trim().toLowerCase() === 'text' && data.text === '') continue;
|
||||
if (seg.type.trim().toLowerCase() === 'text' && data.text === '') {
|
||||
log.debug('ignored explicit empty text placeholder in message segment array');
|
||||
continue;
|
||||
}
|
||||
const elem = await segmentToElement(seg.type, data, options);
|
||||
if (elem) elements.push(elem);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user