Two alternatives (the second one is if you want it to work in older mIRCs that don't have $v1):

$iif($chan,$v1,$nick)
$iif($chan,$chan,$nick)