mirror of
https://github.com/crystelf/crystelf-core.git
synced 2025-07-04 14:49:19 +00:00
优化算法
This commit is contained in:
parent
86f8a04112
commit
d4035acd43
@ -34,11 +34,11 @@ class BotService {
|
|||||||
logger.warn(`解析 ${fileName} 出错: ${e}`);
|
logger.warn(`解析 ${fileName} 出错: ${e}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (const bot of botList) {
|
botList.forEach((bot) => {
|
||||||
if (bot.uin && bot.nickName) {
|
if (bot.uin && bot.nickName) {
|
||||||
uins.push({ uin: bot.uin, nickName: bot.nickName });
|
uins.push({ uin: bot.uin, nickName: bot.nickName });
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(`读取或解析 ${fileName} 出错: ${err}`);
|
logger.error(`读取或解析 ${fileName} 出错: ${err}`);
|
||||||
}
|
}
|
||||||
@ -97,12 +97,7 @@ class BotService {
|
|||||||
| { uin: string; groups: { group_id: string; group_name: string }[]; nickName: string }[]
|
| { uin: string; groups: { group_id: string; group_name: string }[]; nickName: string }[]
|
||||||
| undefined = await redisService.fetch('crystelfBots', clientId);
|
| undefined = await redisService.fetch('crystelfBots', clientId);
|
||||||
if (!raw) continue;
|
if (!raw) continue;
|
||||||
|
if (raw.find((bot) => bot.uin === botId)) return clientId;
|
||||||
for (const bot of raw) {
|
|
||||||
if (bot.uin === botId) {
|
|
||||||
return clientId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(`读取${clientId}出错..`);
|
logger.error(`读取${clientId}出错..`);
|
||||||
}
|
}
|
||||||
@ -126,15 +121,11 @@ class BotService {
|
|||||||
| { uin: string; groups: { group_id: string; group_name: string }[]; nickName: string }[]
|
| { uin: string; groups: { group_id: string; group_name: string }[]; nickName: string }[]
|
||||||
| undefined = await redisService.fetch('crystelfBots', clientId);
|
| undefined = await redisService.fetch('crystelfBots', clientId);
|
||||||
if (!raw) continue;
|
if (!raw) continue;
|
||||||
for (const bot of raw) {
|
raw.forEach((bot) => {
|
||||||
if (bot.uin && bot.groups) {
|
if (bot.uin && bot.groups) {
|
||||||
for (const group of bot.groups) {
|
if (bot.groups.find((group) => group.group_id === groupId)) return bot.uin;
|
||||||
if (group.group_id === groupId) {
|
|
||||||
return bot.uin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(`读取${clientId}出错..`);
|
logger.error(`读取${clientId}出错..`);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user