/*
 * Flood protection for TekNap
 * Author: Brian Weiss <brian@got.net> - 2000, 2001
 *
 * *NOTE* If AUTO_MUZZLE is true then this will do nothing for PUBLIC
 *        floods.
 */

assign AUTO_IGNORE_TIME 60
assign FLOOD_PROTECTION 0

alias fprot (arg, void)
{
	switch ($tolower($arg))
	{
		(0)
		(off)
		{
			^assign FLOOD_PROTECTION 0
		}
		(1)
		(on)
		{
			^assign FLOOD_PROTECTION 1
		}
		(*)
		{
			@ FLOOD_PROTECTION = FLOOD_PROTECTION ? [0] : [1]
		}
	}

	xecho -b Flood protection has been ${FLOOD_PROTECTION ? [activated] : [de-activated]}
}

alias unignore (nick, void)
{
	if (nick)
	{
		//ignore -REMOVE $nick
	}
}

on #^flood 420 "*" if (FLOOD_PROTECTION)
{
	^local chan $2
	^local nick $0
	^local type $1
	switch ($type)
	{
		(PUBLIC)
		{
			/* If auto-muzzle is enabled, let it handle the flooder */
			if (!AUTO_MUZZLE)
			{
				xecho -b PUBLIC flooding detected from $nick - Ignoring for $AUTO_IGNORE_TIME seconds
				//ignore $nick
				timer $AUTO_IGNORE_TIME //ignore -REMOVE $nick
			}
		}
		(JOINS)
		{
			xecho -b JOIN flooding detected from $nick - Ignoring for $AUTO_IGNORE_TIME seconds
			//ignore $nick
			timer $AUTO_IGNORE_TIME //ignore -REMOVE $nick
		}
		(MSGS)
		{
			if (!match($nick ChanServ NickServ OperServ))
			{
				xecho -b MSG flooding detected from $nick - Ignoring for $AUTO_IGNORE_TIME seconds
				//ignore $nick
				timer $AUTO_IGNORE_TIME //ignore -REMOVE $nick
			}
		}
	}
}

on ^322 ^"*"
on ^323 ^"*"

set FLOOD_WARNING OFF


/* bmw '01 */