This commit is contained in:
Flummi 2016-11-18 07:56:12 +01:00
parent cd97c2938c
commit 92c4e2ae36
2 changed files with 46 additions and 26 deletions

View File

@ -230,26 +230,30 @@ self.levelToModes = level => {
self.getcfg = (kat, cb) => {
// main, websrv, irc
var out = {};
self.sql.query("select * from `f0ck`.`cfg` where `class` = ?", kat, (err, rows) => {
rows.forEach(e => {
out[e.key] = ((type, value) => {
switch(type) {
case 'string':
return value;
break;
case 'int':
return parseInt(value);
break;
case 'bool':
return (value === 'true')?true:false;
break;
case 'json':
return JSON.parse(value);
break;
}
})(e.type, e.value);
});
if(cb) cb(out);
self.sql.query("select * from `f0ck`.`cfg` where `class` = ?"+(arguments[2]?"&& `key` = '"+arguments[2]:"")')", kat, (err, rows) => {
if(err || !rows)
cb(err);
else {
rows.forEach(e => {
out[e.key] = ((type, value) => {
switch(type) {
case 'string':
return value;
break;
case 'int':
return parseInt(value);
break;
case 'bool':
return (value === 'true')?true:false;
break;
case 'json':
return JSON.parse(value);
break;
}
})(e.type, e.value);
});
if(cb) cb(out);
}
});
};

View File

@ -5,12 +5,28 @@ module.exports = (lib) => {
level: 100,
active: 1,
func: (e) => {
var output = "";
e.reply("Trigger in "+e.channel.getName()+" (green: activated, red: deactivated):");
lib.trigger.trigger.forEach(e => {
output += lib.bot.format.get( (e.active)?'green':'red' )+" "+e.name;
});
e.reply(output);
var args = e.message.split(' ');
switch(args[1]) {
case "cfg":
lib.getcfg('trigger_'+e.network+'_'+e.channel, cb => {
if(!cb) {
e.reply(cb);
}
else {
e.reply('muh');
}
});
break;
default:
var output = "";
e.reply("Trigger in "+e.channel.getName()+" (green: activated, red: deactivated):");
lib.trigger.trigger.forEach(e => {
output += lib.bot.format.get( (e.active)?'green':'red' )+" "+e.name;
});
e.reply(output);
break;
}
},
desc: 'muh'
});