f0ckv1/src/trigger/umode.js

53 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-09-05 11:18:58 +00:00
module.exports = (bot, trigger, lib) => {
trigger.add({
name: 'umode',
call: /^\!umode (.*)/i,
level: 100,
active: 1,
func: (e) => {
2016-09-05 20:46:03 +00:00
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;
};
2016-09-05 18:23:31 +00:00
var allowedModes = [
'q','a','o','h','v'
];
2016-09-05 20:46:03 +00:00
var modes = processModes(e.message);
console.log(modes);
return;
2016-09-05 11:18:58 +00:00
var user = modes[modes.length - 1];
2016-09-05 11:25:29 +00:00
if(user.toLowerCase() != bot.me.nick.toLowerCase()) {
2016-09-05 11:21:52 +00:00
if(user.match(/(\+|-)/))
user = e.user.getNick();
modes.shift();
2016-09-05 18:23:31 +00:00
var tmp = [];
modes.forEach((entry,i,a) => {
if(entry.match(/((\+|-)[a-z]{1}$)/))
tmp.push(entry);
});
if(tmp.length > 0) {
2016-09-05 20:46:03 +00:00
e.reply('modes: ' + JSON.stringify(tmp) + ' to user: '+user);
2016-09-05 18:23:31 +00:00
tmp.forEach((entry,i,a) => {
2016-09-05 11:21:52 +00:00
bot.mode(e.channel, entry+' '+user, e.network);
});
2016-09-05 18:23:31 +00:00
}
2016-09-05 11:21:52 +00:00
else
e.reply('no modes given');
2016-09-05 11:18:58 +00:00
}
else
2016-09-05 11:21:52 +00:00
e.reply('f0ck you.');
2016-09-05 11:18:58 +00:00
},
desc: 'change Usermodes'
});
};