virtual void RunJob() { if (!m_pUser->GetIRCSock()) return; for (MCString::iterator it = BeginNV(); it != EndNV(); ++it) { CChan *pChan = m_pUser->FindChan(it->first); if (!pChan) { pChan = new CChan(it->first, m_pUser, true); if (!it->second.empty()) pChan->SetKey(it->second); if (!m_pUser->AddChan(pChan)) { /* AddChan() deleted that channel */ PutModule("Could not join [" + it->first + "] (# prefix missing?)"); continue; } } if (!pChan->IsOn()) { PutModule("Joining [" + pChan->GetName() + "]"); PutIRC("JOIN " + pChan->GetName() + (pChan->GetKey().empty() ? "" : " " + pChan->GetKey())); } } }
bool CClient::OnJoinMessage(CJoinMessage& Message) { CString sChans = Message.GetTarget(); CString sKeys = Message.GetKey(); VCString vsChans; sChans.Split(",", vsChans, false); sChans.clear(); VCString vsKeys; sKeys.Split(",", vsKeys, true); sKeys.clear(); for (unsigned int a = 0; a < vsChans.size(); a++) { Message.SetTarget(vsChans[a]); Message.SetKey((a < vsKeys.size()) ? vsKeys[a] : ""); if (m_pNetwork) { // May be nullptr. Message.SetChan(m_pNetwork->FindChan(vsChans[a])); } bool bContinue = false; NETWORKMODULECALL(OnUserJoinMessage(Message), m_pUser, m_pNetwork, this, &bContinue); if (bContinue) continue; CString sChannel = Message.GetTarget(); CString sKey = Message.GetKey(); if (m_pNetwork) { CChan* pChan = m_pNetwork->FindChan(sChannel); if (pChan) { if (pChan->IsDetached()) pChan->AttachUser(this); else pChan->JoinUser(sKey); continue; } else if (!sChannel.empty()) { pChan = new CChan(sChannel, m_pNetwork, false); if (m_pNetwork->AddChan(pChan)) { pChan->SetKey(sKey); } } } if (!sChannel.empty()) { sChans += (sChans.empty()) ? sChannel : CString("," + sChannel); if (!vsKeys.empty()) { sKeys += (sKeys.empty()) ? sKey : CString("," + sKey); } } } Message.SetTarget(sChans); Message.SetKey(sKeys); return sChans.empty(); }
virtual void OnMode(const CNick& OpNick, CChan& Channel, char uMode, const CString& sArg, bool bAdded, bool bNoChange) { // This is called when we join (ZNC requests the channel modes // on join) *and* when someone changes the channel keys. // We ignore channel key "*" because of some broken nets. if (uMode != 'k' || bNoChange || !bAdded || sArg == "*") return; Channel.SetKey(sArg); m_bWriteConf = true; }