-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
62 lines (52 loc) · 1.64 KB
/
index.ts
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
60
61
62
global.APP_PATH = __dirname;
import { CQWebSocket } from 'cq-websocket';
import dotenv from 'dotenv';
import crons from './app/crons';
// import RepeatModule from './app/modules/yuen/repeat';
// import ItemImprovementModule from './app/modules/kancolle/item-improvement';
// import XiaoMModule from './app/modules/yuen/m';
// import Misc from './app/modules/yuen/misc';
import PetModule from './app/modules/pet';
import MiniKancolleModule from './app/modules/kancolle/mini';
import startMiniKancolleServer from './app/server';
const envs = dotenv.config();
if (envs.error) {
throw envs.error;
}
const bot = new CQWebSocket({
qq: +process.env.QQ!,
reconnection: true,
reconnectionAttempts: 10,
host: process.env.COOLQ_HOST,
port: +process.env.COOLQ_PORT!,
});
bot.connect();
bot
.on('socket.connecting', function(socketType, attempts) {
console.log('嘗試第 %d 次連線 _(:з」∠)_', attempts);
})
.on('socket.connect', function(socketType, sock, attempts) {
console.log('第 %d 次連線嘗試成功 ヽ(✿゚▽゚)ノ', attempts);
})
.on('socket.failed', function(socketType, attempts) {
console.log('第 %d 次連線嘗試失敗 。・゚・(つд`゚)・゚・', attempts);
})
.on('socket.error', function(...args) {
console.error('[ERROR] ', ...args);
});
const loadModules = () => {
// new RepeatModule(bot);
// new ItemImprovementModule(bot);
// new XiaoMModule(bot);
// new Misc(bot);
new PetModule(bot);
new MiniKancolleModule(bot);
};
const doCrons = () => {
crons.forEach((getCron) => getCron(bot).start());
};
bot.on('ready', () => {
loadModules();
doCrons();
startMiniKancolleServer();
});