Why don\'t you just do the on Rawmode part the same as the on Mode part?
if ( !$istok($me ,$nick,32) ) { mode $chan $replacex($1-,+,-,-,+) }