no real need for the two checks of the %owner variable
and if you have msg # you might wanna limit to channel use only
heres another small rewrite so you can use it in channel or query
on *:text:*:*: {
if ($nick == %owner) {
if ($1 == !join) { join $2 | msg $iif(($target == #),#,$nick) $me has join $2 }
elseif ($1 == !leave) { part $2 | msg $iif(($target == #),#,$nick) $me has left $2 }
}
}