I'll say this again, to the best of my knowledge, the only way to ensure that someone is in one (or more) rooms is if you are an IRCop or Admininistrator for that network.

Xklark: that code that you posted, would have you join #channel when you connected to a network, and try to force you to join that same channel whenever you or someone else leaves. Taking into account the miscoding of the ON PART event. If you're already on the channel (which you would be), then you wouldn't notice a difference...trying to join a channel that you're already on is a waste of time & resources, so the server ignores the command (or at least, that's how it appears to me)