Permalink
Browse files

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
  • Loading branch information...
1 parent ba1ff0e commit 20f925de19e4beb99a68567f41c3179f2710b10d @orchid-hybrid orchid-hybrid committed Jun 8, 2014
Showing with 25 additions and 46 deletions.
  1. +25 −46 modules/autoop.cpp
View
@@ -53,7 +53,7 @@ class CAutoOpUser {
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 @@ class CAutoOpUser {
}
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 @@ class CAutoOpUser {
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 @@ class CAutoOpMod : public CModule {
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 @@ class CAutoOpMod : public CModule {
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 @@ class CAutoOpMod : public CModule {
CString sHostmasks = sLine.Token(2, true);
if (sHostmasks.empty()) {
- PutModule("Usage: " + sCommand + " <user> <mask> [mask] ...");
+ PutModule("Usage: " + sCommand + " <user> <mask>,[mask] ...");
return;
}

0 comments on commit 20f925d

Please sign in to comment.