alias scaning {
  set %n 0
  :loop1
  inc %n 1
  if ($nick(%ichan,%n) isin %istock) { goto end }
  if ($ialchan($address($nick(%ichan,%n),2),%ichan,0) > 1) {
    inc %itotal 1
    unset %inick | set %l 0
    :loop2
    inc %l 1
    if ($ialchan($address($nick(%ichan,%n),2),%ichan,%l).nick) {
      set %istock %istock $ialchan($address($nick(%ichan,%n),2),%ichan,%l).nick
      if ( $group(#modebot) != on ) { did -a sc 7 $ialchan($address($nick(%ichan,%n),2),%ichan,%l).nick }
      set %inick %inick + $ialchan($address($nick(%ichan,%n),2),%ichan,%l).nick 
      goto loop2
    }
    did -a sc 2 $right(%inick,-2) ¬ 
    did -a sc 2 $chr(160) $address($nick(%ichan,%n),2) 
  }
  :end
  if (%n < $nick(%ichan,0)) { goto loop1 }
  if (%n == $nick(%ichan,0)) { scend }
}

alias scend {
  %ipourcent = [ $calc(%itotal * 100) ] / %itnick
  did -a sc 4 Total: %itotal host ( $+ $int(%ipourcent) $+ % $+ )
  if (%itotal == 0) { did -a sc 2 ¬ Aucun clône détecté. }
  if (%itotal != 0) { did -e sc 3,5 }
  else { did -e sc 3 }
  unset %it*
  unset %in*
  unset %ip*
  unset %is*
}

#cln off
raw 352:*:/halt
raw 315:*:{
  if  ( $dialog(sc) = sc ) { .disable #cln | scaning }
  .disable #cln
  /halt
}
#cln end

alias sc {
  .ial on
  .enable #cln
  who #
  if ($dialog(sc) == sc) { halt }
  else { dialog -m sc sc }
  set %ichan #
  set %itnick $nick(#,0)
  set %itotal 0
  did -a sc 2 Détection de clones sur ( # ) en cours... 
  unset %inick
}

dialog sc {
  title "Détection de clones"
  size -1 -1 467 245
  button "", 1, 1000 1000 1 1, ok
  list 2, 10 10 300 156
  button "[ Ok ]", 3, 6 222 119 21, cancel
  text "", 4, 49 203 130 17
  button "Afficher Les Clones", 5, 78 171 154 21
  box "", 6, 321 4 1 160
  list 7, 332 10 120 158, sort
  button "Kicker", 8, 350 171 35 21
  button "KickBan", 9, 396 171 50 21
  edit "4,1Les 4clones0 ne sont pas autorisés !", 10, 230 219 234 23, autohs
  text "Message Du Kick - Ban :", 11, 230 200 119 16
  text "Clones :", 12, 7 203 39 16
}

on 1:dialog:sc:init:0:{ did -b sc 3,5,8,9 }

on 1:dialog:sc:sclick:*:{
  if ($did == 5) {
    set %c 0
    :loop
    inc %c 1
    msg $active 0,1 $did(sc,2,%c)
    if (%c < $did(sc,2).lines) { goto loop }
    msg $active %VersionCourte
  }
  if ($did == 7) { 
    if ($did(sc,7,$did(sc,7).sel).text != $null) { 
      did -e sc 8,9 
    } 
  }
  if ($did == 8) { kick %ichan $did(sc,7,$did(sc,7).sel).text $did(sc,10) | did -d sc 7 $did(sc,7).sel }
  if ($did == 9) { ban %ichan $did(sc,7,$did(sc,7).sel).text 7 | kick %ichan $did(sc,7,$did(sc,7).sel).text $did(sc,10) | did -d sc 7 $did(sc,7).sel }
}
