finally: umode :D

This commit is contained in:
Flummi 2016-09-05 23:22:54 +00:00
parent ae0a2694e5
commit ca21ce68c5

View File

@ -16,14 +16,14 @@ module.exports = (bot, trigger, lib) => {
user = e.user.getNick();
else
tmp.pop();
e.reply("input: "+JSON.stringify(tmp));
var modes;
if(user.toLowerCase() != bot.me.nick.toLowerCase()) {
if(user in e.channel.names) {
if(modes = processModes(tmp.join(' '))) {
if(checkModes(modes.give + modes.revoke, allowedModes))
if(modes.give != "") bot.mode(e.channel, '+' + modes.give + ' ' + user, e.network);
if(modes.revoke != "") bot.mode(e.channel, '-' + modes.revoke + ' ' + user, e.network);
if(checkModes(modes.give + modes.revoke, allowedModes)) {
if(modes.give != "") bot.mode(e.channel, '+' + modes.give + ' ' + (user+' ').repeat(modes.give.length), e.network);
if(modes.revoke != "") bot.mode(e.channel, '-' + modes.revoke + ' ' + (user+' ').repeat(modes.revoke.length), e.network);
}
else
e.reply('Error! Allowed modes are: ' + allowedModes.join(','));
}
@ -31,11 +31,10 @@ module.exports = (bot, trigger, lib) => {
e.reply('Syntax Error!');
}
else
e.reply('user not found!');
e.reply('user '+user+' not found!');
}
else
e.reply('f0ck you hard');
e.reply("output: "+JSON.stringify(modes));
},
desc: 'change Usermodes'
});
@ -55,9 +54,7 @@ var processModes = (modes) => {
var checkModes = (modes, allowedModes) => {
if([...new Set(modes.split(''))].some((mode) => {
for(var i = 0; i <= allowedModes.length; i++)
if(allowedModes[i] == mode) return false;
return true;
return (allowedModes.indexOf(mode) != -1)?false:true;
})) return false;
return true;
};