; BorgIRC - a01.mrc: Basic & internal aliases: Personal info, sound, (mass)kick, etc.
; -------------------------------------------------------------------------------------------------------------------------------

cc { 
  var %1 = $iif($1,$1,#)
  var %tmp = $_(bc003b,%1) $fm1($nick(%1,0,q) +q $nick(%1,0,o) +o $nick(%1,0,h) +h $nick(%1,0,v) +v)
  e -c $+ $colour(join) %1 %tmp 
  linesep %1
}
clone unset %clones | if ($ialchan($address($1,2),$2,0) < 2) return $null | var %c = 1 | :loop | if ($ialchan($address($1,2),$2,%c) != $null) { var %clones = %clones $ialchan($address($1,2),$2,%c).nick | inc %c | goto loop } | return %clones
clearban set %chan $active | set %clearban on | mode $active +b
ad $iif($active != Status window,da $_(bc007),a -c $+ %c.i3) $ad1
urlad ma $logo - $_url($core.url)
asl { 
  if ((%age == $null) || (%gender == $null) || (%loc == $null)) { fx comply | a $^err $_(bc008) | h } 
  else { if %asl == $null { set %asl 1 } | if %asl == 1 { me a/s/l: %age $+ / $+ %gender $+ / $+ %loc } | if %asl == 2 { me $_(bc009) }
  }
}
icq if %icq == $null { fx comply | a $^err $_(bc014) $_(bc017) | h } | else me 's ICQ UIN: $+ %c.ip2 %icq
msn.view if %msn == $null { fx comply | a $^err $_(bc014b) $_(bc017) | h } | else { me 's MSN address: $+ %c.ip2 %msn }
email if %email == $null { fx comply | a $^err $_(bc015) $_(bc017) | h } | else { me 's e-mail address: $+ %c.ip2 %email }
mysite { 
  if !%site || !%site.rev { fx comply | a $^err $_(bc016) $_(bc017) | h } 
  else { fx recon03 | ma $_(bc010) | say At: 12 $+ %site 
    if (%site.des) { say $_(bc011) $+  $+ %c.ip2 %site.des } 
  }
}

l2 return $chr(124)

info1 { linesep | ms mIRC $_(bc032) 9,1 $version 
  ms Script $_(bc032) 9,1 $borgver  | ms $_(bc033) 9,1 $iif($ip,$ip,unknown) 
  ms $_(bc034) 9,1 $iif($host,$host,unknown)  | ms $_(bc035) 9,1 $server  $_(bc035b) 9,1 $port 
  if (%count. [ $+ [ $netw ] ]) && (%countdate. [ $+ [ $netw ] ]) { ms $_(bc036) }
  if (%lvd. [ $+ [ $netw ] ]) && (%lvt. [ $+ [ $netw ] ]) { ms $_(bc038) }
  ms $_(bc039) $_(bc040) 9,1 $time  | ms $_(bc039) $_(bc041) 9,1 $date  | linesep | ms $_(bc042) 9,1 $me  
  linesep
  ms $_(bc043) $_url($core.url)
  if (!%bupd.counter) { %bupd.counter = 0 }
  if (%bupd.counter < 5) { inc %bupd.counter }
  ms $_(bc044)
  ;ms $_(bc047)

  linesep
  ms $_(bc045) 
}

timedcloak { 
  mode $me +i
  .timerinvis 1 1 fx invis
}

chknick { 
  var %on.lst = *hitler* *adolf* *stalin* *kanker* *cancer* *pr?zac* *fuck* *shit* *bitch* 
  if ($newnick) { var %nick = $newnick } 
  else { var %nick = $nick } 
  var %tmp = 0 
  :loop 
  inc %tmp 
  if %tmp > 10 { return }
  if ($gettok(%on.lst,%tmp,32) iswm %nick) {
    var %tmp2 = $v1 
    if ($newnick) { goto newnick } 
    if ($nick) { goto nick } 
  } 
  if $gettok(%on.lst,%tmp,32) { goto loop } 
  return
  :newnick 
  var %tmp = 0 
  :loop1 
  inc %tmp 
  if ($comchan(%nick,%tmp).op == $true) { 
    if (%on.w. [ $+ [ $site ] ] == on) {
      raw -q mode $comchan(%nick,%tmp) -o %nick
      ban -u600 $comchan(%nick,%tmp) %nick 2
      kick $comchan(%nick,%tmp) %nick Auto-ban (10 min.) - $_(bc048)
      return 
    } 
    else { 
      set -u50 %on.w. [ $+ [ $site ] ] on
      raw -q mode $comchan(%nick,%tmp) -o %nick 
      ban -u30 $comchan(%nick,%tmp) %nick 9 
      kick $comchan(%nick,%tmp) %nick Auto-ban (30 sec.) - $_(bc049)
    }
    if ($comchan(%nick,%tmp).op) { 
      goto loop1 
    }
  } 
  return
  :nick 
  if (%on.w. [ $+ [ $site ] ] == on) { 
    raw -q mode # -o %nick 
    ban -u600 # %nick 2
    kick # %nick Auto-ban (10 min.) - $_(bc048)
    return
  } 
  else {
    set -u50 %on.w. [ $+ [ $site ] ] on
    raw -q mode # -o %nick 
    ban -u30 # %nick 9 
    kick # %nick Auto-ban (30 sec.) - $_(bc049)
  } 
}

reset { if %META.Sd == on { inc %sh 1 | .timer47 off | .ignore -pnticr * | set %META.Sd off }
  if %^ctcp.Sd == on { inc %sh 1 | .ignore -tr * | set %^ctcp.Sd off }
  if %MSG.Sd == on {  inc %sh 1 | .ignore -pr * | set %MSG.Sd off }
  if %DCC.Sd == on { inc %sh 1 | set %DCC.Sd off }
  if %sh == $null || %sh == 0 { fx comply | h }
  unset %sh | off
}

whois { 
  if ($1 == $null) { fx unclear | s  $+ $colour(info) $+ /whois - $_(bc051) /whois nickname | h }
  if ($1 == -a) { %~e. [ $+ [ $2 ] ] = a } | if ($1 == -p) { %~e. [ $+ [ $2 ] ] = ma }
  if ($1 == -w) { if ($window(@whois) == $null) { window -a @whois } | %~e. [ $+ [ $2 ] ] = e @whois }
  if ($left($1,1) != $chr(45)) { set %~e. [ $+ [ $1 ] ] s | whois $1- } | else { whois $2- }
}

whowas %whowas = $true | s 14<15<6 $_(bc037) $+  $1 15>14> | whowas $1- | h
i { 
  if $address(%i.nick,2) == $address($me,2) && %i.nick == $me { fx comply | a $^err $_(bc052) | h } 
  set %i.time $$input($_(bc053),129) 
  if %i.time > 0 { set %i.parms $1 $+ u $+ %i.time } 
  if %i.time == 0 { set %i.parms $1 | unset %i.time } 
  on
  a $^(l.ign) $_(bc054) $+ %c.i %i.nick
  ignore %i.parms %i.nick 2 
  unset %i.*
}
at { 
  window -a @AsciiTable 
  aline 6 @Asciitable $_(bc055) 
  aline @Asciitable   
  var %num = 32 
  while (%num < 255) {
    inc %num 
    aline 6 @Asciitable %num $+ : $chr(%num) 
  }
  aline 6 @Asciitable $_(bc056)
}
vd { 
  if $calc(%v.d - $calc($ctime - %vtt)) < 1 { sv | h } 
  msg %v.c  $+ $_(bc057) $+  
  msg %v.c $_(bc058) $+ 2 %v.q 
  msg %v.c $_(bc059)
  msg %v.c $_(bc060)
}
cstats { 
  if $1 == -pu { var %tmp = ma } 
  else { var %tmp = $_a } 
  %tmp $_(bc061) $+ %c.ip2 # 
  if ($ircx) || ($isunreal) { %tmp  $nick(#,0,q)  $+ $_(bc062) $+ ( $+ $round($calc(($nick(#,0,q) / $nick(#,0))  * 100),1) $+ $chr(37) $+ ) } 
  %tmp  $nick(#,0,o)  $+ $_(bc063) $+ ( $+ $round($calc(($nick(#,0,o) / $nick(#,0))  * 100),1) $+ $chr(37) $+ ) 
  %tmp  $nick(#,0,h)  $+ $_(bc063b) $+ ( $+ $round($calc(($nick(#,0,h) / $nick(#,0))  * 100),1) $+ $chr(37) $+ ) 
  %tmp  $nick(#,0,v)  $+ $_(bc064) $+ ( $+ $round($calc(($vnick(#,0) / $nick(#,0)) * 100),1) $+ $chr(37) $+ ) 
  %tmp  $nick(#,0,a,qo)  $+ $_(bc065) $+ ( $+ $round($calc(($nick(#,0,a,qo) / $nick(#,0)) * 100),1) $+ $chr(37) $+ ) 
  %tmp  $nick(#,0)  $+ $_(bc066)
  %tmp $_(bc067) | fx scancomp 
}
vote if $tim(poll) == $false { dl.open vp }
adc if ($tim(207)) { fx comply } | else { dl.open ad }
sad  .timer203 off | .timer204 off | .timer205 off | .timer206 off | .timer207 off | .timer208 off

cscan {
  if $1 == -p { var %te = msg # } | else { var %te = a }
  set -u %^chan # | if $1 == -p { set -u %tmpecho msg $chan } | else { set -u %tmpecho $_a } 
  var %^t0 = $ticks | if (%^chan == $null) set -u0 %^chan $active 
  if (%^chan !ischan) { a $^err $_(bc069A) | return } 
  if ($chan(#).ial == $false) {
    .ial on
    a $_(bc070)
    a $_(bc071)
    return
  }
  window -hsl @c.s.a
  var %i = 1
  var %num = $nick(#, 0)
  var %address, %nick, %tmp, %cnt
  var %s = $ticks
  while (%i <= %num) {
    %nick = $nick(#, %i)
    %address = $address(%nick, 2)
    %tmp = %address $+ $chr(9) $+ *
    if ($fline(@c.s.a, %tmp, 1)) rline @c.s.a $v1 $line(@c.s.a, $v1) %nick
    else aline @c.s.a %address $+ $chr(9) $+ %nick
    inc %i
  }
  %i = 1 | var %nicks | while ($line(@c.s.a, %i)) { %tmp = $v1 | %nicks = $gettok(%tmp, 2, 9)
    if ($numtok(%nicks, 32) > 1) { 
      var %tmp0 = $replace(%tmp,$chr(9),$chr(32)) | var %tmp1 = $gettok(%tmp0,1,32) 
      var %tmp2 = $remove($replace(%tmp,$chr(9),$chr(32)),%tmp1) | inc %cnt $numtok(%tmp,32) 
      %te $fm2($numtok(%tmp,32)) clones van %c.i2 $+ %tmp1 $+ : $+ %c.i $+ %tmp2
    }
    inc %i 
  }
  fx scancomp
  if %cnt == 0 || %cnt == $null { %te $_(bc072) - $_(bc073) $calc($ticks - %^t0) $+ ms } 
  else { %te $_(bc072) - $_(bc074,%cnt,%^t0) }
  window -c @c.s.a
}
