/*
 * Flood protection for TekNap
 * Author: Brian Weiss <brian@got.net>
 * Last modified: 4/24/02 (bmw)
 *
 * This script uses serial number 422 for ALL /ON hooks.
 *
 * *NOTE* If AUTO_MUZZLE is true then this will do nothing for PUBLIC
 *        floods.
 */

/*** CONFIG SECTION ***/

assign AUTO_IGNORE_TIME 60
assign FLOOD_EXEMPT ChanServ NickServ OperServ
assign FLOOD_PROTECTION 0

/*** END CONFIG SECTION ***/


set FLOOD_WARNING OFF

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 422 "*" if (FLOOD_PROTECTION)
{
	^local chan $2
	^local nick $0
	^local type $1

	unless (match($nick $FLOOD_EXEMPT))
	{
	    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)
		{
			xecho -b MSG flooding detected from $nick - Ignoring for $AUTO_IGNORE_TIME seconds
			//ignore $nick
			timer $AUTO_IGNORE_TIME //ignore -REMOVE $nick
		}
	    }
	}
}


/* EOF */