Just a thought:
The only minor problem with all the scripts suggested so far is that not all servers actually return a value for $network.
Anyone facing this problem might like to consider using $server as the identifier to trigger the channel joins instead.
(Yes I *KNOW* that this can be very fiddly, especially if one doesn't always join the same server on a particular network...)
PM