/floodprotect { if %floodProtectEnabled == 1 goto floodProtEnd /inc %floodCounter if %floodCounter == %maxMessages { %fpTime [ $+ [ %floodCounter ] ] = $ctime($asctime) if $calc(%fpTime [ $+ [ %floodCounter ] ] - %fpTime1) <= %maxSeconds { /fp set protect on } :shiftFloodMessageTimes /inc %i if %i == %maxMessages goto endShiftFloodMessageTimes %fpTime [ $+ [ %i ] ] = %fpTime [ $+ [ $calc(%i + 1) ] ] goto shiftFloodMessageTimes :endShiftFloodMessageTimes /unset %i /dec %floodCounter goto floodProtEnd } %fpTime [ $+ [ %floodCounter ] ] = $ctime($asctime) :floodProtEnd } /fp { if $$1 == set { if $$2 == maxmsgs { %maxMessages = $$3 %floodCounter = 0 /unset %fpTime* /echo # maxMessages set to $$3 } if $$2 == duration { %floodProtectDuration = $$3 /echo # duration set to $$3 } if $$2 == maxsecs { %maxSeconds = $$3 /echo # maxSeconds set to $$3 } if $$2 == protect { if $$3 == on { %floodProtectEnabled = 1 /timer 1 %floodProtectDuration /fp set protect off /echo # Flood protection activated. } else { %floodProtectEnabled = 0 /echo # Flood protection deactivated. } } } }