;:. SwEEt^M0uSSa (m0ussa@helpdesk.zaz.net)
;:. clone/ircop/away/address scanner vf3.0

alias -l i echo -a *** No $1 found $t
alias -l e echo -a *** Scan completed $t | did -i sc 8 3 +p 0 Total of $1 %title were found
alias -l t return ( $+ $calc(($ticks - %_tk) / 1000) $+ s $+ ) 
alias -l c var %i = 1 | while ($comchan($1,%i)) { var %x = $ifmatch | var %x = $remove($nick(%x,$1).pnick,$1) $+ %x | var %z = $addtok(%z,%x,44) | inc %i } | if (%z) return $sorttok(%z,44) | else return none
alias -l gk return $gettok($did($dname,2,$did($dname,2).sel),$1,32)
alias udll return $scriptdirmdx.dll
alias vdll return $scriptdirviews.mdx
alias bdll return $scriptdirbars.mdx
on 1:LOAD:{
  if ($version < 5.91) { echo $colour(info) -a *** You need at least mIRC 5.91 to run this script. You can download it from http://www.mirc.co.uk | .unload -nrs $script | return }
  else { echo $colour(info) -a *** scanner vf3.0 by SwEEt^M0uSSa has been succesfully loaded! Check your channel popups to get started. }
}
on me:*:JOIN:#:{ who $chan }
alias -l clone.do {
  var %cc = $did(sc,1).text , %cn = $gettok($did(sc,2,$did(sc,2).sel),16-,32) , %h = $gettok($did(sc,2,$did(sc,2).sel),6,32)
  var %i = 1
  while (%i <= $numtok(%cn,32)) {
    var %num $calc($numtok(%cn,32) - 1)
    if ($1 == 1) { .notice $gettok(%cn,%i,32) Please get rid of your $iif($numtok(%cn,32) == 2,clone,%num clones) ( $+ %h $+ ) on %cc }
    elseif ($1 == 2) { kick %cc $gettok(%cn,%i,32) Clone %i out of $numtok(%cn,32) ( $+ %h $+ ) }
    elseif ($1 == 3) { ban %cc %h | kick %cc $gettok(%cn,%i,32) Clone %i out of $numtok(%cn,32) ( $+ %h $+ ) }
    inc %i
  }
}
alias -l clone.scan {
  unset %yes
  if ($active ischan) { 
    echo -a *** Scanning # for clones..
    if ($hget(clones)) { hfree clones | hmake clones $nick($active,0) }
    else { hmake clones $nick($active,0) }
  }
  else { return }
  set %_tk $ticks
  var %i = 1
  while (%i <= $nick(#,0)) {
    hadd clones $address($nick(#,%i),2) $hget(clones,$address($nick(#,%i),2)) $nick(#,%i)
    inc %i
  }
  clone.report
}
alias -l clone.report {
  var %n,%i = 1
  while (%i <= $hget(clones,0).item) {
    if ($numtok($hget(clones,$hget(clones,%i).item),32) > 1) {
      if (!$dialog(sc)) { dialog -m sc sc | dialog -t sc Clones | did -a sc 1 # | did -i sc 8 3 +p 0 Scanning for Clones... }
      did -a sc 2 $hget(clones,%i).item $chr(9) $numtok($hget(clones,$hget(clones,%i).item),32) $chr(9) $hget(clones,$hget(clones,%i).item)
      inc %n
      did -i sc 8 3 +p 0 Total of %n item(s) were found
    }
    inc %i
  }
  if (!$dialog(sc)) { echo -a *** No clones found ( $+ $calc($ticks - %_tk) $+ ms $+ ) }
  else { echo -a *** Scan completed ( $+ $calc($ticks - %_tk) $+ ms $+ ) | unset %_tk }
  hfree clones
}
alias -l list.nicks {
  var %cn = $$1 , %cc = $$2 | set %title $$3 
  if (!$dialog(sc)) { dialog -m sc sc | dialog -t sc %title | did -a sc 1 %cc }
  did -a sc 2 %cn $chr(9) $iif(%scan == 3,%addop,$address(%cn,1) $chr(9)) $iif(%scan == 1 || %scan == 2,$iif($remove($nick(%cc,%cn).pnick,%cn),$ifmatch,reg),$chr(32)) $chr(9) $+ $iif(%scan == 1 || %scan == 3,$iif($4 == yes,+ 1,+ 2),$chr(32))
  did -i sc 8 3 +p 0 Scanning for %title $+ ...
}
alias -l scan {
  unset %yes 
  if ($active ischan) {
    set %scan $$1 | set %_tk $ticks 
    if ($$1 == 1) { echo -a *** Scanning $chan for IRCops.. | who # }
    elseif ($$1 == 2) { echo -a *** Scanning $chan for Aways.. | who # } 
    elseif ($$1 == 3) { echo -a *** Scanning for IRCops.. (Global) | who 0 o }
    elseif ($$1 == 4) { if (*!*@* iswm $2) { echo -a *** Resolving nickname(s) for  $+ $2 (all chans) | var %i = 1 | window -h @tmp3 | while (%i <= $chan(0)) { var %cc = $chan(%i) | if ($chan(%i).ial) { var %na = $ialchan($2, %cc, 0),%xx = %na | if (!%na) || (%na < 1) { echo -a *** No nicknames were found ( $+ $2 $+ ) | goto end } | while (%na) { if (!$dialog(sc)) { dialog -m sc sc | dialog -t sc Address | did -a sc 1 All chans ( $+ $2 $+ ) } | var %cn = $ialchan($2, %cc, %na).nick | var %ca = $ialchan($2, %cc, %na).addr | aline @tmp3 %cn | if ($fline(@tmp3,%cn,0) == 1) { did -a sc 2 %cn $chr(9) %ca $chr(9) $c(%cn).pnick | inc %n | did -i sc 8 3 +p 0 Total of %n nick(s) were found } | dec %na } | inc %i
    } } } | :end | window -c @tmp3 | unset %scan %n } 
  }
}
dialog sc {
  title ""
  size -1 -1 410 220
  box "",1, 10 5 390 190
  list 2, 20 23 370 150
  button "warn", 4, 110 170 55 20, disable
  button "kick", 5, 170 170 55 20, disable
  button "kban", 6, 230 170 55 20, disable
  button "clip", 7, 15 166 30 15, disable
  button "whois", 9, 140 170 55 20, disable
  button "query", 10, 200 170 55 20, disable
  list 8, 5 196 150 22, size
  button "close",3, 300 197 60 23,ok
}

on *:dialog:sc:*:*:{
  if ($devent == init) { 
    dll $udll SetMircVersion $version
    dll $udll MarkDialog sc
    dll $udll SetControlMDX sc 2 listview report nosortheader grid rowselect flatsb > $vdll 
    did -i sc 2 1 headerdims $iif(%scan == 1,90 173 51 47,$iif(%scan == 2,75 224 51,$iif(%scan == 3,120 180 53,$iif(%scan == 4,75 200 100,180 28 350))))
    did -i sc 2 1 headertext $iif(%scan == 1,Nickname: $chr(9) Address: $chr(9) Status: $chr(9) Away:,$iif(%scan == 2,Nickname: $chr(9) Address: $chr(9) Status:,$iif(%scan == 3,Nickname: $chr(9) Address: $chr(9) Away:,$iif(%scan == 4,Nickname: $chr(9) Address $chr(9) Channels:,Mask: $chr(9) #: $chr(9) Nicknames:))))
    if (%scan == 1) || (%scan == 3) { did -i sc 2 1 seticon list 0, $+ $scriptdir $+ yes.ico | did -i sc 2 1 seticon list 0, $+ $scriptdir $+ no.ico }
    dll $udll SetBorderStyle 3,4,5,6,9,10 staticedge
    dll $udll SetControlMDX sc 8 StatusBar > $bdll
    dll $udll SetBorderStyle 8
    did -i sc 8 1 setparts 300 -1
    did -i sc 8 2 1
    if (%scan) { did -h sc 4,5,6 | did -v sc 9,10 }
    else { did -v sc 4,5,6 | did -h sc 9,10 }
  }
  if ($devent == sclick) {
    if ($did == 2) { did -e $dname 7,4,9,10 | if ($me isop $active) { did -e $dname 5,6 } | else { halt } }
    elseif ($did == 4) { clone.do 1 }
    elseif ($did == 5) { clone.do 2 }
    elseif ($did == 6) { clone.do 3 }
    elseif ($did == 7) { var %l = $gk(6) $gk(11) $gk($iif(%yes,16,16-)) $gk(21) | clipboard %l }
    elseif ($did == 9) { if ($did($dname,2).sel) { whois $gk(6) } | else { halt } }
    elseif ($did == 10) { if ($did($dname,2).sel) { query $gk(6) } | else { halt } }
  }
  if ($devent == dclick) { 
    if ($did == 2) { whois $gk(6) }
  }
}

raw 352:*:{
  if (%scan == 1) { if (* isin $7) { inc %u.1 | list.nicks $6 $2 IRCops $iif(G isin $7,Yes,No) | set %yes 1 } | haltdef }
  elseif (%scan == 2) { if (G isin $7) { inc %u.2 | list.nicks $6 $2 Aways } | haltdef }
  elseif (%scan == 3) { inc %u.3 | set %addop $3 $+ @ $+ $4 | list.nicks $6 Global IRCops $iif(G isin $7,Yes,No) }
}

raw 315:*:{
  if (%scan == 1) { if (!%u.1) { i IRCops } | else { e %u.1 } }
  elseif (%scan == 2) { if (!%u.2) { i Aways } | else { e %u.2 } }
  elseif (%scan == 3) { if (!%u.3) { i IRCops } | else { e %u.3 } }
  unset %scan %u.* %title %_tk %addop
}
menu channel {
  scanner 
  .clones:/clone.scan # 
  .ircops 
  ..#:/scan 1  
  ..-
  ..global:/scan 3 
  .aways:/scan 2 
  .-
  .address:/scan 4 $input(nick!ident@host.domain.net (e.g: *!*@*.com),1)
}
;eof
