(de)op/halfop/voice with wildcard

By ChanZin on Apr 10, 2010

Usage:
/op
/deop
/halfop
/dehalfop
/voice
/devoice

Example:
/devoice n?cknam*

alias deop {
  var %x 1
  while (%x <= $nick(#,0,o)) {
    if ($1 iswm $nick(#,%x,o) && $nick(#,%x,o) != $me) {
      var %n %n $nick(#,%x,o)
      inc %o
    }
    inc %x
  }
  mode # - $+ $str(o,%o) %n
  unset %o
}
alias op {
  var %x 1
  while (%x <= $nick(#,0)) {
    if ($1 iswm $nick(#,%x) && $nick(#,%x) != $me) {
      var %n %n $nick(#,%x)
      inc %o
    }
    inc %x
  }
  mode # + $+ $str(o,%o) %n
  unset %o
}
alias dehalfop {
  var %x 1
  while (%x <= $nick(#,0,h)) {
    if ($1 iswm $nick(#,%x,h) && $nick(#,%x,h) != $me) {
      var %n %n $nick(#,%x,h)
      inc %o
    }
    inc %x
  }
  mode # - $+ $str(h,%o) %n
  unset %o
}
alias halfop {
  var %x 1
  while (%x <= $nick(#,0)) {
    if ($1 iswm $nick(#,%x) && $nick(#,%x) != $me) {
      var %n %n $nick(#,%x)
      inc %o
    }
    inc %x
  }
  mode # + $+ $str(h,%o) %n
  unset %o
}
alias devoice {
  var %x 1
  while (%x <= $nick(#,0,v)) {
    if ($1 iswm $nick(#,%x,v) && $nick(#,%x,v) != $me) {
      var %n %n $nick(#,%x,v)
      inc %o
    }
    inc %x
  }
  mode # - $+ $str(v,%o) %n
  unset %o
}
alias voice {
  var %x 1
  while (%x <= $nick(#,0)) {
    if ($1 iswm $nick(#,%x) && $nick(#,%x) != $me) {
      var %n %n $nick(#,%x)
      inc %o
    }
    inc %x
  }
  mode # + $+ $str(v,%o) %n
  unset %o
}

Comments

Sign in to comment.
Jethro   -  Apr 10, 2010

:/ Humm..I have just realized you didn't use the loops to mass mode a channel, but rather you used them to give people user modes one at a time in a wildcard manner. But why? You could have used the simple if statement to do one mode per nick.

 Respond  
napa182   -  Apr 10, 2010

also you should incorp $modespl into ur code...

 Respond  
Jethro   -  Apr 10, 2010

You should have done something like this:

alias mass {
  if ($me isop #) {
    var %i 1,%p,%m $modespl,%mass
    if (($$1 = deop) && ($nick(#,0,o))) %p = $+(-,$str(o,%m))
    elseif (($$1 = op) && (!$nick(#,0,o))) %p = $+(+,$str(o,%m))
    elseif (($$1 = dehalfop) && ($nick(#,0,h))) %p = $+(-,$str(h,%m))
    elseif (($$1 = halfop) && (!$nick(#,0,h))) %p = $+(+,$str(h,%m))
    elseif (($$1 = devoice) && ($nick(#,0,v))) %p = $+(+,$str(v,%m))
    elseif (($$1 = voice) && (!$nick(#,0,v))) %p = $+(+,$str(v,%m))
    while $nick(#,%i) { if ($v1 != $me) { %mass = %mass $v1 }
      if ($gettok(%mass,0,32) = %m) || ($nick(#,0) = %i) {
  mode # %p %mass | %mass = "" } | inc %i } }
  else { echo -a *** You're not opped in # *** }
}

Syntax: /mass deop OR op dehalfop OR halfop, and devoice OR voice
Instead of using one same mass loop per each command.

 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.