-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
59 lines (52 loc) · 1.76 KB
/
app.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
global.NIL = {};
NIL.version = [1, 1, 4];
require('./Utils/Logger');
const { ErrorCode } = require('oicq');
var logger = new NIL.Logger('MAIN');
require('./Utils/CMDManager');
require('./Utils/EventManager');
require('./Utils/FileSystem');
if (NIL.IO.exists('./Data') == false) NIL.IO.createDir('./Data');
require('./Utils/ServerManager');
require('./Utils/QQManager');
require('./Utils/ModulesManager');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
prompt: '>> '.yellow
});
logger.info(`NilBridge2 v${NIL.version.join('.')}`);
NIL.EventManager.on('onNilBridgeStart', {});
rl.on('line', (input) => {
NIL.NBCMD.run_cmd(input).then(result=>{
switch (Object.prototype.toString.call(result)) {
case '[object Array]':
result.forEach(element => {
logger.info(element);
});
break;
case '[object String]':
logger.info(result);
break;
}
}).catch(err=>{
logger.error(err);
});
});
NIL.NBCMD.regUserCmd('stop', '关闭NilBridge', () => {
return new Promise((res,rej)=>{
NIL.EventManager.on('onNilBridgeStop', {});
NIL.bots.logoutAll();
setTimeout(() => {
process.exit();
}, 1000);
res('正在退出');
})
})
process.on('unhandledRejection', (reason, promise) => {
console.log(reason);
logger.warn(`看到这条消息表明,您的参数出现了${'null'.bgRed}或者${'undefined'.bgRed},请检查`);
logger.warn(`error type : ${ErrorCode[reason.code]}`);
logger.warn(`errorcode : ${reason.code},descr : ${reason.message}`);
});