Couple things:
Here is what I changed (untested):
Just simplified your code. Made it set the users address instead of nick, made all those if ($nick isetc) into one if and removed the timer and made it ban -ku600. Nice idea, and pretty useful against spammers.