Actually, $target is the target of the event. In an on TEXT for a channel message, it is $chan. In an on TEXT for a private message, it will be $me because you are the target of the event.

If you want a single identifier that gives you either, use:
Code:
$iif($chan,$chan,$nick)