/*
 * Miscellaneous stuff for TekNap
 *
 * Author: Brian Weiss <brian@got.net> - 2000, 2001
 */

alias cme (text)
{
	if (text)
	{
		raw 824 $C \"$cparse("$text")\"
	}{
		xecho -b Usage: /cme <text>
		xecho -b   - Sends an action with colored text to the channel using \$cparse()
		xecho -b   - /help 6 cparse for a list of color codes
	}
}

alias csay (text)
{
	if (text)
	{
		raw 402 $C $cparse("$text")
	}{
		xecho -b Usage: /csay <text>
		xecho -b   - Sends a public with colored text to the channel using \$cparse()
		xecho -b   - /help 6 cparse for a list of color codes
	}
}

alias cycle (chan default "$C", void)
{
	wait -cmd raw 400 $chan
	raw 401 $chan
}

alias links (void)
{
	admin links
}

alias lusers (void)
{
	admin stats
}

alias partall (void)
{
	input "Are you sure you want to part all your channels? (y/N) " if ([$0])
	{
		switch ($tolower($left(1 $0)))
		{
			(y)
			{
				fe ($onchannels()) chan
				{
					raw 401 $chan
				}
			}
			(*) {#}
		}
	}
}

alias pingme (void)
{
	ping $N
}

alias q query

alias quote raw

alias sv version

alias wi whois

/* Keep track of channels you have parted for 5 seconds after you
   part them. (Required for Auto-rejoin on channel clears) */
on -leave '$N *'
{
	local numitm
	@ numitm = numitems(part)
	@ setitem(part $numitems(part) $1)
	timer 5 @ cleanup_part($numitm)
}

/* Auto-rejoin on kick */
on -servermsg '% % $N out of channel *'
{
	local chan
	@ chan = before(-1 : $6)

	if (AUTO_REJOIN)
	{
		join $chan
	}
}

/* Auto-rejoin on channel clear */
on -servermsg "% cleared channel *"
{
	local chan
	@ chan = before(-1 : $3)

	if (AUTO_REJOIN && finditem(part $chan) > -1)
	{
		join $chan
	}
}

alias cleanup_part (item)
{
	@ delitem(part $item)
	return 1
}


/* bmw '01 */