bool Del(bool bNegated, const CString& sChan, const CString& sHost) { VAttachIter it = FindEntry(sChan, sHost); if (it == m_vMatches.end() || it->IsNegated() != bNegated) return false; DelNV(it->ToString()); m_vMatches.erase(it); return true; }
VAttachIter FindEntry(const CString& sChan, const CString& sHost) { VAttachIter it = m_vMatches.begin(); for (; it != m_vMatches.end(); ++it) { if (sHost.empty() || it->GetHostMask() != sHost) continue; if (sChan.empty() || it->GetChans() != sChan) continue; return it; } return m_vMatches.end(); }
bool Add(bool bNegated, const CString& sChan, const CString& sHost) { CAttachMatch attach(sChan, sHost, bNegated); // Check for duplicates VAttachIter it = m_vMatches.begin(); for (; it != m_vMatches.end(); ++it) { if (it->GetHostMask() == attach.GetHostMask() && it->GetChans() == attach.GetChans()) return false; } m_vMatches.push_back(attach); // Also save it for next module load SetNV(attach.ToString(), ""); return true; }
void HandleList(const CString& sLine) { CTable Table; Table.AddColumn("Neg"); Table.AddColumn("Chan"); Table.AddColumn("Host"); VAttachIter it = m_vMatches.begin(); for (; it != m_vMatches.end(); ++it) { Table.AddRow(); Table.SetCell("Neg", it->IsNegated() ? "!" : ""); Table.SetCell("Chan", it->GetChans()); Table.SetCell("Host", it->GetHostMask()); } if (Table.size()) { PutModule(Table); } else { PutModule("You have no entries."); } }
void TryAttach(const CNick& Nick, CChan& Channel, CString& Message) { const CString& sChan = Channel.GetName(); const CString& sHost = Nick.GetHostMask(); const CString& sMessage = Message; VAttachIter it; if (!Channel.IsDetached()) return; // Any negated match? for (it = m_vMatches.begin(); it != m_vMatches.end(); ++it) { if (it->IsNegated() && it->IsMatch(sChan, sHost, sMessage)) return; } // Now check for a positive match for (it = m_vMatches.begin(); it != m_vMatches.end(); ++it) { if (!it->IsNegated() && it->IsMatch(sChan, sHost, sMessage)) { Channel.AttachUser(); return; } } }