Ok, fair point.
It'd me more or less the same code though. You'd want on CHAT instead of on TEXT, and /msg =$nick instead of /msg $nick ... but other than that..