Code:
on *:text:*:*:{
if (!$chan) msg $nick etc.
else msg # etc.
}


It's been a long time since I've had to mess with normal IRC queries, but I think this would work.