Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Commit 305b392

Browse files
xueelfDc_Yuki
authored andcommitted
add filter
- 添加对 bots 目录下文件的过滤
1 parent 645fba3 commit 305b392

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

dist/bot.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ const bots = new Map();
1111
// 获取机器人目录
1212
function getBotDir() {
1313
const bot_bir = new Map();
14-
for (let file_name of fs_1.readdirSync('./config/bots')) {
15-
const bot_id = file_name.split('.')[0];
14+
const files = fs_1.readdirSync('./config/bots').filter(file_name => /\.yml$/.test(file_name));
15+
for (let file_name of files) {
16+
const bot_id = file_name.slice(0, file_name.length - 4);
1617
bot_bir.set(bot_id, util_1.getProfileSync(bot_id, './config/bots'));
1718
}
1819
return bot_bir;

src/bot.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ const bots: Map<number, Client> = new Map();
1212
// 获取机器人目录
1313
function getBotDir(): Map<string, IBot> {
1414
const bot_bir: Map<string, IBot> = new Map();
15+
const files: string[] = readdirSync('./config/bots').filter(file_name => /\.yml$/.test(file_name))
1516

16-
for (let file_name of readdirSync('./config/bots')) {
17-
const bot_id: string = file_name.split('.')[0];
17+
for (let file_name of files) {
18+
const bot_id: string = file_name.slice(0, file_name.length - 4);
1819

1920
bot_bir.set(bot_id, getProfileSync(bot_id, './config/bots') as IBot);
2021
}

0 commit comments

Comments
 (0)