Op/Hop/Voice notice

; so. mIRC is weird.
; say we're on a network that enables PREFIX_AQ (where ~ (founder) and & (sop) are displayed  
;  in nicklists, instead of hiding them behind @)
; also suppose that we have someone named bob, who is the founder of #place, and 
;  is all alone in it.
; (bob isop #place) returns TRUE.. yet, $nick(#place,0,o), which is supposed to return the  
;   number of ops in #place (1), returns 0.
; the following o/h/vnotice code attempts to get around this (while also letting you use  
;   a better way to do it when possible)
; written by Alucard, 11/12/2004
;follow the example of these aliases to make your own custom ones..
; use o for ops, h for halfops, v for vops, and r for regulars in to_who. anything else is 
;ignored; the letters are case-sensitive.
; alias its_name { _notice $chan to_who $1 }
alias ohvn {
  _notice $chan ohv $1-
}
alias on {
  _notice $chan o $1-
}
alias ohn {
  _notice $chan oh $1-
}
alias vn {
  _notice $chan v $1-
}
alias hn {
  _notice $chan h $1-
}
alias -l _notice {
  ;$1 = channel name; $2 = to who on the channel (o,h,v, or a combination of the three),  
  ;  $3- is the message to send
  var %to =  $+ $replace($2,o,Ops/,h,Hops/,v,Vops/,r,Regs/) $+ $1 $+ 
  ;ok, this is pretty complicated.  Unreal has a nifty command to notice certain people on a 
  ;channel in one command (read: less lag).
  ; type /helpop notice to see.
  ;what this does, is uses that command IF
  ; - you are noticing to vops+, hops+, or ops+ (the way the command works does not allow  
  ;   e.g. only vops and ops), AND
  ; -- you are an op on the channel, OR
  ; -- you are a voice or halfop, AND
  ; --- +T is not set (due to a bug(?) in unreal, v/hops cant use /notice as described 
  ;  above with  +T set).
  ; hope that made sense.
  ; if these conditions are fulfilled, then we use the better command
  if (($me isop $1) $&
    || ((($me ishop $1) || ($me isvo $1)) && (T !isincs $chan($1).mode))) $&
    && ((ohv == $2) || (oh == $2) || (o == $2)) { 
    .notice $min($2) $+ $1 %to $3- 
  }
  ; if those conditions are not fulfilled, then we have to /notice everyone individually.
  else {
    var %i = 1
    ; loop thru each person on the channel..
    while (%i < $nick(#,0)) {
      ; this is so that people can do e.g. /opvoice notice.
      ; only notice the person if he's op AND 'o' is specified as a destination, etc
      if (((o isincs $2) && ($nick($1,%i) isop $1)) $&
        || ((h isincs $2) && ($nick($1,%i) ishop $1)) $&
        || ((v isincs $2) && ($nick($1,%i) isvo $1)) $&
        || ((r isincs $2) && ($nick($1,%i) isreg $1)) $&
        && ($nick($1,%i) != $me)) {
        ; keep the dot at the beginning, to hide each individual notice from you
        .notice $nick(#,%i) %to $3-
      }
      inc %i
    }
  }
  ; finally, echo locally what we sent.
  echo 14 -at Notice sent %to $3-
}
alias -l min {
  if (v isin $1) { return + }
  elseif (h isin $1) { return $chr(37) }
  else { return @ }
}