You could use: if ($nick ison $chan) { To see if they are currently in the channel.
You might also want to put a spam protection script into that somehow. Possibly using timers and vars.
AND you may even want to have an enable/disable command.