It is very good to understand that this method is NOT really all that safe. The problems occurs when you are on some network where the nick NickServ isn't restricted (there aren't many now) and someone else takes the nick, and sends you the notice. Services Impersonations are many times a bit ugly.

If the network you are on supports "/ns" instead of "/msg nickserv" I would strongly recomend you use this thinstead, as /ns will not send to anyone other than the server, thus being more secure.

Also, on why you went with all the *s in the line, most services put bold around "IDENTIFY", or underline "password". So a more secure option (I thought about posting it with the on quit, but didn't) would be to use the message right before that:
Code:
on 1:notice:This nickname is registered*:?: if ($nick == NickServ) { ns identify <yourpassword> }

I also tossed in the $nick == NickServ so that some goofball doesn't try to get you to re-identify