diff --git a/modules/autoattach.cpp b/modules/autoattach.cpp index 2ee90e34..9c1b9cf2 100644 --- a/modules/autoattach.cpp +++ b/modules/autoattach.cpp @@ -63,6 +63,13 @@ public: } else { PutModule("Usage: Add [!]<#chan>"); } + } else if (sCommand.CaseCmp("DEL") == 0) { + CString sChan = sLine.Token(1); + + if (Del(sChan)) + PutModule("Remove " + sChan + " from list"); + else + PutModule("Usage: Del [!]<#chan>"); } else if (sCommand.CaseCmp("LIST") == 0) { CTable Table; Table.AddColumn("Chan"); @@ -96,6 +103,10 @@ public: Table.SetCell("Command", "Add"); Table.SetCell("Description", "Add an entry, use !#chan to negate and * for wildcards"); + Table.AddRow(); + Table.SetCell("Command", "Del"); + Table.SetCell("Description", "Remove an entry, needs to be an exact match"); + Table.AddRow(); Table.SetCell("Command", "List"); Table.SetCell("Description", "List all entries"); @@ -127,6 +138,42 @@ public: return true; } + bool Del(const CString& sChan) { + vector::iterator it, end; + + if (sChan.empty() || sChan == "!") + return false; + + if (sChan.Left(1) == "!") { + CString sTmp = sChan.substr(1); + it = m_vsNegChans.begin(); + end = m_vsNegChans.end(); + + for (; it != end; ++it) + if (*it == sTmp) + break; + + if (it == end) + return false; + + m_vsNegChans.erase(it); + } else { + it = m_vsChans.begin(); + end = m_vsChans.end(); + + for (; it != end; ++it) + if (*it == sChan) + break; + + if (it == end) + return false; + + m_vsChans.erase(it); + } + + return true; + } + bool IsAutoAttach(const CString& sChan) { for (unsigned int a = 0; a < m_vsNegChans.size(); a++) { if (sChan.WildCmp(m_vsNegChans[a])) {