Optimise modes based on ISUPPORT
This will see the maximum allowed of modes that are allowed at once as sent in RPL_ISUPPORT and will send multiple batches while using /op, /voice, etc. This also fixes a minor issue where it would try sending an empty voice if it had an extra space on arguments (such as using '/voice ')
This commit is contained in:
parent
22801a629e
commit
4dacaa46f3
@ -19,7 +19,9 @@ exports.input = function ({irc, nick}, chan, cmd, args) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length === 0) {
|
||||
const target = args.filter((arg) => arg !== "");
|
||||
|
||||
if (target.length === 0) {
|
||||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
@ -40,9 +42,13 @@ exports.input = function ({irc, nick}, chan, cmd, args) {
|
||||
devoice: "-v",
|
||||
}[cmd];
|
||||
|
||||
args.forEach(function (target) {
|
||||
irc.raw("MODE", chan.name, mode, target);
|
||||
});
|
||||
const limit = parseInt(irc.network.supports("modes")) || 1;
|
||||
|
||||
for (let i = 0; i < target.length; i += limit) {
|
||||
const targets = target.slice(i, i + limit);
|
||||
const amode = `${mode[0]}${mode[1].repeat(targets.length)}`;
|
||||
irc.raw("MODE", chan.name, amode, ...targets);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user