alias clonescan {
  window -kl15 @Clonescan 100 85 800 494 Arial
  titlebar @Clonescan - Clone Détection 1.0 Par Causerie.
  clear @clonescan | clear -l @clonescan
  aline @clonescan  
  aline @clonescan $c(3) »»» $c(1) Whois Report $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Nick  : $c(2) $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Name  :  $c(2) $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Address: $c(2) $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Channel: $c(2) $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Server: $c(2) $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Idle : $c(2) $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Away: $c(2) $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1) IRCop: $c(2) $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1)  $+ $str( ,90)
  alnull 13
  aline @clonescan $c(3) »»» $c(1)  $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Clone Detection Process $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Status: $c(2) Processing Please Wait... $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Channel:  $c(2) $1 $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Scan: $c(2) 0 / $nick($1,0) [0%] $+ $str( ,90)
  aline @clonescan $c(3) »»» $c(1) Clones: $c(2) 0 / 0 [0%] $+ $str( ,90)
  aline -l @clonescan $c(1) $+ Nicks 
  aline -l @clonescan  
  set %_clone.chan $1
  if ($chan($1).ial == $true) { stat Scaning For Clones... | clscan }
  else { .ial on | set %_clone.who 1 | .who $1 }
}
alias -l alnull { var %i = $1 | :next | dec %i | aline @clonescan $chr(160) | if (%i != 0) goto next }
alias -l stat { rline -h @clonescan $calc($line(@clonescan,0) - 3) $c(3) »»» $c(1) Status: $c(2) $1- $+ $str( ,90) }
alias -l scan {
  rline -h @clonescan $calc($line(@clonescan,0) - 1) $c(3) »»» $c(1) Scanned : $c(2) $1 / $2 [ $+ $round($calc($1 / $2 * 100),0) $+ % $+ $chr(93) $+ $str( ,90)
  rline -h @clonescan $line(@clonescan,0) $c(3) »»» $c(1) Clones: $c(2) $3 / $1 [ $+ $round($calc($3 / $1 * 100),0) $+ % $+ $chr(93) $+ $str( ,90)
}
alias -l clone { rline -h @clonescan $line(@clonescan,0) $c(3) »»» $c(1) Clones: $c(2) $1 / $2 [ $+ $round($calc($1 / $2 * 100),0) $+ % $+ $chr(93) $+ $str( ,90) }
alias -l stm {
  dline @clonescan 13
  iline -h @clonescan 23 $1-
}
alias -l colr {
  if ($istok(0|11|15|9|8,$colour(background),124) == $true) {
    if ($1 == info) return 1
    if ($1 == addr) return 2
    if ($1 == other) return 1
  }
  else {
    if ($1 == info) return 15
    if ($1 == addr) return 15
    if ($1 == other) return 14
  }
}
alias -l clchan {
  var %tmp = $line(@Clonescan,$calc($line(@Clonescan,0) - 2))
  return $left($right(%tmp,-20),$calc($pos($right(%tmp,-20), ,1) - 1))
}
alias -l clkick {
  if (($left($2,1) == ) || ($left($2,1) ==  )) halt
  set %_clone.tmp %_clone.tmp $+ $gettok($strip($2),2,160) $+ , 
  if ($3 == ban) mode $clchan +b $address($gettok($strip($2),2,160),3)
  kick $clchan $gettok($strip($2),2,160) Clones Detected
  if ($numtok(%_clone.tmp,160) == $1) {
    stm  $+ $colr(info) $iif($3 != ban,Kicking     :,Kickbaning  :) [ $+ $left(%_clone.tmp,-2) $+ ] $+ $colr(other) from [ $+ $addr $+ $clchan $+ ]
    unset %_clone.tmp
  }
}
alias -l clquery { if (($left($strip($1),13) ==  -= Nicks =- ) || ($left($1,1) ==  )) halt | query $gettok($strip($1),2,160) }
alias -l clwhois {
  if (($left($strip($1),13) ==  -= Surnoms =- ) || ($left($1,1) ==  )) halt
  set %_clone.whois 1
  whois $gettok($strip($1),2,160)
  var %i 9 | :next | dec %i | clr %i | if (%i != 1) goto next
  clr 8 No
  clr 7 Cet usage n'est pas Away (Parti)
  clr 6 0secs
}
alias -l clr {
  var %tmp = $line(@clonescan,$calc(2 + $1))
  rline -h @clonescan $calc(2 + $1) $left(%tmp,20) $2- $+ $str( ,90)
}
alias -l clscan {
  var %num = $nick(%_clone.chan,0)
  var %i = $calc(%num + 1), %addr, %j, %tmp, %k = 0, %q = 0
  :next
  dec %i
  scan $calc(%num - %i) %num %k
  if ($ialchan($address($nick(%_clone.chan,%i),2),%_clone.chan,0) > 1 && $istok(%addr,$address($nick(%_clone.chan,%i),2),169) == $false) {
    inc %q
    %addr = $addtok(%addr,$address($nick(%_clone.chan,%i),2),169)
    %tmp =  $+ $colr(addr)
    %j = $calc($ialchan($address($nick(%_clone.chan,%i),2),%_clone.chan,0) + 1)
    :next2
    inc %k
    dec %j
    %tmp = %tmp $+ $gettok($ialchan($address($nick(%_clone.chan,%i),2),%_clone.chan,%j),1,33) $+ , 
    if ($calc(%q % 2) == 0) { aline -l @clonescan  $+ $colr(info) $+  $+ %q $+ . $+ $chr(160) $+ $gettok($ialchan($address($nick(%_clone.chan,%i),2),%_clone.chan,%j),1,33) }
    else { aline -l @clonescan 14 $+  $+ %q $+ . $+ $chr(160) $+ $gettok($ialchan($address($nick(%_clone.chan,%i),2),%_clone.chan,%j),1,33) }
    if (%j != 1) goto next2
    stm $c(3) »»» $c(1) Clones Found : 14[ $+ $left(%tmp,-2) $+ 14] $+ $colr(other) Address: 14( $+ $colr(addr) $+ $address($nick(%_clone.chan,%i),2) $+ 14)
    clone %k $calc(%num - %i)
  }
  if (%i != 0) goto next
  unset %_clone.chan
  scan %num %num %k
  if (%k == 0) { stm  $+ $colr(info) No Clones Found. }
  stat Scan Completed.
}
raw 301:*:{ if (%_clone.whois == 1) { clr 7 $3- | halt } }
raw 311:*:{ if (%_clone.whois == 1) { clr 1 $2 | clr 2 $6- | clr 3 $3 $+ @ $+ $4 | halt } }
raw 312:*:{ if (%_clone.whois == 1) { clr 5 $3- | halt } }
raw 313:*:{ if (%_clone.whois == 1) { clr 8 Yes | halt } }
raw 317:*:{ if (%_clone.whois == 1) { clr 6 $duration($3) | halt } }
raw 319:*:{ if (%_clone.whois == 1) { clr 4 $3- | halt } }
raw 318:*:{ if (%_clone.whois == 1) { unset %_clone.whois | halt } }
raw 401:*:{
  if (%_clone.whois == 1) {
    unset %_clone.whois
    var %i 9 | :next | dec %i | clr %i | if (%i != 1) goto next
    stm  $+ $colr(info) Whois       : $+ $colr(other) No Such User (User is not on IRC)
    halt
  }
}
raw 352:*:if (%_clone.who == 1) { haltdef }
raw 315:*:{
  if (%_clone.who == 1) {
    stat Scan For Clones...
    unset %_clone.who
    clscan
    halt
  }
}

menu @Clonescan {
  dclick:clwhois $sline(@Clonescan,1)
  $iif($mouse.win == $null,&Whois):clwhois $1
  $iif($mouse.win == $null,&User central):if (($left($strip($1),13) !=  -= Nicks =- ) && ($left($1,1) !=  )) uwho $gettok($strip($1),2,160)
  $iif($mouse.win == $null,&Query):.timer 1 0 clquery $*
  -
  $iif($mouse.win == $null && $me isop $clchan,&Kick):{
    set %_clone.tmp  $+ $colr(addr)
    .timer 1 0 clkick $numtok($1-,32) $*
  }
  $iif($mouse.win == $null && $me isop $clchan,Kick&ban):{
    set %_clone.tmp  $+ $colr(addr)
    .timer 1 0 clkick $numtok($1-,32) $* ban
  }
  $iif($mouse.win != $null,&Refresh):clonescan $clchan
  -
  $iif($mouse.win != $null,&About):clabout
}

alias -l clabout {
  stm $c(3) »»» $c(1) Clone Détection 1.0 Par Causerie 
  stm $c(3) »»» $c(1) Copyright © 2000 Causerie.            
  stm $c(3) »»» $c(1) Tout droit réservé.                  
}
