; ; Pluggable flood detection ; v0.01 ; For use with mIRC 5.91+ ; Written by Bekar (EFNet @#mIRC) ; For support, or bug reporting, please email: bekar@virtual.net.au ; ; This routine basically gives the identifier $fludd(). An example on how it ; can be used is shown below ; ;ON *@:TEXT:*:#mIRC: { ; if $fludd($address, CTEXT $+ # ,6,9) { ; .raw mode # +b $mask($fulladdress,3) $+ $lf $+ kick # $nick :Channel text flood. ; } ;} ; ; This detects 6 lines of text within 9 seconds, using the persons '$address' ; as the unique identifier, with a flood type of 'CTEXT#mIRC' (channel text ; of #mIRC). ; ; The first two can be anything of your choosing. The last two have to be ; numerical values. ; ; It relies upon a single offline timer, but this can also be altered to an ; event if desired (just so long as it gets triggered periodically). This ; timer cleans out old records from the fludd table. ; ON *:LOAD: { if (!$isdir(Fludd)) { mkdir Fludd hadd -m Fludd.Settings Timeout 3600 hsave Settings.hsh } } ON *:START: { if ($isfile(Fludd\Settings.hsh)) { hmake Fludd.Settings hload Fludd.Settings Fludd\Settings.hsh } else { mkdir Fludd hadd -m Fludd.Settings Timeout 3600 hsave Settings.hsh } var %Counter = 1 if ($hmatch(Fludd.Settings, TBL:*, 0) > 0) { while (%Counter <= $hmatch(Fludd.Settings, TBL:*, 0)) { if ($hget(Fludd.Settings, $hmatch(Fludd.Settings, TBL:*, %Counter)) < $calc($ctime - $hget(Fludd.Settings, Timeout))) { .remove Fludd\ $+ $mkfn($gettok($hmatch(Fludd.Settings, TBL:*, %Counter), 2, 58)) $+ .hsh hdel Fludd.Settings $hmatch(Fludd.Settings, TBL:*, %Counter) continue } else { hmake $gettok($hmatch(Fludd.Settings, TBL:*, %Counter), 2, 58) hload $gettok($hmatch(Fludd.Settings, TBL:*, %Counter), 2, 58) Fludd\ $+ $mkfn($gettok($hmatch(Fludd.Settings, TBL:*, %Counter), 2, 58)) $+ .hsh inc %Counter } } } .timerFludd -o 0 3600 DoFluddStuff } alias DoFluddStuff { FluddCtrl FluddClean } ON *:UNLOAD: { FluddCtrl Unload } ON *:DISCONNECT: { FluddCtrl } alias FluddCtrl { var %Counter = 1 if ($hmatch(Fludd.Settings, TBL:*, 0) > 0) { while (%Counter <= $hmatch(Fludd.Settings, TBL:*, 0)) { if ($hget(Fludd.Settings, $hmatch(Fludd.Settings, TBL:*, %Counter)) < $calc($ctime - $hget(Fludd.Settings, Timeout))) { .remove Fludd\ $+ $mkfn($gettok($hmatch(Fludd.Settings, TBL:*, %Counter), 2, 58)) hfree $gettok($hmatch(Fludd.Settings, TBL:*, %Counter), 2, 58) hdel Fludd.Settings TBL: $+ $gettok($hmatch(Fludd.Settings, TBL:*, %Counter), 2, 58) } else { hsave -o $gettok($hmatch(Fludd.Settings, TBL:*, %Counter), 2, 58) Fludd\ $+ $mkfn($gettok($hmatch(Fludd.Settings, TBL:*, %Counter), 2, 58)) $+ .hsh if ($1 == Unload) { hfree $gettok($hmatch(Fludd.Settings, TBL:*, %Counter), 2, 58) } } inc %Counter } } } alias FluddClean { var %Tables = 1 while (%Tables <= $hmatch(Fludd.Settings, TBL:*, 0)) { var %Counter = 1, %Name = $gettok($hmatch(Fludd.Settings, TBL:*, %Tables), 2, 58) if ($hget(Fludd.Settings, TBL: $+ %Name) < $calc($ctime - $hget(Fludd.Settings, Timeout))) { .remove Fludd\ $+ $mkfn(%Name) hdel Fludd.Settings TBL: $+ %Name hfree %Name continue } else { while ($hmatch(%Name, *, 0) >= %Counter) { var %LineCounter = 1, %Mask = $hmatch(%Name, *, %Counter) ; Ok, now loop through the flood masks, and free them if old var %Line = $hget(%Name, %Mask) while ($numtok(%Line, 33) >= %LineCounter) { if ($gettok(%Line, %LineCounter, 33) < $calc($ctime - %Timeout)) { %Line = $deltok(%Line, %LineCounter, 33) if ($numtok(%Line, 33) >= %LineCounter) { continue } } inc %LineCounter } if ($numtok(%Line, 33) > 0) { hadd -m %Name %Mask %Line inc %Counter } else { hdel %Name %Mask } } } inc %Tables } } alias fludd { ; $1 person identifier ; $2 flood type ; $3 frequensy ; $4 period if (($3 !isnum) && ($4 !isnum)) { return $false } hadd Fludd.Settings TBL: $+ $2 $ctime var %Counter = 1, %Line = $addtok($hget( $2, $1 ), $ctime, 33) while ($numtok(%Line, 33) >= %Counter) { if ($gettok(%Line, %Counter, 33) < $calc($ctime - $4)) { %Line = $deltok(%Line, %Counter, 33) if ($numtok(%Line, 33) >= %Counter) { continue } } inc %Counter } if ($numtok(%Line, 33) > 0) { hadd -m $2 $1 %Line if ($numtok(%Line, 33) >= $3) { return $True } } else { hdel $2 $1 } return $False }