/mass +v (Mass Voice)
/mass +o (Mass Op)
/mass -v (Mass Devoice)
/mass -o (Mass Deop)
Like it? I fixed the code because of some suggestions, thanks
alias mass {
if ($me !isop #) {
echo -a Error : You are not op on $chan
}
else {
if ($regex($1,/\Q+v\E/i) == 1) {
echo -a +V
var %x 1
while %x <= $nick(#,0,r) {
set %x.nick %x.nick $nick(#,%x,r)
if $numtok(%x.nick,32) == $modespl { mode # + $+ $str(v,$modespl) %x.nick | unset %x.nick }
inc %x
}
if %x.nick { mode # + $+ $str(v,$modespl) %x.nick | unset %x.nick }
}
if ($regex($1,/\Q-v\E/i) == 1) {
var %x 1
while %x <= $nick(#,0,v) {
set %x.nick %x.nick $nick(#,%x,v)
if $numtok(%x.nick,32) == $modespl { mode # - $+ $str(v,$modespl) %x.nick | unset %x.nick }
inc %x
}
if %x.nick { mode # - $+ $str(v,$modespl) %x.nick | unset %x.nick }
}
if ($regex($1,/\Q+o\E/i) == 1) {
var %x 1
while %x <= $nick(#,%x,a) {
set %x.nick %x.nick $nick(#,%x,a)
if $numtok(%x.nick,32) == $modespl { mode # + $+ $str(o,$modespl) %x.nick | unset %x.nick }
inc %x
}
if %x.nick { mode # + $+ $str(o,$modespl) %x.nick | unset %x.nick }
}
if ($regex($1,/\Q-o\E/i) == 1) {
var %x 1
while %x <= $nick(#,%x,o) {
set %x.nick %x.nick $remove($nick(#,%x,o),$me)
if $numtok(%x.nick,32) == $modespl { mode # - $+ $str(o,$modespl) %x.nick | unset %x.nick }
inc %x
}
if %x.nick { mode # - $+ $str(o,$modespl) %x.nick | unset %x.nick }
}
}
}
Here\'s one that I made for the nicklist,
http://www.hawkee.com/snippet.php?snippet_id=670
and one xdaemon made for the command line
http://www.hawkee.com/snippet.php?snippet_id=696
Just for examples of how this code could be made a bit shorter.
few things that seem unclear to me:
-why applying a regex on a documented parameter, if ($1 = +o) seems well enough for me...?
-why make 4 blocks of code for every parameter whilst the only difference is either the \'+\' or the \'-\' OR the \'v\' or the \'o\'. All can be combined to 1 block of code with 2 simple $iif