This commit is contained in:
Flummi 2016-08-29 22:07:50 +02:00
parent b6ee765955
commit f26f402471
3 changed files with 12 additions and 13 deletions

View File

@ -5,14 +5,14 @@ var exec = require('child_process').exec;
var probe = require('node-ffprobe'); var probe = require('node-ffprobe');
var crypto = require('crypto'); var crypto = require('crypto');
var Mime = require('mime'); var Mime = require('mime');
var cfg = require('../cfg/main.json');
var bot, sql, cfg, debug; var bot, sql, debug;
module.exports = Lib; module.exports = Lib;
function Lib(tbot, tsql, tcfg) { function Lib(tbot, tsql) {
this.bot = bot = tbot; this.bot = bot = tbot;
this.sql = sql = tsql; this.sql = sql = tsql;
this.cfg = cfg = tcfg;
this.debug = debug = false; this.debug = debug = false;
this.admins = []; this.admins = [];
} }

View File

@ -1,4 +1,4 @@
var cfg = require('../../cfg.json'); var cfg = require('../cfg/irc.json');
var fs = require('fs-extra'); var fs = require('fs-extra');
var mysql = require('mysql'); var mysql = require('mysql');
var bot = require('coffea')(); var bot = require('coffea')();
@ -6,9 +6,8 @@ var Lib = require('./lib.js');
var Websrv = require('./websrv.js'); var Websrv = require('./websrv.js');
var sql; var sql;
var haDC = () => { var haDC = () => {
sql = mysql.createConnection(cfg.mysql); sql = mysql.createConnection(require('../cfg/mysql.json'));
sql.connect((err) => { sql.connect((err) => {
if(err) setTimeout(haDC, 2000); if(err) setTimeout(haDC, 2000);
}); });
@ -18,10 +17,10 @@ var haDC = () => {
}; };
haDC(); haDC();
var lib = new Lib(bot, sql, cfg); var lib = new Lib(bot, sql);
var websrv = new Websrv(bot, sql, cfg, lib); var websrv = new Websrv(bot, sql, lib);
cfg.server.forEach((e,i,a) => { cfg.forEach((e,i,a) => {
bot.add({ bot.add({
"name": e.name, "name": e.name,
"host": e.host, "host": e.host,

View File

@ -2,15 +2,15 @@ var fs = require('fs-extra');
var http = require('http'); var http = require('http');
var path = require('path'); var path = require('path');
var swig = require('swig'); var swig = require('swig');
var cfg = require('../cfg/websrv.json');
var templates = {}; var templates = {};
var bot, sql, cfg, lib; var bot, sql, lib;
module.exports = Websrv; module.exports = Websrv;
function Websrv(tbot, tsql, tcfg, tlib) { function Websrv(tbot, tsql, tlib) {
this.bot = bot = tbot; this.bot = bot = tbot;
this.sql = sql = tsql; this.sql = sql = tsql;
this.cfg = cfg = tcfg;
this.lib = lib = tlib; this.lib = lib = tlib;
http.createServer((req, res) => { http.createServer((req, res) => {
@ -253,7 +253,7 @@ function Websrv(tbot, tsql, tcfg, tlib) {
res.writeHead(403); res.writeHead(403);
res.end('403 - forbidden'); res.end('403 - forbidden');
} }
}).listen(cfg.webserver.port); }).listen(cfg.port);
} }
Websrv.prototype.getTpls = () => { Websrv.prototype.getTpls = () => {