diff --git a/User.cpp b/User.cpp index 24f4cf4e..9ff8a4be 100644 --- a/User.cpp +++ b/User.cpp @@ -704,9 +704,14 @@ CChan* CUser::FindChan(const CString& sName) const { } void CUser::JoinChans() { + // We start at a random offset into the channel list so that if your + // first 3 channels are invite-only and you got MaxJoins == 3, ZNC will + // still be able to join the rest of your channels. + unsigned int start = rand() % m_vChans.size(); unsigned int uJoins = m_uMaxJoins; for (unsigned int a = 0; a < m_vChans.size(); a++) { - CChan* pChan = m_vChans[a]; + unsigned int idx = (start + a) % m_vChans.size(); + CChan* pChan = m_vChans[idx]; if (!pChan->IsOn() && !pChan->IsDisabled()) { if (!JoinChan(pChan)) continue;