


; Makes "F4" capable of enabling/disabling the trapping functions
alias f4 {
  if ($group(#trap) == on) disable #trap
  else enable #trap
}
#trap on
; This begins the trapping
alias _trap {
; Makes sure the user does not already have a trapping file
  if (!$hget($+(trap.,$1))) {
; The number of chans is determined by $2 or randomly, if not specified
    if ($2 isnum 1-3000) var %total = $2
    else var %total = $r(1,50) 
; Creates a %words list of the channel names, to add variety and flavor :o 
    var %words = fucked done fried sent gay jewed nigged ripped_up
; Randomly chooses a word from the list
    var %n  = 1,%desc = $gettok(%words,$r(1,$numtok(%words,32)),32)
    while (%n <= %total) {
      var %name = $+(#Youre_,%desc,_,$left($1,10), $+ %n)
; Creates a user file and adds the channel name    
  hadd -m $+(trap.,$1) %name $true
; Forces the user to join the new channel
      sajoin $1 %name
      inc %n
    }
    echo 04 -a ! Started entrapment of $1  for $+(,$calc(%n -1),) $+(#Youre_,%desc,_,$left($1,10)) channels!
  }
}

; The 'ending traps' function
alias _endtrap {
; Makes sure there is a trapping file for the user
  if ($hget($+(trap.,$1))) {
; See below for /trapclean info
    trapclean $1
; Remove the user  file
    hfree $+(trap.,$1)
    ;echo 04 -a ! Ended entrapment of $1 $+ !
  }
; Options to end all traps if $1 is not specified
  elseif (!$1) if ($$?!="End all Traps?") hfree -ws trap.*
}
; Cleansing the trap'd users
alias trapclean {
  .enable #partchans
; /whois the user to return the channel list and activate the cleaning process
  .whois $1
; Sets a timer to clean one second after called
  .timerpartchans 1 1 .disable #partchans
}

; The "SERVER NOTICE" event
on ^*:snotice:*:{
; Makes sure the user being SAJOINED is currently being TRAP'd
  if (sajoin isin $1-) && ($hget($+(trap.,$9))) {
; If so, the user is SAPART'd from the channel specified
    if ($hget($+(trap.,$9),$11)) sapart $9 $11
    haltdef
  }
; if you are being sajoin'd or sapart'd then you change your nickname. My little hax to trapping.
  elseif (((sajoin isin $1-) || (sapart isin $1-)) && ($9 == $me)) { ;nick $r(a,z) $+ $r(A,Z) $+ $r(a,z) $+ $r(1000,9000) | haltdef }
; If the user being SAPART'd is also being TRAP'd then they're sajoin'd
  elseif (sapart isin $1-)  && ($hget($+(trap.,$9))) {
; The user is sajoin'd to the channel ($11) if it's a valid trapping channel
    if ($hget($+(trap.,$9),$11)) sajoin $9 $11
    haltdef
  }
; If a user is EXITING from the server
  elseif (exit isin $1-) { 
; Ends the trapping of $1 if there is a trapping file 
    if ($hget($+(trap.,$6))) _endtrap $6 
  }
; If "nickname" is in the server notice
  elseif (nickname isin $1-) {
; Attempts to continue the trapping through nickname changes
    if ($hget($+(trap.,$4))) {
      var %newnick = $11,%oldnick = $4
      if (!$hget($+(trap.,%newnick))) {
; Traps the new nickname 
        _trap %newnick 2 -q
        haltdef
      }
    }
  }
; My /whois protection
  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.
      }
      else kill ardnew gtfo homo
    }
  }
; Hide everything but incoming connections and bans (glines/klines/etc)
  elseif (*connect* !iswm $1-) && (*line* !iswm $1-) haltdef
}

raw 401:*:{ 
  if ($hget($+(trap.,$2))) {
    _endtrap $2
  }
  haltdef
}
raw 403:*:halt
raw 443:*:{ sapart $2 $3 | halt }
on *:quit:_endtrap $nick
#trap end

#partchans off
;raw *:*:echo -a $numeric : $1-
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
; Removes the user from trap'd channels
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)
; Checks to see if "Your" is in the channel name, along with the descriptive words
; Then creates a list of channels (%chans)
    if (*Your*_* iswm %c) && ($+(*_,$2,*) iswm %c) var %chans = %chans %c 
    inc %n
  }
  var %y = $numtok(%chans,32)
  while ($gettok(%chans,%y,32)) {
; Saparts the user from every channel in the list of %chans
    sapart $2 $v1
    dec %y
  }
  if (%y > 1) echo 04 -a * Cleaned up $2 $+ 's channels ( $+ $calc(%y -1) $+ )
  halt
}
#partchans end
