diff --git a/packages/onebot/src/actions/extended.ts b/packages/onebot/src/actions/extended.ts index 2ebc02b0..d8d04338 100644 --- a/packages/onebot/src/actions/extended.ts +++ b/packages/onebot/src/actions/extended.ts @@ -1230,6 +1230,12 @@ export const actions = [ { rkey?: string; ttl?: number } | undefined; const priv = pick(10); const group = pick(20); + // No rkey at all → fail rather than hand back an "expired_time = now, + // no keys" shell that a caching caller would misread as a valid-but-empty + // (already-expired) result. + if (!priv?.rkey && !group?.rkey) { + return failedResponse(RETCODE.ACTION_FAILED, 'no download rkey available'); + } const ttls = [priv?.ttl, group?.ttl].filter((t): t is number => typeof t === 'number' && t > 0); const minTtl = ttls.length ? Math.min(...ttls) : 0; const data: JsonObject = { diff --git a/packages/onebot/src/actions/group-file.ts b/packages/onebot/src/actions/group-file.ts index 177c1405..e785fb40 100644 --- a/packages/onebot/src/actions/group-file.ts +++ b/packages/onebot/src/actions/group-file.ts @@ -112,6 +112,8 @@ export const actions = [ }, run: async (p, ctx) => { await ctx.bridge.apis.groupFile.rename(p.group_id, p.file_id, p.current_parent_directory || '/', p.new_name); + // {ok:true} 刻意对齐 NapCat RenameGroupFile 的返回体,偏离 SnowLuma 同类 + // 文件写操作(move/delete 返回空 data)——为 NapCat 客户端 drop-in 兼容。 return okResponse({ ok: true }); }, }), diff --git a/packages/onebot/tests/extended-actions.test.ts b/packages/onebot/tests/extended-actions.test.ts index 69089577..e7432c69 100644 --- a/packages/onebot/tests/extended-actions.test.ts +++ b/packages/onebot/tests/extended-actions.test.ts @@ -744,4 +744,10 @@ describe('extended-actions / get_rkey_server', () => { expect(d.private_rkey).toBe('&rkey=PRIV'); expect(d.group_rkey).toBeUndefined(); }); + + it('fails (not an expired empty shell) when no rkey is available', async () => { + const getDownloadRKeys = vi.fn(async () => []); + const res = await makeHandler(fakeCtx(fakeBridge(), { getDownloadRKeys })).handle('get_rkey_server', {}); + expect(res).toMatchObject({ status: 'failed', retcode: 100 }); + }); });