menu channel {
Scan # for clones:clonescan #
}
alias clonescan {
  if ($1 ischan) {
    unset %clone.*
    .remove clones.clz
    set %clone.start $ticks
    set %clone.start2 $time
    set %clone.all $nick($1,0)
    :start
    inc %clone.i
    if (%clone.address.done. [ $+ [ $address($nick($1,%clone.i),2) ] ] == $null) {
      set %clone.address.all. [ $+ [ $address($nick($1,%clone.i),2) ] ] $ialchan($address($nick($1,%clone.i),2),$1,0)
      if (%clone.address.all. [ $+ [ $address($nick($1,%clone.i),2) ] ] > 1) {
        inc %clone.groups
        :start2
        inc %clone.ii
        set %clone.address.nicks. [ $+ [ $ialchan($address($nick($1,%clone.i),2),$1,1) ] ] %clone.address.nicks. [ $+ [ $ialchan($address($nick($1,%clone.i),2),$1,1) ] ] & $userprefix($ialchan($address($nick($1,%clone.i),2),$1,%clone.ii).nick,$1) $+ $ialchan($address($nick($1,%clone.i),2),$1,%clone.ii).nick
        inc %clone.tot
        if (%clone.ii != %clone.address.all. [ $+ [ $address($nick($1,%clone.i),2) ] ]) { goto start2 }
        set %magick.text %clone.address.nicks. [ $+ [ $ialchan($address($nick($1,%clone.i),2),$1,1) ] ]
        set %magick.len $len(%magick.text)
        set %magick.magick $replace($right(%magick.text,$calc(%magick.len -1)),&,2&12)
        write clones.clz echo @clonez 4Group %clone.groups $+ :2  %clone.address.all. [ $+ [ $address($nick($1,%clone.i),2) ] ] Clones4:12 %magick.magick 2at site:12 $address($nick($1,%clone.i),2)
        unset %magick.*
        set %clone.address.done. [ $+ [ $address($nick($1,%clone.i),2) ] ] x
        unset %clone.ii
      }
    }
    if (%clone.i != %clone.all) { goto start }
    window -c @clonez
    if (%clone.tot != $null) {
      iecho CloneScan on12 $1 3took4 $calc(($ticks - %clone.start) / 1000) 3secs, and4 %clone.tot 3clones on4 %clone.groups 3groups was found.
      .timer -m 1 1200  window @clonez
      .timer -m 1 1250 .play -c $me clones.clz 2
    }
    else iecho Clonescanner Found 0 clones on $1
    unset %clone.*
  }
}
alias iecho {
  set %tsta $readini mirc.ini options n4
  if ($gettok(%tsta,12,44) == 1) { set %ts $timestamp }
  echo -a 3 $+ $+ %ts $+ *** 4 $+ $1 $+ 3 $2-
  if (Status isin $active) && (Window isin $active) {
    echo -a  $+ $colour(info) $+ -
  }
  unset %ts %tsta
}
