mode parsing function

This commit is contained in:
jkhsjdhjs 2016-09-05 22:46:03 +02:00
parent 619e225544
commit c00e3b867c

View File

@ -5,10 +5,26 @@ module.exports = (bot, trigger, lib) => {
level: 100,
active: 1,
func: (e) => {
var processModes = (modes) => {
var delta, modeList = [];
if(modes.split('').some((token) => {
if(token === '-') {delta = false; return;}
if(token === '+') {delta = true; return;}
if(token === ' ') return;
if(typeof delta !== "boolean") return true;
modeList.push({
delta: delta,
mode: token
});
})) return false;
else return modeList;
};
var allowedModes = [
'q','a','o','h','v'
];
var modes = e.message.trim().split(' ');
var modes = processModes(e.message);
console.log(modes);
return;
var user = modes[modes.length - 1];
if(user.toLowerCase() != bot.me.nick.toLowerCase()) {
if(user.match(/(\+|-)/))
@ -21,7 +37,7 @@ module.exports = (bot, trigger, lib) => {
});
if(tmp.length > 0) {
e.reply('modes: '+JSON.stringify(tmp) + ' to user: '+user);
e.reply('modes: ' + JSON.stringify(tmp) + ' to user: '+user);
tmp.forEach((entry,i,a) => {
bot.mode(e.channel, entry+' '+user, e.network);
});