MassCommands

By LiquidJesus on Mar 04, 2006

just load into ur remotes..then in a channel type /mass +o/-o or +v/-v

;Mass commands
;Use /mass +o/-o +v/-v ...
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)) {
     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 }
   }
 }
}

Comments

Sign in to comment.
Yoinx   -  Mar 04, 2006

yeah I know gex, like I said, I missed that if after the while on my first post.

The code he has would work, I just posted the other one, to show a more efficent way of doing it since he is using regex. The code as he has it now, you\'d have to add another whole if section if you wanted to add another mode, with the example i gave you would merely add it to

if ($regex(mode,$1,/^(\+|-)(v|h|o)/i)) {

the (v|h|o) section in that if, and the code would use it. Like I said, Its just a slightly more efficient way of doing it in my opinion. In case you want to add more modes.

 Respond  
Gex   -  Mar 04, 2006

hehe....i donno yoinx it works perfectly here.

 Respond  
Yoinx   -  Mar 04, 2006

oh and sorry about my first post, I didnt see the if after the while.. my bad.

 Respond  
Yoinx   -  Mar 04, 2006

here\'s another way to do this, which is a little more efficent since you\'re using regex anyway.

alias mass {
if ($active !ischan) || ($me !isop $active) {
echo -a Error: This command can only be used on a channel which you have Op status in.
return
}
if ($regex(mode,$1,/^(\+|-)(v|h|o)/i)) {
if ($regml(mode,1) == + ) var %include = $remove(ohvr,$regml(mode,2))
elseif ($regml(mode,1) == - ) var %include = $regml(mode,2)
var %nicktotal = $nick($chan,0,%include)
while (%nicktotal) {
set %nicks $+(%nicks,$chr(32),$nick($chan,%nicktotal,%include))
if ($numtok(%nicks,32) == $modespl) {
mode $chan $str($+($regml(mode,1),$regml(mode,2)),$modespl) %nicks
unset %nicks
}
dec %nicktotal
}
if (%nicks) {
mode $chan $str($+($regml(mode,1),$regml(mode,2)),$numtok(%nicks,32)) %nicks
unset %nicks
}
}
}

 Respond  
LiquidJesus   -  Mar 04, 2006

ok thanks Gex..i just fixed it :)

 Respond  
Yoinx   -  Mar 04, 2006

I dont know gex. I didnt test it, but just from looking at it, its very inefficent. and from the look at the first while.

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
}

it looks like you\'re only gonna do the mode changes on groups of people that meet modespl.

ie $modespl = 6, if you have 29 people in your room, you\'re only going to do the modechanges on the first 24. and it will skip the last 5 since they dont make it into the modespl multiple. and the while loop is broken out of without doing the modechange on them.

like I said though, I didnt test it, but thats how it looks.

 Respond  
Gex   -  Mar 04, 2006

aht btw u dont need to write \"if ($regex($1,/\Q+v\E/i) == 1)\" the == 1 isnt important as it refers to $true..it only can be like that ........\"if ($regex($1,/\Q+v\E/i))\"

 Respond  
Gex   -  Mar 04, 2006

that deserves more than 1.0 ... at least 5.0 ... very nice LiquidJesus

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.