Clone Detection
Posted by HellRaz0r
Friday, July 20, 2007
Description: Detects clones.


;/clones [#channel]
alias clones {
  var %targ = $iif($1,$1,$chan), %x = 1, %y
  while (%x <= $nick(%targ,0)) {
    var %nick = $nick(%targ,%x), %addr = $address(%nick,2), %clones = $ialchan(%addr,%targ,0)
    if (%clones > 1) && (!$hget(detectclones,%addr)) {
      echo -a [^B]Warning:[^B] %nick has %clones clones.
      hinc -mu1 detectclones %addr
      inc %y
    }
    inc %x
  }
  if (!%y) echo -a No clones detected.
  .hfree -sw detectclones
}

# $clone(<channel>,<Nick|Wildsite|Number>).prop
# Props: nick addr clones
# note: If you input 0 for Number it will show you total clones.
alias clone {
  if (!$isid) halt
  var %targ = $iif($1,$1,$chan), %x = 1, %y, %z
  while (%x <= $nick(%targ,0)) {
    var %nick = $nick(%targ,%x), %addr = $address(%nick,2), %clones = $ialchan(%addr,%targ,0)
    if (%clones > 1) {
      inc %y
      if (%y == $2) || (%nick == $2-) || (%addr == $2-) {
        if ($prop == $null) || ($prop == nick) return %nick
        elseif ($prop == addr) return %addr
        elseif ($prop == clones) return %clones
        hinc -mu1 detectclones %addr
        return %nick
      }
      inc %z
    }
    inc %x
  }
  if ($2 == 0) return $iif(%z,%z,0)
}
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world