fix(onebot): allow clearing the self signature

Accept explicit empty strings from both longNick and long_nick when callers need to clear the bot signature. Missing and non-string values remain rejected before reaching the bridge.

Preserve the QQ-compatible clear representation by omitting the empty profile value, and add action-level and wire-level regression coverage. Live verification confirmed successful clearing and readback on the test bot.

Fixes #247
This commit is contained in:
DrSmoothl committed 2026-07-19 18:12:48 +08:00
1 parent 65e819d96e
commit f3e0c4e45a
3 files changed
+47 -1

No files matched your search

@@ -36,6 +36,13 @@ describe('SetSelfLongNick namespace', () => {
expect(env.body?.profile).toEqual({ tag: 102, value: 'hello world' });
});
it('omits the value field when clearing the signature', async () => {
const deps = makeDeps();
await SetSelfLongNick.invoke(deps, { longNick: '' });
const [, bytes] = deps.sendRawPacket.mock.calls[0]!;
expect(Buffer.from(bytes).toString('hex')).toBe('08aa221002220708914e12020866');
});
it('coerces non-string longNick into a string (defensive)', async () => {
const deps = makeDeps();
// simulate a misbehaving caller passing a number