-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.ts
46 lines (39 loc) · 1.16 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
#!/usr/bin/env node
import fs from 'fs';
import log from 'loglevel';
import prefix from 'loglevel-plugin-prefix';
import { BotConfig, createBot } from "./bot";
prefix.reg(log);
log.setLevel("info")
prefix.apply(log, {
timestampFormatter: (date) => date.toISOString(),
format: (level, name, timestamp) => `${timestamp} [${level}]`
})
interface RunConfig {
botToken?: string,
botConfig: Partial<BotConfig>
}
log.info("Running with args:", process.argv)
const configPath = process.argv[2] || "config.json";
log.info("Config path:", configPath)
const config: RunConfig = fs.existsSync(configPath) ?
JSON.parse(fs.readFileSync(configPath).toString("utf-8")) : {};
const token = process.env.BOT_TOKEN || config.botToken
if (!token) {
throw new Error("missing bot token");
}
const fandomDomainInfo = {
"aoe": "https://ageofempires.fandom.com/api.php",
"dota":"https://dota2.fandom.com/api.php",
}
const client = createBot({
dataDir: "data",
disconnectAferInactivityMs: 5 * 60_000,
myInstantsEnabled: true,
mediawikiCDNEnabled: true,
fandomDomains: fandomDomainInfo,
maxConcurrentPlayers: 256,
bannedSounds: [],
...config.botConfig
});
client.login(token);