fix(onebot): reject ambiguous video message combinations

Prevent ordinary messages and forwarded nodes from combining video content with visible sibling segments or additional videos. Invalid combinations now fail before parsing side effects, media work, or bridge sends, while exact empty text placeholders remain compatible with a single video.

Cover group, private, temporary-session, CQ string, nested forward, cached forward, and protocol-builder paths. Preserve the existing standalone window-shake behavior and keep valid single-video messages unchanged.
This commit is contained in:
DrSmoothl committed 2026-08-05 23:55:55 +08:00
1 parent 2ac0b92859
commit 27c527976b
8 files changed
+371 -29

No files matched your search

@@ -81,6 +81,22 @@ describe('private window shake messages', () => {
expect(sendPrivate).not.toHaveBeenCalled();
});
it('keeps empty text significant for the standalone window-shake policy', async () => {
const sendPrivate = vi.fn(async () => ({ ...receipt, clientSequence: 9 }));
const ctx = makeContext({ sendPrivate });
await expect(sendPrivateMessage(ctx, 67890, [
{ type: 'poke', data: { type: 1 } },
{ type: 'text', data: { text: '' } },
], false)).rejects.toMatchObject({
code: 'UNSENDABLE_TYPE',
elementType: 'poke',
message: expect.stringContaining('only segment'),
});
expect(sendPrivate).not.toHaveBeenCalled();
});
it('rejects group window shakes before resolving an earlier segment', async () => {
const sendGroup = vi.fn(async () => receipt);
const ctx = makeContext({ sendGroup });