Here's an example:
on *:ACTION:*:*: echo $iif($target ischan,$v1,$nick) Action: * $nick $1-
$target will return the target of an event.
If the user does an action on a channel that you are on, the $target will be that channel, so we then do /echo $target
If the user does an action in a query window, then the $target will be your own nick. Then you know that you should do /echo $nick
This is summarised in $iif($target ischan,$v1,$nick)
Greets