-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.ts
38 lines (34 loc) · 981 Bytes
/
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
import config from "./config";
import Ai from "./ai";
import Modulez from "./modules";
import IModule from "./module";
import { User } from "./misskey";
console.log(">>> starting... <<<");
let ai: Ai;
async function main() {
let tmp = await fetch(`${config.apiURL}/i`, {
method: "POST",
body: JSON.stringify({
i: config.i,
}),
headers: config.headers,
});
let me = (await tmp.json()) as User; // Force convert to misskey.User
console.log(`I am ${me.name}(@${me.username})!`);
console.log(`Version: ${config.version}(${config.revision})`);
me.host = config.host;
const modules: IModule[] = [];
Modulez.forEach((M) => {
const m = new M(ai);
if (config.modules.indexOf(m.name) >= 0) modules.push(m);
});
modules.sort((a, b) => {
return b.priority - a.priority;
});
ai = new Ai(me, modules);
}
process.on("SIGINT", async () => {
console.log("Received interrupt signal, exiting...");
await ai.onInterrupt();
});
main();