fix(onebot): distinguish private poke conversations
Preserve the private conversation peer separately from the poke sender and target. Emit NapCat-compatible user_id and sender_id fields while keeping group notices unchanged. Add MsgPush and event-converter regression coverage for self-pokes across multiple friend sessions. Fixes #285.
This commit is contained in:
7 files changed
+126
-13
No files matched your search
@@ -111,7 +111,8 @@ export function convertFriendPoke(ctx: ConverterContext, event: FriendPoke): Jso
|
||||
return notice(ctx, event, {
|
||||
notice_type: 'notify',
|
||||
sub_type: 'poke',
|
||||
user_id: event.userUin,
|
||||
user_id: event.peerUin,
|
||||
sender_id: event.senderUin,
|
||||
target_id: event.targetUin,
|
||||
action: event.action,
|
||||
suffix: event.suffix,
|
||||
|
||||
@@ -253,16 +253,25 @@ describe('convertEvent — notice kinds', () => {
|
||||
expect(out!.message_id).toBe(99);
|
||||
});
|
||||
|
||||
it('friend_poke: notice/notify/poke with target_id + action fields', async () => {
|
||||
it('friend_poke: identifies the private peer, sender, and target independently', async () => {
|
||||
const out = await convertEvent(bareCtx(), {
|
||||
kind: 'friend_poke', time: 1, selfUin: SELF_ID,
|
||||
userUin: PEER_UIN, targetUin: SELF_ID,
|
||||
peerUin: PEER_UIN, senderUin: SELF_ID, targetUin: SELF_ID,
|
||||
action: '戳了戳', suffix: '一下', actionImgUrl: 'http://x',
|
||||
} as QQEventVariant);
|
||||
expect(out!.notice_type).toBe('notify');
|
||||
expect(out!.sub_type).toBe('poke');
|
||||
expect(out!.target_id).toBe(SELF_ID);
|
||||
expect(out!.action).toBe('戳了戳');
|
||||
expect(out).toEqual({
|
||||
time: 1,
|
||||
self_id: SELF_ID,
|
||||
post_type: 'notice',
|
||||
notice_type: 'notify',
|
||||
sub_type: 'poke',
|
||||
user_id: PEER_UIN,
|
||||
sender_id: SELF_ID,
|
||||
target_id: SELF_ID,
|
||||
action: '戳了戳',
|
||||
suffix: '一下',
|
||||
action_img_url: 'http://x',
|
||||
});
|
||||
});
|
||||
|
||||
it('group_poke: same shape as friend_poke + group_id', async () => {
|
||||
|
||||
Reference in new issue
Block a user