alias flood.kick { flood_punish kick $active }
alias flood.ban { flood_punish ban $active }
alias flood.mod { flood_punish +m $active }
on *:TEXT:*:#: flood_
on *:ACTION:*:#: flood_
on *:NOTICE:*:#: flood_
alias -l flood_punish {
if (!$istok(ban kick,$1,32)) {
if (($me isop $2) || ($me ishop $2)) {
mode $chan $1-
}
}
else {
var %q = $($+(%,flood_punish.,$cid,.,$2),2)
if (%q) {
if (($me isop $2) || ($me ishop $2)) {
var %wildsite = $gettok(%q,2,32)
mode $2 +b $gettok(%q,2,32)
if (%flood_ban) { .timer 1 %flood_ban if (($me isop $2 $+ ) || ($me ishop $2 $+ )) && ($me ison $2 $+ ) mode $2 -b %wildsite }
if ($1 == ban) { return }
var %nick = $gettok(%q,1,32), %lines = $gettok(%q,3,32), %secs = $gettok(%q,4,32)
if ((%nick isreg $2) || (%nick isvoice $2)) && (%nick ison $2) {
kick $2 %nick $(%flood_kick,2)
}
var %x = $ialchan(%wildsite,$2,0)
while (%x) {
var %nick = $ialchan(%wildsite,$2,%x).nick
if (%nick isreg $2) || (%nick isvoice $2) {
kick $2 %nick $(%flood_kick,2)
}
dec %x
}
}
}
}
}
alias -l flood_ {
if (%flood_protection) && (!$($+(%,flood_triggered.,$cid,.,$site),2)) {
if (%flood_opt & 1) && (($me isop $chan) || ($me ishop $chan)) || (%flood_opt !& 1) {
if (%flood_opt & 2) && (($nick isreg $chan) || ($nick isvoice $chan)) || (%flood_opt !& 2) {
var %q = $+($chan,.,$cid,.,$site)
var %f = $hget(flood_,%q)
if ($calc($ticks - $gettok(%f,1,32)) > $calc($gettok(%flood_reset,2,32) * 1000)) { unset %f }
if ($gettok(%f,2,32) >= $gettok(%flood_reset,1,32)) { unset %f }
if (!$len(%f)) { var %f = $ticks 0 }
hadd -m flood_ %q $gettok(%f,1,32) $calc($gettok(%f,2,32) + 1)
var %f = $hget(flood_,%q)
var %secs = $calc(($ticks - $gettok(%f,1,32)) / 1000)
var %lines = $gettok(%f,2,32)
var %x = $numtok(%flood_trigger,32)
while (%x) && (%lines) && (%secs) {
var %f = $gettok(%flood_trigger,%x,32)
var %l = $gettok(%f,1,58)
var %s = $gettok(%f,2,58)
if (%lines >= %l) && (%secs <= %s) {
echo $color(highlight) -t $chan * Channel Flood from $nick ( $+ $site $+ ): %lines lines in %secs seconds.
if (%flood_reaction == 3) {
var %kick_key = $replace($upper($gettok(%flood_fkeys,1,32)),s,Shift+,c,Ctrl+)
var %ban_key = $replace($upper($gettok(%flood_fkeys,2,32)),s,Shift+,c,Ctrl+)
echo $color(highlight) -t $chan * $iif(%kick_key != _,Press $+(,%kick_key,),Type /flood.kick) to kick/ban or $iif(%ban_key != _,$+(,%ban_key,),/flood.ban) to ban
}
elseif (%flood_reaction == 2) {
echo $color(highlight) -t $chan * Punishing by kick/ban
flood_punish kick $chan
}
elseif (%flood_reaction == 1) {
echo $color(highlight) -t $chan * Punishing by ban
flood_punish ban $chan
}
if (%flood_opt & 4) {
if (%flood_opt & 8) {
window -g2 $chan
}
if (%flood_opt & 16) && (%flood_switchbar) {
flash $(%flood_switchbar,2)
}
if (%flood_opt & 32) && (($active != $chan) || ($activecid != $cid)) {
echo $colour(highlight) -ta * Flood protection triggered in $chan on $network
}
}
set $+(%,flood_punish.,$cid,.,$chan) $nick $wildsite %lines %secs
set -u60 $+(%,flood_triggered.,$cid,.,$site) 1
break
}
dec %x
}
}
}
}
}
on *:EXIT: {
unset %flood_triggered.*
unset %flood_punish.*
}
on *:LOAD: {
unset %flood_triggered.* %flood_punish.* %flood_trigger %flood_protection %flood_opt %flood_reset $&
%flood_switchbar %flood_kick %flood_ban %flood_reaction
set %flood_opt 29
set %flood_kick Text Flood: $+(%,lines) lines in $+(%,secs) seconds.
set %flood_switchbar Flood in $!chan on $!network
set %flood_trigger 5:5.5 7:9 8:10 12:15 17:27
set %flood_reset 18 28
set %flood_reaction 3
set %flood_fkeys _ _ _
}
on *:START: {
unset %flood_triggered.*
unset %flood_punish.*
}
on *:UNLOAD: {
unset %flood_triggered.* %flood_punish.* %flood_trigger %flood_protection %flood_opt %flood_reset $&
%flood_switchbar %flood_kick %flood_ban %flood_reaction %flood_fkeys
}
menu channel,menubar {
Channel Text Flood Protection
.$iif(%flood_protection,$style(1)) Use Flood Protection:set %flood_protection $iif(%flood_protection,0,1)
.$iif(%flood_opt & 1,$style(1)) Use only when opped/hopped:set %flood_opt $iif(%flood_opt & 1,$calc(%flood_opt - 1),$calc(%flood_opt + 1))
.$iif(%flood_opt & 2,$style(1)) Do not use for other ops/hops:set %flood_opt $iif(%flood_opt & 2,$calc(%flood_opt - 2),$calc(%flood_opt + 2))
.Change Kick Message: {
var %k = $input(Enter kick message. Use $+(%,nick) $+ $chr(44) $+(%,lines) and $+(%,secs) variables.,e,Input Request,%flood_kick)
if (%k) {
set %flood_kick %k
}
else {
set %flood_kick Text Flood: $+(%,lines) lines in $+(%,secs) seconds.
}
}
.Set Ban Time [[ $+ $iif(%flood_ban,$+($v1,s),Disabled) $+ ]:set %flood_ban $input(Enter ban time in seconds (0 to disable):,e)
.-
.Alert
..$iif(%flood_opt & 4,$style(1)) Alert me when protection is triggered:set %flood_opt $iif(%flood_opt & 4,$calc(%flood_opt - 4),$calc(%flood_opt + 4))
..-
..$iif(%flood_opt & 8,$style(1)) Highlight the window button:set %flood_opt $iif(%flood_opt & 8,$calc(%flood_opt - 8),$calc(%flood_opt + 8))
..$iif(%flood_opt & 16,$style(1)) Flash the mIRC taskbar button: {
if ($mouse.key !& 4) { set %flood_opt $iif(%flood_opt & 16,$calc(%flood_opt - 16),$calc(%flood_opt + 16)) }
if (%flood_opt & 16) || ($mouse.key & 4) {
set %flood_switchbar $iif($input(Enter message to flash. Use $!nick $+ $chr(44) $!network and $!chan identifiers.,e,Input Request,%flood_switchbar),$v1,Flood in $!chan on $!network)
}
}
..$iif(%flood_opt & 32,$style(1)) Dispay message in active window:set %flood_opt $iif(%flood_opt & 32,$calc(%flood_opt - 32),$calc(%flood_opt + 32))
.Reaction
..$iif(%flood_reaction == 1,$style(1)) Ban host: { set %flood_reaction 1 }
..$iif(%flood_reaction == 2,$style(1)) Kick/Ban user and clones: { set %flood_reaction 2 }
..$iif(%flood_reaction == 3,$style(1)) Let me choose: { set %flood_reaction 3 }
.Triggers
..Add Trigger:flood_add_trigger
..-
..$submenu($flood_trigger($1))
.Fkeys
..Punish with kick/ban
...$submenu($fkeys(kick,$1))
..Punish with ban
...$submenu($fkeys(ban,$1))
..Moderate channel
...$submenu($fkeys(mod,$1))
.-
.Set Defaults:{
if ($input(Reset all flood protection options to defaults?,yv) == $yes) {
unset %flood_*
set %flood_opt 29
set %flood_kick Text Flood: $+(%,lines) lines in $+(%,secs) seconds.
set %flood_switchbar Flood in $!chan on $!network
set %flood_trigger 5:5.5 7:9 8:10 12:15 17:27
set %flood_reset 18 28
set %flood_reaction 3
set %flood_fkeys _ _ _
}
}
}
alias -l fkeys {
if ($2 == begin) { set %flood_fkeys_temp 0 }
if ($2 == end) { unset %flood_fkeys_temp }
if ($2 isnum) {
tokenize 32 $1 %flood_fkeys_temp
var %div = $int($calc($2 / 12))
var %mod = $calc(($2 % 12) + 1)
if (%div >= 3) { return }
var %alias = $+($replace(%div,0,$null,1,s,2,c),f,%mod)
var %cmd = $isalias(%alias).alias
if ($gettok(%cmd,1,32) != $+(flood.,$1)) && ($len(%cmd)) { var %return = $style(2) }
if ($gettok(%cmd,1,32) == $+(flood.,$1)) { var %return = $style(1) }
inc %flood_fkeys_temp
return %return $+($replace(%div,0,$null,1,Shift+,2,Ctrl+),F,%mod) $+ :flood_fkeys_set %alias $1
}
}
alias -l flood_fkeys_set {
var %x = $replace($2,kick,1,ban,2,mod,3)
var %old_alias = $gettok(%flood_fkeys,%x,32)
if ($isalias(%old_alias).alias == $+(flood.,$2)) {
.alias %old_alias
}
if (%old_alias != $1) {
.alias $1 $+(flood.,$2)
set %flood_fkeys $puttok(%flood_fkeys,$1,%x,32)
}
else {
set %flood_fkeys $puttok(%flood_fkeys,_,%x,32)
}
}
alias -l flood_trigger {
if ($1 <= $numtok(%flood_trigger,32)) {
var %q = $gettok(%flood_trigger,$1,32)
return $gettok(%q,1,58) lines in $gettok(%q,2,58) seconds:flood_set_trigger $1
}
if (!$numtok(%flood_trigger,32)) && ($1 = 1) {
return $style(2) No triggers defined:/
}
}
alias -l flood_add_trigger {
var %lines = $input(Enter number of lines:,e)
var %seconds = $input(Enter number of seconds:,e)
if (%lines isnum) && (%seconds isnum) {
%flood_trigger = %flood_trigger $+(%lines,:,%seconds)
}
flood_update_reset
}
alias -l flood_set_trigger {
var %q = $gettok(%flood_trigger,$1,32)
var %d = $input(Do you want to delete this entry or update it? $crlf $+ Click YES to DELETE it. $crlf $+ Click NO to UPDATE it.,nv)
if (%d == $cancel) { return }
elseif (%d == $yes) {
%flood_trigger = $iif($deltok(%flood_trigger,$1,32),$v1,"")
}
elseif (%d == $no) {
var %lines = $input(Enter number of lines:,e,Input Request,$gettok(%q,1,58))
var %seconds = $input(Enter number of seconds:,e,Input Request,$gettok(%q,2,58))
if (%lines isnum) && (%seconds isnum) {
%flood_trigger = $puttok(%flood_trigger,$+(%lines,:,%seconds),$1,32)
}
}
flood_update_reset
}
alias -l flood_update_reset {
var %x = $numtok(%flood_trigger,32)
while (%x) {
var %f = $gettok(%flood_trigger,%x,32)
var %lines = $gettok(%f,1,58) %lines
var %secs = $gettok(%f,2,58) %secs
dec %x
}
var %highlines = $gettok($sorttok(%lines,32,nr),1,32)
var %highsecs = $gettok($sorttok(%secs,32,nr),1,32)
set %flood_reset $calc(%highlines + 1) $calc(%highsecs + 1)
}