mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 04:13:17 +08:00
feat(feishu): add configurable group response mode
This commit is contained in:
parent
1a86fa5013
commit
9950261a49
19 changed files with 615 additions and 150 deletions
|
|
@ -108,6 +108,7 @@ function fixture({
|
|||
stops: 0,
|
||||
sentTests: [],
|
||||
probes: [],
|
||||
responseModes: [],
|
||||
repair,
|
||||
get status() { return structuredClone(status); },
|
||||
async start() {
|
||||
|
|
@ -126,6 +127,10 @@ function fixture({
|
|||
runtime.sentTests.push(text);
|
||||
return { sent: true };
|
||||
},
|
||||
setGroupResponseMode(mode) {
|
||||
runtime.responseModes.push(mode);
|
||||
runtime.config.groupResponseMode = mode;
|
||||
},
|
||||
async beginCardActionProbe(options) {
|
||||
runtime.probes.push(structuredClone(options));
|
||||
if (callbackProbe) return callbackProbe({ botId, runtime, options });
|
||||
|
|
@ -184,6 +189,29 @@ test('QR registration separates events from card callbacks', async () => {
|
|||
await fx.controller.close();
|
||||
});
|
||||
|
||||
test('group response mode defaults to mention and updates the live runtime without reconnecting', async () => {
|
||||
const existing = bot('bot_response_mode', 'response_mode');
|
||||
const fx = fixture({
|
||||
bots: [existing],
|
||||
secrets: { [existing.secretRef]: 'stable-secret' },
|
||||
});
|
||||
await fx.controller.initialize();
|
||||
|
||||
assert.equal(fx.controller.status().bots[0].groupResponseMode, 'mention');
|
||||
const runtime = fx.runtimes.get(existing.id)[0];
|
||||
const updated = await fx.controller.updateGroupResponseMode(existing.id, 'all');
|
||||
|
||||
assert.equal(updated.bots[0].groupResponseMode, 'all');
|
||||
assert.equal(fx.configStore.getBot(existing.id).groupResponseMode, 'all');
|
||||
assert.deepEqual(runtime.responseModes, ['all']);
|
||||
assert.equal(fx.runtimes.get(existing.id).length, 1);
|
||||
await assert.rejects(
|
||||
fx.controller.updateGroupResponseMode(existing.id, 'sometimes'),
|
||||
/Invalid Feishu group response mode/,
|
||||
);
|
||||
await fx.controller.close();
|
||||
});
|
||||
|
||||
test('callback repair is deduplicated per bot, updates only its secret, and proves the callback', async () => {
|
||||
const existing = bot('bot_existing', 'existing');
|
||||
const fx = fixture({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue