I can't test that here, but why would:
/msg $chan $1-
not treat the | as a separator? This is why you have the switch for $read, so that you can not interpret lines as commands, right? Anyhow, I've never tried it, but it seems like it would be an issue. If not, then that's great.