From 9d96f78921bfbd9c19e6959b8fef58a0477fc3ed Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 9 May 2025 22:42:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AA=E7=8E=AF=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/bot/bot.service.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/bot/bot.service.ts b/src/modules/bot/bot.service.ts index ac63dba..944dc58 100644 --- a/src/modules/bot/bot.service.ts +++ b/src/modules/bot/bot.service.ts @@ -115,22 +115,27 @@ class BotService { const userPath = paths.get('userData'); const botsPath = path.join(userPath, '/crystelfBots'); const dirData = await fs.readdir(botsPath); + for (const clientId of dirData) { if (!clientId.endsWith('.json')) continue; + try { const raw: | { uin: number; groups: { group_id: number; group_name: string }[]; nickName: string }[] | undefined = await redisService.fetch('crystelfBots', clientId); if (!raw) continue; - raw.forEach((bot) => { + + for (const bot of raw) { if (bot.uin && bot.groups) { - if (bot.groups.find((group) => group.group_id == groupId)) return bot.uin; + const found = bot.groups.find((group) => group.group_id == groupId); + if (found) return bot.uin; } - }); + } } catch (err) { logger.error(`读取${clientId}出错..`); } } + return undefined; } }