diff --git a/Client.cpp b/Client.cpp index e4961f65..03f3f11b 100644 --- a/Client.cpp +++ b/Client.cpp @@ -1185,6 +1185,65 @@ void CClient::UserCommand(const CString& sLine) { } #else PutStatus("Modules are not enabled."); +#endif + return; + } else if ((sCommand.CaseCmp("LISTAVAILMODS") == 0) || (sCommand.CaseCmp("LISTAVAILABLEMODULES") == 0)) { +#ifdef _MODULES + if (m_pUser->IsAdmin()) { + set ssGlobalMods; + CZNC::Get().GetModules().GetAvailableMods(ssGlobalMods, true); + + if (!ssGlobalMods.size()) { + PutStatus("No global modules available."); + } else { + CTable GTable; + GTable.AddColumn("Name"); + GTable.AddColumn("Description"); + set::iterator it; + + for (it = ssGlobalMods.begin(); it != ssGlobalMods.end(); it++) { + const CModInfo& Info = *it; + GTable.AddRow(); + GTable.SetCell("Name", (CZNC::Get().GetModules().FindModule(Info.GetName()) ? "*" : " ") + Info.GetName()); + GTable.SetCell("Description", Info.GetDescription().Ellipsize(128)); + } + + unsigned int uTableIdx = 0; CString sLine; + + while (GTable.GetLine(uTableIdx++, sLine)) { + PutStatus(sLine); + } + } + } + + if (m_pUser) { + set ssUserMods; + CZNC::Get().GetModules().GetAvailableMods(ssUserMods); + + if (!ssUserMods.size()) { + PutStatus("No user modules available."); + return; + } + + CTable Table; + Table.AddColumn("Name"); + Table.AddColumn("Description"); + set::iterator it; + + for (it = ssUserMods.begin(); it != ssUserMods.end(); it++) { + const CModInfo& Info = *it; + Table.AddRow(); + Table.SetCell("Name", (m_pUser->GetModules().FindModule(Info.GetName()) ? "*" : " ") + Info.GetName()); + Table.SetCell("Description", Info.GetDescription().Ellipsize(128)); + } + + unsigned int uTableIdx = 0; CString sLine; + while (Table.GetLine(uTableIdx++, sLine)) { + PutStatus(sLine); + } + } +#else + PutStatus("Modules are not enabled."); #endif return; } else if ((sCommand.CaseCmp("LOADMOD") == 0) || (sCommand.CaseCmp("LOADMODULE") == 0)) { @@ -1500,6 +1559,11 @@ void CClient::HelpUser() { Table.SetCell("Arguments", ""); Table.SetCell("Description", "List all loaded modules"); + Table.AddRow(); + Table.SetCell("Command", "ListAvailMods"); + Table.SetCell("Arguments", ""); + Table.SetCell("Description", "List all available modules"); + Table.AddRow(); Table.SetCell("Command", "ListChans"); Table.SetCell("Arguments", "");