Add a del command to autoattach

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@878 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2007-11-24 21:24:15 +00:00
parent b0e84a0605
commit 67342d0c29
+47
View File
@@ -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<CString>::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])) {