Hum, the code above was meant to replace your code. I don't know if you issue the /who # manually, or auto-who on join, or use a menu or the like.

Anyway, below's yet another version (full script). It uses dynamically named timers in place of the dynamic variables. It also won't /haltdef replies for other /who requests, it will sort the output, etc.
In your channel menu youl'll find a new item to scan for opers. You can set exceptions (like *serv) there as well.
Code:
menu channel {
  IRCOp-Scan 
  .$iif($timer($+(opersc,$cid,$chr(1),$chan)),$style(2)) Scan chan $chan now : {
    who $chan
    $+(.timeropersc,$cid,$chr(1),$chan) 1 25 opersc.off
  }
  .Set exclusions $chr(91) $numtok(%opersc.exclude,32) set $chr(93): {
    set %opersc.exclude $input(Nicks will be excluded from the output message if any mask in the following string $&
      matches the user's address. $crlf $crlf $+ Put masks in the format nick!user@host. $crlf $+ Separate multiple $&
      masks with a space.You may use wildcards (example: *serv!*@*).,eog,Set exclusions for IRCop-Scan,%opersc.exclude)
    opersc.maketable
  }
}

alias -l opersc.off { if ($hget($ctimer)) hfree $v1 }

alias -l opersc.maketable {
  var %n = 1
  if ($hget(opersc.exclude)) { hfree $v1 }
  while ($gettok(%opersc.exclude,%n,32)) {
    hadd -m opersc.exclude $v1
    inc %n
  }
}

on *:start: { opersc.maketable }

raw 352:*: {
  if ($timer($+(opersc,$cid,$chr(1),$2))) {
    haltdef
    if (* isin $7) {
      var %t = $+(opersc,$cid,$chr(1),$2)
      if ($hfind(opersc.exclude,$+($6,!,$3,@,$4),1,W)) { hinc -m %t excluded }
      else { hadd -m %t onicks $addtok($hget(%t,onicks),$6,32) }
    }
  }
}

raw 315:*: {
  if ($timer($+(opersc,$cid,$chr(1),$2))) {
    haltdef
    var %t = $timer($v1), %w = $gettok(%t,-1,1), %h = $sorttok($hget(%t,onicks),32), %n = $numtok(%h,32), %e = $hget(%t,excluded)
    ECHO $iif((%w ischan),$v1) * Found $iif((%n || %e),%n $iif(%e,$+([+,%e,])),no) $iif((%n != 1),users,user), with IRCOP-flag in %w $+ $iif(%h,:,.)
    $iif(%h,ECHO $iif((%w ischan),$v1) %h)
    .timer $+ %t -e
  }
}

on *:disconnect: {
  var %n = 1
  while ($timer(%n)) { $iif(($+(opersc,$cid,$chr(1),*) iswm $v1),timer $+ $v2 -e,inc %n) }
}

on *:unload: { 
  unset %opersc.exclude
  hfree -w opersc.*
}

Note that I did not test the script intensely.
Both the scan and the exclusions-filter do work for me though.

Last edited by Horstl; 19/01/10 01:11 AM.