There is a script that does exactly this, its a channel join flood protector.