mirror of
https://github.com/znc/znc.git
synced 2026-08-06 08:52:57 +02:00
Update autoop.cpp
Further improvements to autoop module: * Tabulate the data vertically with a new column for each hostname * Rename table column to Hostmasks * <mask>,[<mask>] inside help for AddHosts * Help for AddUser updated
This commit is contained in:
+25
-46
@@ -53,7 +53,7 @@ public:
|
||||
CAutoOpUser(const CString& sUsername, const CString& sUserKey, const CString& sHostmasks, const CString& sChannels) :
|
||||
m_sUsername(sUsername),
|
||||
m_sUserKey(sUserKey) {
|
||||
AddHostmasks(sHostmasks);
|
||||
AddHostmasks(sHostmasks);
|
||||
AddChans(sChannels);
|
||||
}
|
||||
|
||||
@@ -82,31 +82,11 @@ public:
|
||||
}
|
||||
|
||||
CString GetHostmasks() const {
|
||||
CString sRet;
|
||||
|
||||
for (set<CString>::const_iterator it = m_ssHostmasks.begin(); it != m_ssHostmasks.end(); ++it) {
|
||||
if (!sRet.empty()) {
|
||||
sRet += ",";
|
||||
}
|
||||
|
||||
sRet += *it;
|
||||
}
|
||||
|
||||
return sRet;
|
||||
return CString(",").Join(m_ssHostmasks.begin(), m_ssHostmasks.end());
|
||||
}
|
||||
|
||||
CString GetChannels() const {
|
||||
CString sRet;
|
||||
|
||||
for (set<CString>::const_iterator it = m_ssChans.begin(); it != m_ssChans.end(); ++it) {
|
||||
if (!sRet.empty()) {
|
||||
sRet += " ";
|
||||
}
|
||||
|
||||
sRet += *it;
|
||||
}
|
||||
|
||||
return sRet;
|
||||
return CString(" ").Join(m_ssChans.begin(), m_ssChans.end());
|
||||
}
|
||||
|
||||
void DelHostmasks(const CString& sHostmasks) {
|
||||
@@ -149,21 +129,8 @@ public:
|
||||
CString sChans;
|
||||
CString sHostmasks;
|
||||
|
||||
for (set<CString>::const_iterator it = m_ssHostmasks.begin(); it != m_ssHostmasks.end(); ++it) {
|
||||
if (!sHostmasks.empty()) {
|
||||
sHostmasks += ",";
|
||||
}
|
||||
|
||||
sHostmasks += *it;
|
||||
}
|
||||
|
||||
for (set<CString>::const_iterator it = m_ssChans.begin(); it != m_ssChans.end(); ++it) {
|
||||
if (!sChans.empty()) {
|
||||
sChans += " ";
|
||||
}
|
||||
|
||||
sChans += *it;
|
||||
}
|
||||
sHostmasks = CString(",").Join(m_ssHostmasks.begin(), m_ssHostmasks.end());
|
||||
sChans = CString(" ").Join(m_ssChans.begin(), m_ssChans.end());
|
||||
|
||||
return m_sUsername + "\t" + sHostmasks + "\t" + m_sUserKey + "\t" + sChans;
|
||||
}
|
||||
@@ -280,7 +247,7 @@ public:
|
||||
|
||||
if (sCommand.Equals("ADDUSER")) {
|
||||
if (sHost.empty()) {
|
||||
PutModule("Usage: " + sCommand + " <user> <hostmask> <key> [channels]");
|
||||
PutModule("Usage: " + sCommand + " <user> <hostmasks> <key> [channels]");
|
||||
} else {
|
||||
CAutoOpUser* pUser = AddUser(sUser, sKey, sHost, sLine.Token(4, true));
|
||||
|
||||
@@ -301,16 +268,28 @@ public:
|
||||
CTable Table;
|
||||
|
||||
Table.AddColumn("User");
|
||||
Table.AddColumn("Hostmask");
|
||||
Table.AddColumn("Hostmasks");
|
||||
Table.AddColumn("Key");
|
||||
Table.AddColumn("Channels");
|
||||
|
||||
for (map<CString, CAutoOpUser*>::iterator it = m_msUsers.begin(); it != m_msUsers.end(); ++it) {
|
||||
Table.AddRow();
|
||||
Table.SetCell("User", it->second->GetUsername());
|
||||
Table.SetCell("Hostmask", it->second->GetHostmasks());
|
||||
Table.SetCell("Key", it->second->GetUserKey());
|
||||
Table.SetCell("Channels", it->second->GetChannels());
|
||||
VCString vsHostmasks;
|
||||
it->second->GetHostmasks().Split(",", vsHostmasks);
|
||||
for (unsigned int a = 0; a < vsHostmasks.size(); a++) {
|
||||
Table.AddRow();
|
||||
if(a == 0) {
|
||||
Table.SetCell("User", it->second->GetUsername());
|
||||
Table.SetCell("Key", it->second->GetUserKey());
|
||||
Table.SetCell("Channels", it->second->GetChannels());
|
||||
}
|
||||
else if(a == vsHostmasks.size()-1) {
|
||||
Table.SetCell("User", "`-");
|
||||
}
|
||||
else {
|
||||
Table.SetCell("User", "|-");
|
||||
}
|
||||
Table.SetCell("Hostmasks", vsHostmasks[a]);
|
||||
}
|
||||
}
|
||||
|
||||
PutModule(Table);
|
||||
@@ -344,7 +323,7 @@ public:
|
||||
CString sHostmasks = sLine.Token(2, true);
|
||||
|
||||
if (sHostmasks.empty()) {
|
||||
PutModule("Usage: " + sCommand + " <user> <mask> [mask] ...");
|
||||
PutModule("Usage: " + sCommand + " <user> <mask>,[mask] ...");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user