-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
44 lines (32 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import fs from 'fs';
import { appPath } from './lib/path.js';
logger.info('*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*');
logger.info('ZZZ-Plugin 加载中');
logger.info('仓库地址 https://github.com/ZZZure/ZZZ-plugin');
logger.info('Created By ZZZure Project (MIHOMO)');
logger.info('*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*');
if (!global.segment) global.segment = (await import('oicq')).segment;
if (!global.core) {
try {
global.core = (await import('oicq')).core;
} catch (err) {
// ignore empty error
}
}
const files = fs.readdirSync(appPath).filter(file => file.endsWith('.js'));
const ret = [];
files.forEach(file => {
ret.push(import(`./apps/${file}`));
});
const retPromise = await Promise.allSettled(ret);
const apps = {};
for (const i in files) {
const name = files[i].replace('.js', '');
if (retPromise[i].status != 'fulfilled') {
logger.error(`[ZZZ-Plugin] 载入模块${logger.red(name)}错误`);
logger.error(retPromise[i].reason);
continue;
}
apps[name] = retPromise[i].value[Object.keys(retPromise[i].value)[0]];
}
export { apps };