See /help $nick (second entry)

Use $nick($chan,$r(1,$nick($chan,0,r)),r)
Note that addition of "r" and the change of 0 into 1.