I'd recommend something like
on *:connect:{
if (<network_name> isin $network) {
if $me != $mnick { .nick $v2 }
}
}
on *:notice:*is registered and protected*:{
if ($nick == nickserv) { .msg $v2 identify <password> }
}
on *:notice:Password accepted*:*{
if $nick == nickserv { .join #chan1,#chan2,#chan3 }
}
on *:op:#:{
if $opnick == $me { .mode $chan <modes> }
}
As noted, the timing is the biggest hassle, and rather than guess at a fixed time delay, my code waits for specific information to be received before going onto the next step.
Thus, even if services are extremely lagged (and I've seen lags of up to 10 seconds for services), or extremely fast (in the millisecond range), there is minimum delay between when an operation has been completed and when the next one will take place.
The main problem that I have with this code (although I use something similar myself), is the fact that if services go completely down, then come back, you will end up with a repeat of the join to the channels, which could make you end up sending a message to the wrong channel, due to the fact that each channel takes focus when you join it.
There are ways of avoiding most of that, but they require even more code than has already been done here.