This trap script is designed to /sajoin and /sapart a user from a specified amount of channels, occasionally causing them to disconnect from the server. The script is for IRCOps, and is intended for use on personal (or small/friendly) servers.
/trap [N] - Initiates the trapping script on $1 with $2 channels.
/endtrap [user] - Ends the trap for $1, or everyone if not specified.
$istrap(user) - Returns whether or not $1 is being "Trapped".
$totaltrap(user) - Returns the amount of channels $1 is being trapped in.
Everything is accessible through menus, such as detailed trapping information, and commands to start/stop the trapping. Enjoy.
Updates
04/16 Added the ability to trap users upon connecting to the server. x100 chans is the default trap-on-connect setting. Check the menu for options/list modifications.
on ^*:snotice:*:{
if (sajoin isin $1-) {
if ($istrap($9)) {
if ($4 == $me) {
hadd trap $+(chan.,$9,.,$11) 1
sapart $9 $11
haltdef
}
}
elseif ($timer($+(endtrap.,$9))) haltdef
}
elseif (sapart isin $1-) {
if ($istrap($9)) {
if ($4 == $me) {
if ($hget(trap,$+(chan.,$9,.,$11))) {
hdel trap $+(chan.,$9,.,$11)
hinc trap $+(user.,$9)
}
sajoin $9 $11
haltdef
}
}
elseif ($timer($+(endtrap.,$9))) haltdef
}
elseif (exit isin $1-) {
if ($istrap($6)) {
var %t = $totaltrap($6)
endtrap $6
}
}
elseif (nickname isin $1-) {
if ($istrap($4)) {
if (!$istrap($11)) trap $11
endtrap $4
haltdef
}
}
elseif (connect isin $1-) {
if ($octswitch) {
var %addy = $+($9,!,$remove($10,$chr(40),$chr(41)))
var %n = 1
while ($gettok($octrap,%n,44)) {
if ($v1 iswm %addy) {
trap $gettok($octrap,%n,44) 100
return
}
inc %n
}
}
}
}
alias octrap return %octrap
alias octswitch {
if (%octswitch == $null) set %octswitch $true
return %octswitch
}
alias istrap return $iif($hget(trap,$+(user.,$1)),$true,$false)
alias totaltrap return $hget(trap,$+(user.,$1))
alias trap {
if (!$istrap($1)) {
hadd -m trap $+(user.,$1) 1
var %n = 1,%total = $iif($2 isnum 1-500,$2,15)
while (%n <= %total) {
var %name = $+($chr(35),$qcn)
sajoin $1 %name
inc %n
}
}
}
alias qcn return $remove($($str($!r(a,z) $+ $chr(32),$r(5,20)),2),$chr(32))
alias endtrap {
if ($istrap($1)) {
var %t = $totaltrap($1)
hdel -w trap $+(*.,$1,.*)
hdel -w trap $+(*.,$1)
.timerendtrap. $+ $1 1 5 $($iif(!$hfind(trap,user.*,0,w),hfree trap,return),2)
return * Trap stopped. $1 was trapped %t time(s).
}
else if ($$?!="End all traps?") if ($hget(trap)) hfree trap
}
alias octrapsub {
if ($1 == begin) return -
var %n = 1
while ($gettok($octrap,%n,44)) {
if ($1 == %n) return %n $+ . $gettok($octrap,%n,44) :return
inc %n
}
if ($1 == end) return -
}
menu nicklist {
Trap!
.$iif($istrap($1),Count $+ $chr(58) $totaltrap($1),Trap (xN)):$iif(!$istrap($1),trap $$1 $$?="How many times?",return)
.-
.$iif(!$istrap($1),$style(2) Quick Traps,End trap):$iif($istrap($1),endtrap $1,return)
.-
.$iif(!$istrap($1),x05 channels):trap $$1 5
.$iif(!$istrap($1),x10 channels):trap $$1 10
.$iif(!$istrap($1),x30 channels):trap $$1 30
.$iif(!$istrap($1),x50 channels):trap $$1 50
.-
.$iif(!$istrap($1),Killer trap!):trap $1 500
}
menu channel,menubar,status {
Trap!
.$iif($hfind(trap,user.*,0,w) > 0,Currently $+ $chr(58) $v1):return
.-
.Trap Someone:trap $$?="Enter nickname:" $$?="Enter channel amount (xN):"
.-
.$iif($hget(trap),End All):endtrap
.-
.On Connect
..$iif($octswitch == $true,Disable?,Enable!) : set $+(%,octswitch) $iif($octswitch,$false,$true)
..-
..List $iif($octrap,( $+ $numtok($octrap,44) $+ ))
...$submenu($octrapsub($1))
..-
..Add:{
var %r = $$?="Enter target's nick/address:"
if (@ !isin %r) {
if (! !isin %r) && (. !isin %r) var %r = %r $+ ! $+ *@*
elseif (. isin %r) var %r = *!*@ $+ %r
}
if (! !isin %r) var %r = *!* $+ %r
set $+(%,octrap) $iif(%octrap,$+(%octrap,$chr(44),%r),%r)
}
..$iif($octrap,Delete): set $+(%,octrap) $remtok($octrap,$$?="Enter target's nick/address:",1,44)
..-
..$iif($octrap,Clear): unset %octrap
}