mirror of
https://github.com/znc/znc.git
synced 2026-07-04 17:01:23 +02:00
Get rid of the module questions during --makeconf
The following modules are enabled by default: - global: webadmin - user: controlpanel, chansaver - network: simple_away This reduces a lot makeconf noise and fixes #541.
This commit is contained in:
@@ -1207,6 +1207,7 @@ public:
|
|||||||
static bool GetModInfo(CModInfo& ModInfo, const CString& sModule, CString &sRetMsg);
|
static bool GetModInfo(CModInfo& ModInfo, const CString& sModule, CString &sRetMsg);
|
||||||
static bool GetModPathInfo(CModInfo& ModInfo, const CString& sModule, const CString& sModPath, CString &sRetMsg);
|
static bool GetModPathInfo(CModInfo& ModInfo, const CString& sModule, const CString& sModPath, CString &sRetMsg);
|
||||||
static void GetAvailableMods(std::set<CModInfo>& ssMods, CModInfo::EModuleType eType = CModInfo::UserModule);
|
static void GetAvailableMods(std::set<CModInfo>& ssMods, CModInfo::EModuleType eType = CModInfo::UserModule);
|
||||||
|
static void GetDefaultMods(std::set<CModInfo>& ssMods, CModInfo::EModuleType eType = CModInfo::UserModule);
|
||||||
|
|
||||||
// This returns the path to the .so and to the data dir
|
// This returns the path to the .so and to the data dir
|
||||||
// which is where static data (webadmin skins) are saved
|
// which is where static data (webadmin skins) are saved
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ public:
|
|||||||
CSockManager& GetManager() { return m_Manager; }
|
CSockManager& GetManager() { return m_Manager; }
|
||||||
const CSockManager& GetManager() const { return m_Manager; }
|
const CSockManager& GetManager() const { return m_Manager; }
|
||||||
CModules& GetModules() { return *m_pModules; }
|
CModules& GetModules() { return *m_pModules; }
|
||||||
size_t FilterUncommonModules(std::set<CModInfo>& ssModules);
|
|
||||||
CString GetSkinName() const { return m_sSkinName; }
|
CString GetSkinName() const { return m_sSkinName; }
|
||||||
const CString& GetStatusPrefix() const { return m_sStatusPrefix; }
|
const CString& GetStatusPrefix() const { return m_sStatusPrefix; }
|
||||||
const CString& GetCurPath() const;
|
const CString& GetCurPath() const;
|
||||||
|
|||||||
@@ -1196,6 +1196,28 @@ void CModules::GetAvailableMods(set<CModInfo>& ssMods, CModInfo::EModuleType eTy
|
|||||||
GLOBALMODULECALL(OnGetAvailableMods(ssMods, eType), NOTHING);
|
GLOBALMODULECALL(OnGetAvailableMods(ssMods, eType), NOTHING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModules::GetDefaultMods(set<CModInfo>& ssMods, CModInfo::EModuleType eType) {
|
||||||
|
|
||||||
|
GetAvailableMods(ssMods, eType);
|
||||||
|
|
||||||
|
const map<CString, CModInfo::EModuleType> ns = {
|
||||||
|
{ "chansaver", CModInfo::UserModule },
|
||||||
|
{ "controlpanel", CModInfo::UserModule },
|
||||||
|
{ "simple_away", CModInfo::NetworkModule },
|
||||||
|
{ "webadmin", CModInfo::GlobalModule }
|
||||||
|
};
|
||||||
|
|
||||||
|
auto it = ssMods.begin();
|
||||||
|
while (it != ssMods.end()) {
|
||||||
|
auto it2 = ns.find(it->GetName());
|
||||||
|
if (it2 != ns.end() && it2->second == eType) {
|
||||||
|
++it;
|
||||||
|
} else {
|
||||||
|
it = ssMods.erase(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CModules::FindModPath(const CString& sModule, CString& sModPath,
|
bool CModules::FindModPath(const CString& sModule, CString& sModPath,
|
||||||
CString& sDataPath) {
|
CString& sDataPath) {
|
||||||
CString sMod = sModule;
|
CString sMod = sModule;
|
||||||
|
|||||||
+18
-150
@@ -645,50 +645,13 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
|
|||||||
// !Listen
|
// !Listen
|
||||||
|
|
||||||
set<CModInfo> ssGlobalMods;
|
set<CModInfo> ssGlobalMods;
|
||||||
GetModules().GetAvailableMods(ssGlobalMods, CModInfo::GlobalModule);
|
GetModules().GetDefaultMods(ssGlobalMods, CModInfo::GlobalModule);
|
||||||
size_t uNrOtherGlobalMods = FilterUncommonModules(ssGlobalMods);
|
vector<CString> vsGlobalModNames;
|
||||||
|
for (set<CModInfo>::const_iterator it = ssGlobalMods.begin(); it != ssGlobalMods.end(); ++it) {
|
||||||
if (!ssGlobalMods.empty()) {
|
vsGlobalModNames.push_back(it->GetName());
|
||||||
CUtils::PrintMessage("");
|
vsLines.push_back("LoadModule = " + it->GetName());
|
||||||
CUtils::PrintMessage("-- Global Modules --");
|
|
||||||
CUtils::PrintMessage("");
|
|
||||||
|
|
||||||
CTable Table;
|
|
||||||
Table.AddColumn("Name");
|
|
||||||
Table.AddColumn("Description");
|
|
||||||
set<CModInfo>::iterator it;
|
|
||||||
|
|
||||||
for (it = ssGlobalMods.begin(); it != ssGlobalMods.end(); ++it) {
|
|
||||||
const CModInfo& Info = *it;
|
|
||||||
Table.AddRow();
|
|
||||||
Table.SetCell("Name", Info.GetName());
|
|
||||||
Table.SetCell("Description", Info.GetDescription().Ellipsize(128));
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int uTableIdx = 0; CString sLine;
|
|
||||||
while (Table.GetLine(uTableIdx++, sLine)) {
|
|
||||||
CUtils::PrintMessage(sLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uNrOtherGlobalMods > 0) {
|
|
||||||
CUtils::PrintMessage("And " + CString(uNrOtherGlobalMods) + " other (uncommon) modules. You can enable those later.");
|
|
||||||
}
|
|
||||||
|
|
||||||
CUtils::PrintMessage("");
|
|
||||||
|
|
||||||
for (it = ssGlobalMods.begin(); it != ssGlobalMods.end(); ++it) {
|
|
||||||
const CModInfo& Info = *it;
|
|
||||||
CString sName = Info.GetName();
|
|
||||||
|
|
||||||
if (CDebug::StdoutIsTTY()) {
|
|
||||||
if (CUtils::GetBoolInput("Load global module <\033[1m" + sName + "\033[22m>?", false))
|
|
||||||
vsLines.push_back("LoadModule = " + sName);
|
|
||||||
} else {
|
|
||||||
if (CUtils::GetBoolInput("Load global module <" + sName + ">?", false))
|
|
||||||
vsLines.push_back("LoadModule = " + sName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
CUtils::PrintMessage("Enabled the default global modules [" + CString(", ").Join(vsGlobalModNames.begin(), vsGlobalModNames.end()) + "]");
|
||||||
|
|
||||||
// User
|
// User
|
||||||
CUtils::PrintMessage("");
|
CUtils::PrintMessage("");
|
||||||
@@ -754,51 +717,13 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set<CModInfo> ssUserMods;
|
set<CModInfo> ssUserMods;
|
||||||
GetModules().GetAvailableMods(ssUserMods);
|
GetModules().GetDefaultMods(ssUserMods, CModInfo::UserModule);
|
||||||
size_t uNrOtherUserMods = FilterUncommonModules(ssUserMods);
|
vector<CString> vsUserModNames;
|
||||||
|
for (set<CModInfo>::const_iterator it = ssUserMods.begin(); it != ssUserMods.end(); ++it) {
|
||||||
if (!ssUserMods.empty()) {
|
vsUserModNames.push_back(it->GetName());
|
||||||
vsLines.push_back("");
|
vsLines.push_back("LoadModule = " + it->GetName());
|
||||||
CUtils::PrintMessage("");
|
|
||||||
CUtils::PrintMessage("-- User Modules --");
|
|
||||||
CUtils::PrintMessage("");
|
|
||||||
|
|
||||||
CTable Table;
|
|
||||||
Table.AddColumn("Name");
|
|
||||||
Table.AddColumn("Description");
|
|
||||||
set<CModInfo>::iterator it;
|
|
||||||
|
|
||||||
for (it = ssUserMods.begin(); it != ssUserMods.end(); ++it) {
|
|
||||||
const CModInfo& Info = *it;
|
|
||||||
Table.AddRow();
|
|
||||||
Table.SetCell("Name", Info.GetName());
|
|
||||||
Table.SetCell("Description", Info.GetDescription().Ellipsize(128));
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int uTableIdx = 0; CString sLine;
|
|
||||||
while (Table.GetLine(uTableIdx++, sLine)) {
|
|
||||||
CUtils::PrintMessage(sLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uNrOtherUserMods > 0) {
|
|
||||||
CUtils::PrintMessage("And " + CString(uNrOtherUserMods) + " other (uncommon) modules. You can enable those later.");
|
|
||||||
}
|
|
||||||
|
|
||||||
CUtils::PrintMessage("");
|
|
||||||
|
|
||||||
for (it = ssUserMods.begin(); it != ssUserMods.end(); ++it) {
|
|
||||||
const CModInfo& Info = *it;
|
|
||||||
CString sName = Info.GetName();
|
|
||||||
|
|
||||||
if (CDebug::StdoutIsTTY()) {
|
|
||||||
if (CUtils::GetBoolInput("Load module <\033[1m" + sName + "\033[22m>?", false))
|
|
||||||
vsLines.push_back("\tLoadModule = " + sName);
|
|
||||||
} else {
|
|
||||||
if (CUtils::GetBoolInput("Load module <" + sName + ">?", false))
|
|
||||||
vsLines.push_back("\tLoadModule = " + sName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
CUtils::PrintMessage("Enabled the default user modules [" + CString(", ").Join(vsUserModNames.begin(), vsUserModNames.end()) + "]");
|
||||||
|
|
||||||
CUtils::PrintMessage("");
|
CUtils::PrintMessage("");
|
||||||
CString sAAnother = "a";
|
CString sAAnother = "a";
|
||||||
@@ -813,50 +738,13 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
|
|||||||
vsLines.push_back("\t<Network " + sNetwork + ">");
|
vsLines.push_back("\t<Network " + sNetwork + ">");
|
||||||
|
|
||||||
set<CModInfo> ssNetworkMods;
|
set<CModInfo> ssNetworkMods;
|
||||||
GetModules().GetAvailableMods(ssNetworkMods, CModInfo::NetworkModule);
|
GetModules().GetDefaultMods(ssNetworkMods, CModInfo::NetworkModule);
|
||||||
size_t uNrOtherNetworkMods = FilterUncommonModules(ssNetworkMods);
|
vector<CString> vsNetworkModNames;
|
||||||
|
for (set<CModInfo>::const_iterator it = ssNetworkMods.begin(); it != ssNetworkMods.end(); ++it) {
|
||||||
if (!ssNetworkMods.empty()) {
|
vsNetworkModNames.push_back(it->GetName());
|
||||||
CUtils::PrintMessage("");
|
vsLines.push_back("LoadModule = " + it->GetName());
|
||||||
CUtils::PrintMessage("-- Network Modules --");
|
|
||||||
CUtils::PrintMessage("");
|
|
||||||
|
|
||||||
CTable Table;
|
|
||||||
Table.AddColumn("Name");
|
|
||||||
Table.AddColumn("Description");
|
|
||||||
set<CModInfo>::iterator it;
|
|
||||||
|
|
||||||
for (it = ssNetworkMods.begin(); it != ssNetworkMods.end(); ++it) {
|
|
||||||
const CModInfo& Info = *it;
|
|
||||||
Table.AddRow();
|
|
||||||
Table.SetCell("Name", Info.GetName());
|
|
||||||
Table.SetCell("Description", Info.GetDescription().Ellipsize(128));
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int uTableIdx = 0; CString sLine;
|
|
||||||
while (Table.GetLine(uTableIdx++, sLine)) {
|
|
||||||
CUtils::PrintMessage(sLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uNrOtherNetworkMods > 0) {
|
|
||||||
CUtils::PrintMessage("And " + CString(uNrOtherNetworkMods) + " other (uncommon) modules. You can enable those later.");
|
|
||||||
}
|
|
||||||
|
|
||||||
CUtils::PrintMessage("");
|
|
||||||
|
|
||||||
for (it = ssNetworkMods.begin(); it != ssNetworkMods.end(); ++it) {
|
|
||||||
const CModInfo& Info = *it;
|
|
||||||
CString sName = Info.GetName();
|
|
||||||
|
|
||||||
if (CDebug::StdoutIsTTY()) {
|
|
||||||
if (CUtils::GetBoolInput("Load module <\033[1m" + sName + "\033[22m>?", false))
|
|
||||||
vsLines.push_back("\t\tLoadModule = " + sName);
|
|
||||||
} else {
|
|
||||||
if (CUtils::GetBoolInput("Load module <" + sName + ">?", false))
|
|
||||||
vsLines.push_back("\t\tLoadModule = " + sName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
CUtils::PrintMessage("Enabled the default network modules [" + CString(", ").Join(vsNetworkModNames.begin(), vsNetworkModNames.end()) + "]");
|
||||||
|
|
||||||
vsLines.push_back("");
|
vsLines.push_back("");
|
||||||
CUtils::PrintMessage("");
|
CUtils::PrintMessage("");
|
||||||
@@ -1001,26 +889,6 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
|
|||||||
return bFileOpen && CUtils::GetBoolInput("Launch ZNC now?", true);
|
return bFileOpen && CUtils::GetBoolInput("Launch ZNC now?", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CZNC::FilterUncommonModules(set<CModInfo>& ssModules) {
|
|
||||||
const char* ns[] = { "webadmin", "controlpanel",
|
|
||||||
"chansaver", "keepnick", "simple_away", "partyline",
|
|
||||||
"kickrejoin", "nickserv", "perform" };
|
|
||||||
const set<CString> ssNames(ns, ns + sizeof(ns) / sizeof(ns[0]));
|
|
||||||
|
|
||||||
size_t uNrRemoved = 0;
|
|
||||||
for(set<CModInfo>::iterator it = ssModules.begin(); it != ssModules.end(); ) {
|
|
||||||
if(ssNames.count(it->GetName()) > 0) {
|
|
||||||
++it;
|
|
||||||
} else {
|
|
||||||
set<CModInfo>::iterator it2 = it++;
|
|
||||||
ssModules.erase(it2);
|
|
||||||
uNrRemoved++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return uNrRemoved;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CZNC::BackupConfigOnce(const CString& sSuffix) {
|
void CZNC::BackupConfigOnce(const CString& sSuffix) {
|
||||||
static bool didBackup = false;
|
static bool didBackup = false;
|
||||||
if (didBackup)
|
if (didBackup)
|
||||||
|
|||||||
Reference in New Issue
Block a user