; =================
; = LOCAL ALIASES
; --------------------------------------
alias trap.int return 0
; --------------------------------------
; =================
alias f4 {
  if ($group(#trap) == on) disable #trap
  else enable #trap
}
#trap on
alias _trap {
  if (!$hget($+(trap.,$1))) {
    if ($2 isnum 1-3000) var %total = $2
    else var %total = $r(1,50) 
    var %words = fucked done fried sent gay jewed nigged ripped_up
    var %n  = 1,%desc = $gettok(%words,$r(1,$numtok(%words,32)),32)
    while (%n <= %total) {
      var %name = $+(#Youre_,%desc,_,$left($1,10), $+ %n)
      hadd -m $+(trap.,$1) %name $true
      sajoin $1 %name
      inc %n
    }
    if ($3 !=== -q) echo 04 -t ! Started entrapment of $1  for $+(,$calc(%n -1),) $+(#Youre_,%desc,_,$left($1,10)) channels!
  }
}
alias _endtrap {
  if ($hget($+(trap.,$1))) {
    trapclean $1
    hfree $+(trap.,$1)
    ;echo 04 -a ! Ended entrapment of $1 $+ !
  }
  elseif (!$1) if ($$?!="End all Traps?") hfree -ws trap.*
}
alias trapclean {
  .enable #partchans
  .whois $1
  .timerpartchans 1 1 .disable #partchans
}
on ^*:snotice:*:{
  if (sajoin isin $1-) && ($hget($+(trap.,$9))) {
    if ($hget($+(trap.,$9),$11)) .timerpartint. $+ $11 $+ $9 1 $trap.int sapart $9 $11
    haltdef
  }
  elseif (((sajoin isin $1-) || (sapart isin $1-)) && ($9 == $me)) { ;nick $r(a,z) $+ $r(A,Z) $+ $r(a,z) $+ $r(1000,9000) | haltdef }
  elseif (sapart isin $1-)  && ($hget($+(trap.,$9))) {
    if ($hget($+(trap.,$9),$11)) .timerjoinint. $+ $11 $+ $9 1 $trap.int sajoin $9 $11
    haltdef
  }
  elseif (exit isin $1-) { 
    if ($hget($+(trap.,$6))) _endtrap $6 
  }
  elseif (connecting isin $1-) {
    var %nlist = GeckoPie
    if ($istok(%nlist,$9,44)) && (!$hget($+(trap.,$9))) _trap $9 100
  }
  elseif (nickname isin $1-) {
    if ($hget($+(trap.,$4))) {
      var %newnick = $11,%oldnick = $4
      var %n = $($+(%,trapad.,$address(%oldnick,3) ),2),%ip = $($+(%,trapip.,%oldnick),2)
      if (%n > 3) { 
        unset $+(%,trapad.,$address(%oldnick,3))
        if (%ip) shun %ip
        else kill %newnick >:(?!!?!?!!??!?!
      }
      else { 
        inc % $+ trapad. $+ $address(%oldnick,3)
        .enable getip
        .whois %newnick
      }
      ;echo -a $address(%newnick,3) : $address(%oldnick,3)
      if (!$hget($+(trap.,%newnick))) { 
        _trap %newnick 2 -q
        halt
      }
    }
  }
  elseif (/whois isin $1-) { 
    if (!$hget($+(trap.,$2))) { 
      if (!$istok(ardnew andrew,$2,32)) && (*okstate* !iswm $address($2,5)) {
        _trap $2 2
        .notice $2 04TRAP'D due to /WHOIS. DON'T FUCKING /WHOIS ME. (AUTOMATED RESPONSE)
      }
      else kill ardnew gtfo homo
    }
  }
  elseif (*connect* !iswm $1-) && (*line* !iswm $1-) haltdef
}
raw 401:*:{ 
  if ($hget($+(trap.,$2))) {
    _endtrap $2
  }
  haltdef
}
raw 403:*:halt
raw 443:*:{ .timerpartint. $+ $2 $+ $3 1 $trap.int sapart $2 $3 | halt }
on *:quit:_endtrap $nick
#trap end
;raw *:*:echo -a $numeric : $1-
#partchans off
raw 301:*:halt
raw 310:*:halt
raw 311:*:halt
raw 312:*:halt
raw 313:*:halt
raw 317:*:halt
raw 318:*:halt
raw 378:*:halt
raw 379:*:halt
raw 319:*:{
  ; $3- = chans; $2 = user
  var %chans,%n = 1
  while ($gettok($3-,%n,32)) {
    var %c = $v1
    if ($left(%c,1) != $chr(35)) var %c = $chr(35) $+ $gettok(%c,2-,35)
    if (*Your*_* iswm %c) && ($+(*_,$2,*) iswm %c) var %chans = %chans %c 
    inc %n
  }
  var %y = $numtok(%chans,32)
  while ($gettok(%chans,%y,32)) {
    sapart $2 $v1
    dec %y
  }
  if (%y > 1) echo 04 -a * Cleaned up $2 $+ 's channels ( $+ $calc(%y -1) $+ )
  halt
}
#partchans end
