WIP: cfgtrigger

This commit is contained in:
Flummi 2016-11-21 19:05:02 +01:00
parent bdd4ef7b95
commit a6495dd213

View File

@ -1,19 +1,63 @@
module.exports = (lib) => {
var kats = {
main: [
"allowedMimes",
"debugchannel",
"disallowedHosts",
"maxFileSize"
]
};
lib.trigger.add({
name: 'cfg',
call: /^!cfg/i,
level: 100,
active: 1,
func: (e) => {
// irc, main, websrv
var tmp = e.message.split('=');
var value = tmp[1].trim();
var cmd = tmp[0].replace('!cfg.','').trim().split('.');
var kat = cmd[0];
var key = cmd[1];
e.reply("kat: "+kat+" ; key: "+key+" ; val: "+value);
// irc, main, websrv, trigger
var msg = e.message.replace('!cfg.','');
if(msg.match(/=/)) {
var tmp = e.message.split('=');
var value = tmp[1].trim();
var cmd = tmp[0].trim().split('.');
if(cmd.length == 2) {
var kat = cmd[0];
if(kat in kats) {
var key = cmd[1];
if(kats[kat].indexOf(key) !== -1) {
e.reply("kat: "+kat+" ; key: "+key+" ; val: "+value);
}
else {
e.reply("key not found");
}
}
else {
e.reply("kat not found");
}
}
else {
e.reply("nope");
}
}
else {
var cmd = msg.trim().split('.');
var kat = cmd[0];
if(kat in kats) {
var key = cmd[1];
if(kats[kat].indexOf(key) !== -1) {
lib.getcfg(kat, (cb) => {
e.reply(kat+"."+key+" = "+JSON.stringify(cb));
}, key);
}
else {
e.reply("key not found");
}
}
else {
e.reply("kat not found");
}
}
},
desc: 'cfg'
});