You could modify the raw 319 of this post.
- replace channelname #q with #teenzone
- add a condition to exclude certain allowed nicknames
- have it issue the "mode # +bb" instead of a "ban -k #"

Note that both your script and the script in this post have no check for being OP at all, and have no flood protection (you might flood yourself off the server by whoissing all the users in case of e.g. a bot attack or the mass-rejoin after a netsplit).
Also note that using a variable like %cc.whois to track a nick is not reliable: Another user may join while the whois reply for a previous nick hadn't been received yet, and thereby become the value of the variable. If now the whois reply for that "previous" user arrives, you might ban the innocent "new" user in his place. Use $2 instead - it's the nickname for the actual reply.