This commit is contained in:
Flummi 2016-11-07 02:15:08 +01:00
parent 948fd4e647
commit 0826223d5c
2 changed files with 307 additions and 299 deletions

View File

@ -40,8 +40,8 @@ module.exports = Lib;
function Lib() {
//self.cfg = require('../cfg/main.json');
self.cfg = {};
self.getcfg((cfg) => {
self.cfg = cfg;
self.getcfg('main', cfg => {
self.cfg.main = cfg;
self.debug = self.cfg.main.debug;
self.loadIRC();
self.loadUser((cb) => console.log((cb)?"Admins wurden geladen":"Admins konnten nicht geladen werden"));
@ -234,15 +234,17 @@ self.levelToModes = level => {
return "";
};
self.getcfg = (cb) => {
var out = {
self.getcfg = (kat, cb) => {
// main, websrv, irc
/*var out = {
irc: {},
main: {},
websrv: {}
};
self.sql.query("select * from `f0ck`.`cfg`", (err, rows) => {
};*/
var out = {};
self.sql.query("select * from `f0ck`.`cfg` where `class` = ?", kat, (err, rows) => {
rows.forEach(e => {
out[e.class][e.key] = ((type, value) => {
out[e.key] = ((type, value) => {
switch(type) {
case 'string':
return value;
@ -264,6 +266,8 @@ self.getcfg = (cb) => {
};
self.loadIRC = () => {
self.getcfg('irc', cfg => {
self.cfg.irc = cfg;
self.cfg.irc.forEach(e => {
self.bot.add({
"name": e.name,
@ -279,4 +283,5 @@ self.loadIRC = () => {
});
console.log("Server "+e.name+" wurde geladen");
});
});
};

View File

@ -13,6 +13,8 @@ module.exports = Websrv;
function Websrv(tlib) {
this.lib = lib = tlib;
lib.getcfg('websrv', cfg => {
lib.cfg.websrv = cfg;
Websrv.prototype.getTpls();
http.createServer((req, res) => {
@ -316,6 +318,7 @@ function Websrv(tlib) {
res.end('403 - forbidden');
}
}).listen(lib.cfg.websrv.port);
});
}
Websrv.prototype.getTpls = () => {