muh
This commit is contained in:
parent
aefc42fe71
commit
4fc92320b3
|
@ -1,3 +1,7 @@
|
|||
var allowedModes = [
|
||||
'q','a','o','h','v'
|
||||
];
|
||||
|
||||
module.exports = (bot, trigger, lib) => {
|
||||
trigger.add({
|
||||
name: 'umode',
|
||||
|
@ -5,31 +9,6 @@ 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 === "undefined") return true;
|
||||
modeList.push({
|
||||
delta: delta,
|
||||
mode: token
|
||||
});
|
||||
})) return false;
|
||||
return [...new Set(modeList)];
|
||||
};
|
||||
var checkModes = (modes, allowedModes) => {
|
||||
if([...new Set(modes.map(a => a.mode))].some((mode) => {
|
||||
if(allowedModes.some((allowedMode) => {
|
||||
if(allowedMode != mode) return true;
|
||||
})) return true;
|
||||
})) return false;
|
||||
return true;
|
||||
};
|
||||
var allowedModes = [
|
||||
'q','a','o','h','v'
|
||||
];
|
||||
var tmp = e.message.trim().split(' ');
|
||||
tmp.shift();
|
||||
var user = tmp[tmp.length - 1];
|
||||
|
@ -39,44 +18,50 @@ module.exports = (bot, trigger, lib) => {
|
|||
tmp.pop();
|
||||
e.reply("input: "+JSON.stringify(tmp));
|
||||
var modes;
|
||||
if(modes = processModes(tmp.join(' '))) {
|
||||
if(checkModes(modes, allowedModes)) {
|
||||
//---apply modes---
|
||||
}
|
||||
else {
|
||||
e.reply('Error! Allowed modes are: ' + allowedModes.join(',');
|
||||
}
|
||||
}
|
||||
else {
|
||||
e.reply('Syntax Error!');
|
||||
}
|
||||
e.reply("output: "+JSON.stringify(modes));
|
||||
e.reply("user: "+user);
|
||||
|
||||
return;
|
||||
var user = modes[modes.length - 1];
|
||||
if(user.toLowerCase() != bot.me.nick.toLowerCase()) {
|
||||
if(user.match(/(\+|-)/))
|
||||
user = e.user.getNick();
|
||||
modes.shift();
|
||||
var tmp = [];
|
||||
modes.forEach((entry,i,a) => {
|
||||
if(entry.match(/((\+|-)[a-z]{1}$)/))
|
||||
tmp.push(entry);
|
||||
});
|
||||
|
||||
if(tmp.length > 0) {
|
||||
e.reply('modes: ' + JSON.stringify(tmp) + ' to user: '+user);
|
||||
tmp.forEach((entry,i,a) => {
|
||||
bot.mode(e.channel, entry+' '+user, e.network);
|
||||
});
|
||||
if(user in e.channel.names) {
|
||||
if(modes = processModes(tmp.join(' '))) {
|
||||
if(checkModes(modes, allowedModes))
|
||||
modes.forEach((entry,i,a) => {
|
||||
bot.mode(e.channel, (entry.delta?'+':'-')+entry.mode+' '+user, e.network);
|
||||
});
|
||||
else
|
||||
e.reply('Error! Allowed modes are: ' + allowedModes.join(','));
|
||||
}
|
||||
else
|
||||
e.reply('Syntax Error!');
|
||||
}
|
||||
else
|
||||
e.reply('no modes given');
|
||||
e.reply('user not found!');
|
||||
}
|
||||
else
|
||||
e.reply('f0ck you.');
|
||||
e.reply('f0ck you hard');
|
||||
e.reply("output: "+JSON.stringify(modes));
|
||||
},
|
||||
desc: 'change Usermodes'
|
||||
});
|
||||
};
|
||||
|
||||
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 === "undefined") return true;
|
||||
modeList.push({
|
||||
delta: delta,
|
||||
mode: token
|
||||
});
|
||||
})) return false;
|
||||
return [...new Set(modeList)];
|
||||
};
|
||||
|
||||
var checkModes = (modes, allowedModes) => {
|
||||
if([...new Set(modes.map(a => a.mode))].some((mode) => {
|
||||
for(var i = 0; i <= allowedModes.length; i++)
|
||||
if(allowedModes[i] == mode) return false;
|
||||
return true;
|
||||
})) return false;
|
||||
return true;
|
||||
};
|
Loading…
Reference in New Issue
Block a user