From 2c3d2abd950ebe0ff127074103722cff34cce9b9 Mon Sep 17 00:00:00 2001 From: sunlei Date: Sat, 13 Jun 2026 13:40:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=BE=E5=AE=BDNapCat=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81=E6=97=A5=E5=BF=97=E8=AF=BB=E5=8F=96=E8=B6=85?= =?UTF-8?q?=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../napcat/qqbot-napcat-container.service.ts | 6 +++- .../napcat/qqbot-napcat-captcha-log.spec.ts | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/qqbot/napcat/qqbot-napcat-container.service.ts b/src/qqbot/napcat/qqbot-napcat-container.service.ts index f40a55f..0b6833a 100644 --- a/src/qqbot/napcat/qqbot-napcat-container.service.ts +++ b/src/qqbot/napcat/qqbot-napcat-container.service.ts @@ -492,7 +492,7 @@ docker inspect --format '{{range .Config.Env}}{{println .}}{{end}}' "$NAME" [...this.getSshArgs(), 'sh -s'], script, undefined, - this.getRuntimeCheckTimeoutMs(), + this.getCaptchaLogReadTimeoutMs(), ); return this.toolsService.extractNapcatCaptchaUrl(result.stdout) || null; } catch { @@ -1281,6 +1281,10 @@ ${accountRunFlag}${passwordRunFlag} -p "$PORT:6099" \\ return Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : 5000; } + private getCaptchaLogReadTimeoutMs() { + return Math.max(this.getRuntimeCheckTimeoutMs(), 15000); + } + private sh(value: string) { return `'${`${value}`.replace(/'/g, `'\\''`)}'`; } diff --git a/test/qqbot/napcat/qqbot-napcat-captcha-log.spec.ts b/test/qqbot/napcat/qqbot-napcat-captcha-log.spec.ts index 879949e..e6f3815 100644 --- a/test/qqbot/napcat/qqbot-napcat-captcha-log.spec.ts +++ b/test/qqbot/napcat/qqbot-napcat-captcha-log.spec.ts @@ -61,4 +61,32 @@ describe('QqbotNapcatContainerService captcha logs', () => { 'https://ti.qq.com/safe/tools/captcha/sms-verify-login?uin=10001&sid=abc', ); }); + + it('uses a longer timeout for captcha log reads than the quick runtime check', async () => { + const service = new QqbotNapcatContainerService( + { + get: jest.fn((key: string) => + key === 'QQBOT_NAPCAT_CONTAINER_MODE' ? 'ssh' : '', + ), + } as any, + { update: jest.fn() } as any, + {} as any, + new ToolsService(), + ); + const runProcess = jest.spyOn(service as any, 'runProcess').mockResolvedValue({ + stderr: '', + stdout: + '需要验证码, proofWaterUrl: https://ti.qq.com/safe/tools/captcha/sms-verify-login?uin=10001\n', + }); + + await service.detectRuntimeCaptchaUrl( + { + id: 'container-1', + name: 'napcat-10001', + } as any, + Date.now(), + ); + + expect(runProcess.mock.calls[0]?.[4]).toBeGreaterThanOrEqual(15000); + }); });