fix(onebot): identify QQ automatic replies in private messages
Refs #663
This commit is contained in:
17 files changed
+128
-6
No files matched your search
@@ -112,6 +112,28 @@ describe('convertEvent — message kinds', () => {
|
||||
expect(out!.message_id).toBe(PEER_UIN + 1);
|
||||
});
|
||||
|
||||
it.each([makeFriendMessage(PEER_UIN), makeTempMessage(PEER_UIN)])(
|
||||
'exposes only QQ-marked auto replies in $kind',
|
||||
async (event) => {
|
||||
const manual = await convertEvent(bareCtx(), {
|
||||
...event,
|
||||
elements: [{ type: 'text', text: '[自动回复] 稍后联系' }],
|
||||
});
|
||||
const automatic = await convertEvent(bareCtx(), { ...event, autoReply: true });
|
||||
|
||||
expect(manual).toMatchObject({
|
||||
message: [{ type: 'text', data: { text: '[自动回复] 稍后联系' } }],
|
||||
raw_message: '[自动回复] 稍后联系',
|
||||
});
|
||||
expect(manual).not.toHaveProperty('auto_reply');
|
||||
expect(automatic).toMatchObject({
|
||||
auto_reply: true,
|
||||
message: [{ type: 'text', data: { text: 'hi' } }],
|
||||
raw_message: 'hi',
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it('group_message peer → post_type "message", sub_type "normal", group_id set', async () => {
|
||||
const out = await convertEvent(bareCtx(), makeGroupMessage(PEER_UIN));
|
||||
expect(out!.post_type).toBe('message');
|
||||
|
||||
@@ -137,7 +137,7 @@ describe('history direction plumbing', () => {
|
||||
it('uses C2C roaming for an unanchored latest page and ignores a stale local sequence', async () => {
|
||||
const fetchRangeHistory = vi.fn(async () => [friendMessage(99999, FRIEND_ID)]);
|
||||
const fetchLatestHistory = vi.fn(async () => [
|
||||
friendMessage(63213, FRIEND_ID, 32742),
|
||||
{ ...friendMessage(63213, FRIEND_ID, 32742), autoReply: true },
|
||||
friendMessage(63214, SELF_ID, 32743),
|
||||
]);
|
||||
await messageStore.storeMeta(-222222222, {
|
||||
@@ -169,6 +169,12 @@ describe('history direction plumbing', () => {
|
||||
|
||||
expect(fetchLatestHistory).toHaveBeenCalledWith('u_friend', 20, SELF_ID);
|
||||
expect(fetchRangeHistory).not.toHaveBeenCalled();
|
||||
expect(messages[0]).toMatchObject({ auto_reply: true, raw_message: '63213' });
|
||||
expect(messages[1]).not.toHaveProperty('auto_reply');
|
||||
expect(await messageStore.findEvent(Number(messages[0]!.message_id))).toMatchObject({
|
||||
auto_reply: true,
|
||||
raw_message: '63213',
|
||||
});
|
||||
expect(
|
||||
messages.map((message) => ({
|
||||
sender: message.user_id,
|
||||
|
||||
Reference in new issue
Block a user