feat: add stable proactive delivery

This commit is contained in:
xmanrui 2026-08-30 11:24:53 +08:00
parent 410cb822d7
commit 31792d7bc8
88 changed files with 6427 additions and 488 deletions

View file

@ -97,6 +97,7 @@ test('QQ controller delegates the shared connection-test message to the selected
botId: 'qq_bot', appId: 'app-id', secretRef: 'qq.secret', ownerUserOpenid: 'owner-openid',
};
const sent = [];
const proactiveSends = [];
const controller = new QqController({
qrAuth: { start() { return () => {}; } },
credentials: {
@ -116,6 +117,10 @@ test('QQ controller delegates the shared connection-test message to the selected
start: async () => {},
stop: async () => {},
sendConnectionTest: async (text) => sent.push(text),
sendProactiveText: async (...args) => {
proactiveSends.push(args);
return { sent: true };
},
}),
});
@ -124,6 +129,11 @@ test('QQ controller delegates the shared connection-test message to the selected
assert.deepEqual(sent, [
connectionTestMessage(`QQ 机器人(${maskQqAppId(config.appId)})`),
]);
const target = { kind: 'user', route: { userOpenId: 'user-openid' } };
assert.deepEqual(await controller.sendProactiveText(config.botId, target, '主动投递'), {
sent: true,
});
assert.deepEqual(proactiveSends, [[target, '主动投递', {}]]);
await controller.close();
});

View file

@ -98,6 +98,14 @@ test('QQ runtime sends a proactive connection test to the explicit owner fallbac
target: { scope: 'c2c', targetId: 'owner-openid' },
text: 'connection-test',
}]);
await runtime.sendProactiveText({
kind: 'group',
route: { groupOpenId: 'group-openid' },
}, 'proactive-test');
assert.deepEqual(bot.sent[1], {
target: { scope: 'group', targetId: 'group-openid' },
text: 'proactive-test',
});
await runtime.stop();
});