You can change this part
if ($nick != $me) && ($nick != ) && ($nick != ) {
to
if ( !$istok($me nick1 nick2,$nick,32) ) {