This commit is contained in:
Flummi 2018-09-08 11:21:26 +02:00
parent 75a700e332
commit 510838db4d
3 changed files with 30 additions and 6 deletions

View File

@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"node-fetch": "^2.2.0", "node-fetch": "^2.2.0",
"nodejs-mysql2": "git+https://gitfap.de/Flummi/nodejs-mysql2.git", "nodejs-mysql2": "git+https://gitfap.de/Flummi/nodejs-mysql2.git",
"cuffeo": "git+https://gitfap.de/keinBot/cuffeo.git",
"request": "^2.88.0", "request": "^2.88.0",
"request-promise-native": "^1.0.5", "request-promise-native": "^1.0.5",
"winston": "^2.4.0" "winston": "^2.4.0"

View File

@ -6,6 +6,7 @@ let cfg = {
websrv: {}, websrv: {},
trigger: {} trigger: {}
}; };
let admins = [];
const read = () => new Promise((resolve, reject) => { const read = () => new Promise((resolve, reject) => {
sql.exec("select * from cfg").then(rows => { sql.exec("select * from cfg").then(rows => {
@ -27,11 +28,33 @@ const read = () => new Promise((resolve, reject) => {
type: rows[row].type type: rows[row].type
} }
} }
resolve(); loadAdmins().then(() => {
resolve();
});
}) })
.catch(err => { .catch(err => {
reject("no cfg"); reject("no cfg");
}) })
}); });
export { cfg, read }; export const loadAdmins = () => new Promise((resolve, reject) => {
admins = [];
sql.exec(`select * from admins`)
.then(rows => {
rows.forEach(row => {
admins.push({
id: row.id,
prefix: row.prefix,
account: row.account,
network: row.network,
level: row.level
});
});
resolve();
})
.catch(err => {
reject("keine Admins vorhanden");
});
});
export { cfg, read, admins };

View File

@ -1,6 +1,7 @@
import { logger } from "./inc/log"; import { logger } from "./inc/log";
import { read, cfg } from "./inc/cfg"; import { read, cfg, admins } from "./inc/cfg";
import { wrapper } from "./inc/wrapper"; //import { wrapper } from "./inc/wrapper";
import { cuffeo } from "cuffeo";
import triggers from "./inc/trigger"; import triggers from "./inc/trigger";
import events from "./inc/events"; import events from "./inc/events";
@ -17,11 +18,10 @@ read().then(() => {
this.clients = args.clients || ["irc", "tg", "discord"]; this.clients = args.clients || ["irc", "tg", "discord"];
this.f = args.f; this.f = args.f;
}, },
bot: new wrapper() bot: new cuffeo(cfg.client, admins)
}; };
triggers.forEach(mod => { triggers.forEach(mod => {
console.log(mod);
mod(self); mod(self);
}); });
events.forEach(event => event(self)); events.forEach(event => event(self));