diff --git a/include/znc/Client.h b/include/znc/Client.h index 413e107b..b7aed570 100644 --- a/include/znc/Client.h +++ b/include/znc/Client.h @@ -133,7 +133,7 @@ public: virtual void ReadLine(const CString& sData); bool SendMotd(); - void HelpUser(); + void HelpUser(const CString& sFilter = ""); void AuthUser(); virtual void Connected(); virtual void Timeout(); diff --git a/modules/controlpanel.cpp b/modules/controlpanel.cpp index f084518b..de6e138a 100644 --- a/modules/controlpanel.cpp +++ b/modules/controlpanel.cpp @@ -40,100 +40,123 @@ static array_size_helper array_size(T (&)[N]) { class CAdminMod : public CModule { using CModule::PutModule; - void PrintHelp(const CString&) { - HandleHelpCommand(); + void PrintHelp(const CString& sLine) { + HandleHelpCommand(sLine); - PutModule("The following variables are available when using the Set/Get commands:"); - - CTable VarTable; - VarTable.AddColumn("Variable"); - VarTable.AddColumn("Type"); static const char* str = "String"; static const char* boolean = "Boolean (true/false)"; static const char* integer = "Integer"; static const char* doublenum = "Double"; - static const char* vars[][2] = { - {"Nick", str}, - {"Altnick", str}, - {"Ident", str}, - {"RealName", str}, - {"BindHost", str}, - {"MultiClients", boolean}, - {"DenyLoadMod", boolean}, - {"DenySetBindHost", boolean}, - {"DefaultChanModes", str}, - {"QuitMsg", str}, - {"BufferCount", integer}, - {"AutoClearChanBuffer", boolean}, - {"AutoClearQueryBuffer",boolean}, - {"Password", str}, - {"JoinTries", integer}, - {"MaxJoins", integer}, - {"MaxNetworks", integer}, - {"MaxQueryBuffers", integer}, - {"Timezone", str}, - {"Admin", boolean}, - {"AppendTimestamp", boolean}, - {"PrependTimestamp", boolean}, - {"TimestampFormat", str}, - {"DCCBindHost", str}, - {"StatusPrefix", str}, + + const CString sCmdFilter = sLine.Token(1, false); + const CString::size_type iCmdLength = sCmdFilter.size(); + + const CString sVarFilter = sLine.Token(2, true); + const CString::size_type iVarLength = sVarFilter.size(); + + if (sCmdFilter.empty() || sCmdFilter.Equals("Set", false, iCmdLength) || sCmdFilter.Equals("Get", false, iCmdLength)) { + CTable VarTable; + VarTable.AddColumn("Variable"); + VarTable.AddColumn("Type"); + static const char* vars[][2] = { + {"Nick", str}, + {"Altnick", str}, + {"Ident", str}, + {"RealName", str}, + {"BindHost", str}, + {"MultiClients", boolean}, + {"DenyLoadMod", boolean}, + {"DenySetBindHost", boolean}, + {"DefaultChanModes", str}, + {"QuitMsg", str}, + {"BufferCount", integer}, + {"AutoClearChanBuffer", boolean}, + {"AutoClearQueryBuffer",boolean}, + {"Password", str}, + {"JoinTries", integer}, + {"MaxJoins", integer}, + {"MaxNetworks", integer}, + {"MaxQueryBuffers", integer}, + {"Timezone", str}, + {"Admin", boolean}, + {"AppendTimestamp", boolean}, + {"PrependTimestamp", boolean}, + {"TimestampFormat", str}, + {"DCCBindHost", str}, + {"StatusPrefix", str}, #ifdef HAVE_ICU - {"ClientEncoding", str}, + {"ClientEncoding", str}, #endif - }; - for (unsigned int i = 0; i != ARRAY_SIZE(vars); ++i) { - VarTable.AddRow(); - VarTable.SetCell("Variable", vars[i][0]); - VarTable.SetCell("Type", vars[i][1]); + }; + for (unsigned int i = 0; i != ARRAY_SIZE(vars); ++i) { + if (sVarFilter.empty() || sVarFilter.Equals(vars[i][0], false, iVarLength)) { + VarTable.AddRow(); + VarTable.SetCell("Variable", vars[i][0]); + VarTable.SetCell("Type", vars[i][1]); + } + } + if (!VarTable.empty()) { + PutModule("The following variables are available when using the Set/Get commands:"); + PutModule(VarTable); + } } - PutModule(VarTable); - PutModule("The following variables are available when using the SetNetwork/GetNetwork commands:"); - - CTable NVarTable; - NVarTable.AddColumn("Variable"); - NVarTable.AddColumn("Type"); - static const char* nvars[][2] = { - {"Nick", str}, - {"Altnick", str}, - {"Ident", str}, - {"RealName", str}, - {"BindHost", str}, - {"FloodRate", doublenum}, - {"FloodBurst", integer}, + if (sCmdFilter.empty() || sCmdFilter.Equals("SetNetwork", false, iCmdLength) || sCmdFilter.Equals("GetNetwork", false, iCmdLength)) { + CTable NVarTable; + NVarTable.AddColumn("Variable"); + NVarTable.AddColumn("Type"); + static const char* nvars[][2] = { + {"Nick", str}, + {"Altnick", str}, + {"Ident", str}, + {"RealName", str}, + {"BindHost", str}, + {"FloodRate", doublenum}, + {"FloodBurst", integer}, #ifdef HAVE_ICU - {"Encoding", str}, + {"Encoding", str}, #endif - }; - for (unsigned int i = 0; i != ARRAY_SIZE(nvars); ++i) { - NVarTable.AddRow(); - NVarTable.SetCell("Variable", nvars[i][0]); - NVarTable.SetCell("Type", nvars[i][1]); + }; + for (unsigned int i = 0; i != ARRAY_SIZE(nvars); ++i) { + if (sVarFilter.empty() || sVarFilter.Equals(nvars[i][0], false, iVarLength)) { + NVarTable.AddRow(); + NVarTable.SetCell("Variable", nvars[i][0]); + NVarTable.SetCell("Type", nvars[i][1]); + } + } + if (!NVarTable.empty()) { + PutModule("The following variables are available when using the SetNetwork/GetNetwork commands:"); + PutModule(NVarTable); + } } - PutModule(NVarTable); - - PutModule("The following variables are available when using the SetChan/GetChan commands:"); - CTable CVarTable; - CVarTable.AddColumn("Variable"); - CVarTable.AddColumn("Type"); - static const char* cvars[][2] = { - {"DefModes", str}, - {"Key", str}, - {"Buffer", integer}, - {"InConfig", boolean}, - {"AutoClearChanBuffer", boolean}, - {"Detached", boolean} - }; - for (unsigned int i = 0; i != ARRAY_SIZE(cvars); ++i) { - CVarTable.AddRow(); - CVarTable.SetCell("Variable", cvars[i][0]); - CVarTable.SetCell("Type", cvars[i][1]); + if (sCmdFilter.empty() || sCmdFilter.Equals("SetChan", false, iCmdLength) || sCmdFilter.Equals("GetChan", false, iCmdLength)) { + CTable CVarTable; + CVarTable.AddColumn("Variable"); + CVarTable.AddColumn("Type"); + static const char* cvars[][2] = { + {"DefModes", str}, + {"Key", str}, + {"Buffer", integer}, + {"InConfig", boolean}, + {"AutoClearChanBuffer", boolean}, + {"Detached", boolean} + }; + for (unsigned int i = 0; i != ARRAY_SIZE(cvars); ++i) { + if (sVarFilter.empty() || sVarFilter.Equals(cvars[i][0], false, iVarLength)) { + CVarTable.AddRow(); + CVarTable.SetCell("Variable", cvars[i][0]); + CVarTable.SetCell("Type", cvars[i][1]); + } + } + if (!CVarTable.empty()) { + PutModule("The following variables are available when using the SetChan/GetChan commands:"); + PutModule(CVarTable); + } } - PutModule(CVarTable); - PutModule("You can use $me as the user name for modifying your own user."); + if (sCmdFilter.empty()) + PutModule("You can use $me as the user name for modifying your own user."); } CUser* GetUser(const CString& sUsername) { @@ -157,7 +180,7 @@ class CAdminMod : public CModule { CUser* pUser; if (sVar.empty()) { - PutModule("Usage: get [username]"); + PutModule("Usage: Get [username]"); return; } @@ -234,7 +257,7 @@ class CAdminMod : public CModule { CString sValue = sLine.Token(3, true); if (sValue.empty()) { - PutModule("Usage: set "); + PutModule("Usage: Set "); return; } @@ -574,7 +597,7 @@ class CAdminMod : public CModule { const CString sChan = sLine.Token(3); if (sChan.empty()) { - PutModule("Usage: addchan "); + PutModule("Usage: AddChan "); return; } @@ -606,7 +629,7 @@ class CAdminMod : public CModule { const CString sChan = sLine.Token(3); if (sChan.empty()) { - PutModule("Usage: delchan "); + PutModule("Usage: DelChan "); return; } @@ -644,7 +667,7 @@ class CAdminMod : public CModule { CString sChan = sLine.Token(4, true); if (sChan.empty()) { - PutModule("Usage: getchan "); + PutModule("Usage: GetChan "); return; } @@ -690,7 +713,7 @@ class CAdminMod : public CModule { CString sValue = sLine.Token(5, true); if (sValue.empty()) { - PutModule("Usage: setchan "); + PutModule("Usage: SetChan "); return; } @@ -791,7 +814,7 @@ class CAdminMod : public CModule { sUsername = sLine.Token(1), sPassword = sLine.Token(2); if (sPassword.empty()) { - PutModule("Usage: adduser "); + PutModule("Usage: AddUser "); return; } @@ -823,7 +846,7 @@ class CAdminMod : public CModule { const CString sUsername = sLine.Token(1, true); if (sUsername.empty()) { - PutModule("Usage: deluser "); + PutModule("Usage: DelUser "); return; } @@ -860,7 +883,7 @@ class CAdminMod : public CModule { sNewUsername = sLine.Token(2, true); if (sOldUsername.empty() || sNewUsername.empty()) { - PutModule("Usage: cloneuser "); + PutModule("Usage: CloneUser "); return; } @@ -905,7 +928,7 @@ class CAdminMod : public CModule { } if (sNetwork.empty()) { - PutModule("Usage: " + sLine.Token(0) + " [user] network"); + PutModule("Usage: AddNetwork [user] network"); return; } @@ -942,7 +965,7 @@ class CAdminMod : public CModule { } if (sNetwork.empty()) { - PutModule("Usage: " + sLine.Token(0) + " [user] network"); + PutModule("Usage: DelNetwork [user] network"); return; } @@ -1010,7 +1033,7 @@ class CAdminMod : public CModule { CString sServer = sLine.Token(3, true); if (sServer.empty()) { - PutModule("Usage: addserver "); + PutModule("Usage: AddServer "); return; } @@ -1201,7 +1224,7 @@ class CAdminMod : public CModule { CString sArgs = sLine.Token(3, true); if (sModName.empty()) { - PutModule("Usage: loadmodule []"); + PutModule("Usage: LoadModule [args]"); return; } @@ -1219,7 +1242,7 @@ class CAdminMod : public CModule { CString sArgs = sLine.Token(4, true); if (sModName.empty()) { - PutModule("Usage: loadnetmodule []"); + PutModule("Usage: LoadNetModule [args]"); return; } @@ -1260,7 +1283,7 @@ class CAdminMod : public CModule { CString sModName = sLine.Token(2); if (sModName.empty()) { - PutModule("Usage: unloadmodule "); + PutModule("Usage: UnloadModule "); return; } @@ -1277,7 +1300,7 @@ class CAdminMod : public CModule { CString sModName = sLine.Token(3); if (sModName.empty()) { - PutModule("Usage: unloadnetmodule "); + PutModule("Usage: UnloadNetModule "); return; } @@ -1317,7 +1340,7 @@ class CAdminMod : public CModule { CString sUsername = sLine.Token(1); if (sUsername.empty()) { - PutModule("Usage: listmods "); + PutModule("Usage: ListMods "); return; } @@ -1333,7 +1356,7 @@ class CAdminMod : public CModule { CString sNetwork = sLine.Token(2); if (sNetwork.empty()) { - PutModule("Usage: listnetmods "); + PutModule("Usage: ListNetMods "); return; } @@ -1353,63 +1376,63 @@ class CAdminMod : public CModule { public: MODCONSTRUCTOR(CAdminMod) { AddCommand("Help", static_cast(&CAdminMod::PrintHelp), - "", "Generates this output"); + "[command] [variable]", "Prints help for matching commands and variables"); AddCommand("Get", static_cast(&CAdminMod::Get), - "variable [username]", "Prints the variable's value for the given or current user"); + " [username]", "Prints the variable's value for the given or current user"); AddCommand("Set", static_cast(&CAdminMod::Set), - "variable username value", "Sets the variable's value for the given user (use $me for the current user)"); + " ", "Sets the variable's value for the given user (use $me for the current user)"); AddCommand("GetNetwork", static_cast(&CAdminMod::GetNetwork), - "variable [username network]", "Prints the variable's value for the given network"); + " [username] [network]", "Prints the variable's value for the given network"); AddCommand("SetNetwork", static_cast(&CAdminMod::SetNetwork), - "variable username network value", "Sets the variable's value for the given network"); + " ", "Sets the variable's value for the given network"); AddCommand("GetChan", static_cast(&CAdminMod::GetChan), - "variable [username] network chan", "Prints the variable's value for the given channel"); + " [username] ", "Prints the variable's value for the given channel"); AddCommand("SetChan", static_cast(&CAdminMod::SetChan), - "variable username network chan value", "Sets the variable's value for the given channel"); + " ", "Sets the variable's value for the given channel"); AddCommand("AddChan", static_cast(&CAdminMod::AddChan), - "username network chan", "Adds a new channel"); + " ", "Adds a new channel"); AddCommand("DelChan", static_cast(&CAdminMod::DelChan), - "username network chan", "Deletes a channel"); + " ", "Deletes a channel"); AddCommand("ListUsers", static_cast(&CAdminMod::ListUsers), - "", "Lists users"); + "", "Lists users"); AddCommand("AddUser", static_cast(&CAdminMod::AddUser), - "username password", "Adds a new user"); + " ", "Adds a new user"); AddCommand("DelUser", static_cast(&CAdminMod::DelUser), - "username", "Deletes a user"); + "", "Deletes a user"); AddCommand("CloneUser", static_cast(&CAdminMod::CloneUser), - "oldusername newusername", "Clones a user"); + " ", "Clones a user"); AddCommand("AddServer", static_cast(&CAdminMod::AddServer), - "username network server", "Adds a new IRC server for the given or current user"); + " ", "Adds a new IRC server for the given or current user"); AddCommand("Reconnect", static_cast(&CAdminMod::ReconnectUser), - "username network", "Cycles the user's IRC server connection"); + " ", "Cycles the user's IRC server connection"); AddCommand("Disconnect", static_cast(&CAdminMod::DisconnectUser), - "username network", "Disconnects the user from their IRC server"); + " ", "Disconnects the user from their IRC server"); AddCommand("LoadModule", static_cast(&CAdminMod::LoadModuleForUser), - "username modulename [args]", "Loads a Module for a user"); + " [args]", "Loads a Module for a user"); AddCommand("UnLoadModule", static_cast(&CAdminMod::UnLoadModuleForUser), - "username modulename", "Removes a Module of a user"); + " ", "Removes a Module of a user"); AddCommand("ListMods", static_cast(&CAdminMod::ListModulesForUser), - "username", "Get the list of modules for a user"); + "", "Get the list of modules for a user"); AddCommand("LoadNetModule",static_cast(&CAdminMod::LoadModuleForNetwork), - "username network modulename [args]", "Loads a Module for a network"); + " [args]", "Loads a Module for a network"); AddCommand("UnLoadNetModule",static_cast(&CAdminMod::UnLoadModuleForNetwork), - "username network modulename", "Removes a Module of a network"); + " ", "Removes a Module of a network"); AddCommand("ListNetMods", static_cast(&CAdminMod::ListModulesForNetwork), - "username network", "Get the list of modules for a network"); + " ", "Get the list of modules for a network"); AddCommand("ListCTCPs", static_cast(&CAdminMod::ListCTCP), - "username", "List the configured CTCP replies"); + "", "List the configured CTCP replies"); AddCommand("AddCTCP", static_cast(&CAdminMod::AddCTCP), - "username ctcp [reply]", "Configure a new CTCP reply"); + " [reply]", "Configure a new CTCP reply"); AddCommand("DelCTCP", static_cast(&CAdminMod::DelCTCP), - "username ctcp", "Remove a CTCP reply"); + " ", "Remove a CTCP reply"); // Network commands AddCommand("AddNetwork", static_cast(&CAdminMod::AddNetwork), - "[username] network", "Add a network for a user"); + "[username] ", "Add a network for a user"); AddCommand("DelNetwork", static_cast(&CAdminMod::DelNetwork), - "[username] network", "Delete a network for a user"); + "[username] ", "Delete a network for a user"); AddCommand("ListNetworks", static_cast(&CAdminMod::ListNetworks), - "[username]", "List all networks for a user"); + "[username]", "List all networks for a user"); } virtual ~CAdminMod() {} diff --git a/src/ClientCommand.cpp b/src/ClientCommand.cpp index 431a50cb..ea241f59 100644 --- a/src/ClientCommand.cpp +++ b/src/ClientCommand.cpp @@ -42,7 +42,7 @@ void CClient::UserCommand(CString& sLine) { const CString sCommand = sLine.Token(0); if (sCommand.Equals("HELP")) { - HelpUser(); + HelpUser(sLine.Token(1)); } else if (sCommand.Equals("LISTNICKS")) { if (!m_pNetwork) { PutStatus("You must be connected with a network to use this command"); @@ -257,7 +257,7 @@ void CClient::UserCommand(CString& sLine) { CString sMessage = sLine.Token(1, true); if (sMessage.empty()) { - PutStatus("Usage: SetMOTD "); + PutStatus("Usage: SetMOTD "); } else { CZNC::Get().SetMotd(sMessage); PutStatus("MOTD set to [" + sMessage + "]"); @@ -266,7 +266,7 @@ void CClient::UserCommand(CString& sLine) { CString sMessage = sLine.Token(1, true); if (sMessage.empty()) { - PutStatus("Usage: AddMOTD "); + PutStatus("Usage: AddMOTD "); } else { CZNC::Get().AddMotd(sMessage); PutStatus("Added [" + sMessage + "] to MOTD"); @@ -587,7 +587,7 @@ void CClient::UserCommand(CString& sLine) { CString sNewNetwork = sLine.Token(4); if (sOldUser.empty() || sOldNetwork.empty() || sNewUser.empty()) { - PutStatus("Usage: MoveNetwork old-user old-network new-user [new-network]"); + PutStatus("Usage: MoveNetwork [new network]"); return; } if (sNewNetwork.empty()) { @@ -1546,284 +1546,110 @@ void CClient::UserPortCommand(CString& sLine) { } } -void CClient::HelpUser() { +static void AddCommandHelp(CTable& Table, const CString& sCmd, const CString& sArgs, const CString& sDesc, const CString& sFilter = "") +{ + const CString::size_type iFilterLength = sFilter.size(); + if (sFilter.empty() || sCmd.Equals(sFilter, false, iFilterLength)) { + Table.AddRow(); + Table.SetCell("Command", sCmd); + Table.SetCell("Arguments", sArgs); + Table.SetCell("Description", sDesc); + } +} + +void CClient::HelpUser(const CString& sFilter) { CTable Table; Table.AddColumn("Command"); Table.AddColumn("Arguments"); Table.AddColumn("Description"); - PutStatus("In the following list all occurrences of <#chan> support wildcards (* and ?)"); - PutStatus("(Except ListNicks)"); + if (sFilter.empty()) { + PutStatus("In the following list all occurrences of <#chan> support wildcards (* and ?)"); + PutStatus("(Except ListNicks)"); + } - Table.AddRow(); - Table.SetCell("Command", "Version"); - Table.SetCell("Description", "Print which version of ZNC this is"); - - Table.AddRow(); - Table.SetCell("Command", "ListMods"); - Table.SetCell("Description", "List all loaded modules"); - - Table.AddRow(); - Table.SetCell("Command", "ListAvailMods"); - Table.SetCell("Description", "List all available modules"); + AddCommandHelp(Table, "Version", "", "Print which version of ZNC this is", sFilter); + AddCommandHelp(Table, "ListMods", "", "List all loaded modules", sFilter); + AddCommandHelp(Table, "ListAvailMods", "", "List all available modules", sFilter); if (!m_pUser->IsAdmin()) { // If they are an admin we will add this command below with an argument - Table.AddRow(); - Table.SetCell("Command", "ListChans"); - Table.SetCell("Description", "List all channels"); + AddCommandHelp(Table, "ListChans", "", "List all channels", sFilter); } - - Table.AddRow(); - Table.SetCell("Command", "ListNicks"); - Table.SetCell("Arguments", "<#chan>"); - Table.SetCell("Description", "List all nicks on a channel"); - + AddCommandHelp(Table, "ListNicks", "<#chan>", "List all nicks on a channel", sFilter); if (!m_pUser->IsAdmin()) { - Table.AddRow(); - Table.SetCell("Command", "ListClients"); - Table.SetCell("Description", "List all clients connected to your ZNC user"); + AddCommandHelp(Table, "ListClients", "", "List all clients connected to your ZNC user", sFilter); } + AddCommandHelp(Table, "ListServers", "", "List all servers of current IRC network", sFilter); - Table.AddRow(); - Table.SetCell("Command", "ListServers"); - Table.SetCell("Description", "List all servers of current IRC network"); + AddCommandHelp(Table, "AddNetwork", "", "Add a network to your user", sFilter); + AddCommandHelp(Table, "DelNetwork", "", "Delete a network from your user", sFilter); + AddCommandHelp(Table, "ListNetworks", "", "List all networks", sFilter); + if (m_pUser->IsAdmin()) { + AddCommandHelp(Table, "MoveNetwork", " [new network]", "Move an IRC network from one user to another", sFilter); + } + AddCommandHelp(Table, "JumpNetwork", "", "Jump to another network", sFilter); - Table.AddRow(); - Table.SetCell("Command", "AddNetwork"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Add a network to your user"); + AddCommandHelp(Table, "AddServer", " [[+]port] [pass]", "Add a server to the list of alternate/backup servers of current IRC network.", sFilter); + AddCommandHelp(Table, "DelServer", " [port] [pass]", "Remove a server from the list of alternate/backup servers of current IRC network", sFilter); - Table.AddRow(); - Table.SetCell("Command", "DelNetwork"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Delete a network from your user"); + AddCommandHelp(Table, "EnableChan", "<#chan>", "Enable the channel", sFilter); + AddCommandHelp(Table, "DisableChan", "<#chan>", "Disable the channel", sFilter); + AddCommandHelp(Table, "Detach", "<#chan>", "Detach from the channel", sFilter); + AddCommandHelp(Table, "Topics", "", "Show topics in all your channels", sFilter); - Table.AddRow(); - Table.SetCell("Command", "ListNetworks"); - Table.SetCell("Description", "List all networks"); + AddCommandHelp(Table, "PlayBuffer", "<#chan|query>", "Play back the specified buffer", sFilter); + AddCommandHelp(Table, "ClearBuffer", "<#chan|query>", "Clear the specified buffer", sFilter); + AddCommandHelp(Table, "ClearAllChannelBuffers", "", "Clear the channel buffers", sFilter); + AddCommandHelp(Table, "ClearAllQueryBuffers", "", "Clear the query buffers", sFilter); + AddCommandHelp(Table, "SetBuffer", "<#chan|query> [linecount]", "Set the buffer count", sFilter); if (m_pUser->IsAdmin()) { - Table.AddRow(); - Table.SetCell("Command", "MoveNetwork"); - Table.SetCell("Arguments", "old-user old-net new-user [new-net]"); - Table.SetCell("Description", "Move an IRC network from one user to another"); - } - - Table.AddRow(); - Table.SetCell("Command", "JumpNetwork"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Jump to another network"); - - Table.AddRow(); - Table.SetCell("Command", "AddServer"); - Table.SetCell("Arguments", " [[+]port] [pass]"); - Table.SetCell("Description", "Add a server to the list of alternate/backup servers of current IRC network."); - - Table.AddRow(); - Table.SetCell("Command", "DelServer"); - Table.SetCell("Arguments", " [port] [pass]"); - Table.SetCell("Description", "Remove a server from the list of alternate/backup servers of current IRC network"); - - Table.AddRow(); - Table.SetCell("Command", "Enablechan"); - Table.SetCell("Arguments", "<#chan>"); - Table.SetCell("Description", "Enable the channel"); - - Table.AddRow(); - Table.SetCell("Command", "Disablechan"); - Table.SetCell("Arguments", "<#chan>"); - Table.SetCell("Description", "Disable the channel"); - - Table.AddRow(); - Table.SetCell("Command", "Detach"); - Table.SetCell("Arguments", "<#chan>"); - Table.SetCell("Description", "Detach from the channel"); - - Table.AddRow(); - Table.SetCell("Command", "Topics"); - Table.SetCell("Description", "Show topics in all your channels"); - - Table.AddRow(); - Table.SetCell("Command", "PlayBuffer"); - Table.SetCell("Arguments", "<#chan|query>"); - Table.SetCell("Description", "Play back the specified buffer"); - - Table.AddRow(); - Table.SetCell("Command", "ClearBuffer"); - Table.SetCell("Arguments", "<#chan|query>"); - Table.SetCell("Description", "Clear the specified buffer"); - - Table.AddRow(); - Table.SetCell("Command", "ClearAllChannelBuffers"); - Table.SetCell("Description", "Clear the channel buffers"); - - Table.AddRow(); - Table.SetCell("Command", "ClearAllQueryBuffers"); - Table.SetCell("Description", "Clear the query buffers"); - - Table.AddRow(); - Table.SetCell("Command", "SetBuffer"); - Table.SetCell("Arguments", "<#chan|query> [linecount]"); - Table.SetCell("Description", "Set the buffer count"); - - if (m_pUser->IsAdmin()) { - Table.AddRow(); - Table.SetCell("Command", "AddBindHost"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Adds a bind host for normal users to use"); - - Table.AddRow(); - Table.SetCell("Command", "DelBindHost"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Removes a bind host from the list"); + AddCommandHelp(Table, "AddBindHost", "", "Adds a bind host for normal users to use", sFilter); + AddCommandHelp(Table, "DelBindHost", "", "Removes a bind host from the list", sFilter); } if (m_pUser->IsAdmin() || !m_pUser->DenySetBindHost()) { - Table.AddRow(); - Table.SetCell("Command", "ListBindHosts"); - Table.SetCell("Description", "Shows the configured list of bind hosts"); - - Table.AddRow(); - Table.SetCell("Command", "SetBindHost"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Set the bind host for this connection"); - - Table.AddRow(); - Table.SetCell("Command", "SetUserBindHost"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Set the default bind host for this user"); - - Table.AddRow(); - Table.SetCell("Command", "ClearBindHost"); - Table.SetCell("Description", "Clear the bind host for this connection"); - - Table.AddRow(); - Table.SetCell("Command", "ClearUserBindHost"); - Table.SetCell("Description", "Clear the default bind host for this user"); + AddCommandHelp(Table, "ListBindHosts", "", "Shows the configured list of bind hosts", sFilter); + AddCommandHelp(Table, "SetBindHost", "", "Set the bind host for this connection", sFilter); + AddCommandHelp(Table, "SetUserBindHost", "", "Set the default bind host for this user", sFilter); + AddCommandHelp(Table, "ClearBindHost", "", "Clear the bind host for this connection", sFilter); + AddCommandHelp(Table, "ClearUserBindHost", "", "Clear the default bind host for this user", sFilter); } - Table.AddRow(); - Table.SetCell("Command", "ShowBindHost"); - Table.SetCell("Description", "Show currently selected bind host"); - - Table.AddRow(); - Table.SetCell("Command", "Jump [server]"); - Table.SetCell("Description", "Jump to the next or the specified server"); - - Table.AddRow(); - Table.SetCell("Command", "Disconnect"); - Table.SetCell("Arguments", "[message]"); - Table.SetCell("Description", "Disconnect from IRC"); - - Table.AddRow(); - Table.SetCell("Command", "Connect"); - Table.SetCell("Description", "Reconnect to IRC"); - - Table.AddRow(); - Table.SetCell("Command", "Uptime"); - Table.SetCell("Description", "Show for how long ZNC has been running"); + AddCommandHelp(Table, "ShowBindHost", "", "Show currently selected bind host", sFilter); + AddCommandHelp(Table, "Jump", "[server]", "Jump to the next or the specified server", sFilter); + AddCommandHelp(Table, "Disconnect", "[message]", "Disconnect from IRC", sFilter); + AddCommandHelp(Table, "Connect", "", "Reconnect to IRC", sFilter); + AddCommandHelp(Table, "Uptime", "", "Show for how long ZNC has been running", sFilter); if (!m_pUser->DenyLoadMod()) { - Table.AddRow(); - Table.SetCell("Command", "LoadMod"); - Table.SetCell("Arguments", "[--type=global|user|network] "); - Table.SetCell("Description", "Load a module"); - - Table.AddRow(); - Table.SetCell("Command", "UnloadMod"); - Table.SetCell("Arguments", "[--type=global|user|network] "); - Table.SetCell("Description", "Unload a module"); - - Table.AddRow(); - Table.SetCell("Command", "ReloadMod"); - Table.SetCell("Arguments", "[--type=global|user|network] "); - Table.SetCell("Description", "Reload a module"); - + AddCommandHelp(Table, "LoadMod", "[--type=global|user|network] ", "Load a module", sFilter); + AddCommandHelp(Table, "UnloadMod", "[--type=global|user|network] ", "Unload a module", sFilter); + AddCommandHelp(Table, "ReloadMod", "[--type=global|user|network] ", "Reload a module", sFilter); if (m_pUser->IsAdmin()) { - Table.AddRow(); - Table.SetCell("Command", "UpdateMod"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Reload a module everywhere"); + AddCommandHelp(Table, "UpdateMod", "", "Reload a module everywhere", sFilter); } } - Table.AddRow(); - Table.SetCell("Command", "ShowMOTD"); - Table.SetCell("Description", "Show ZNC's message of the day"); + AddCommandHelp(Table, "ShowMOTD", "", "Show ZNC's message of the day", sFilter); if (m_pUser->IsAdmin()) { - Table.AddRow(); - Table.SetCell("Command", "SetMOTD"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Set ZNC's message of the day"); - - Table.AddRow(); - Table.SetCell("Command", "AddMOTD"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Append to ZNC's MOTD"); - - Table.AddRow(); - Table.SetCell("Command", "ClearMOTD"); - Table.SetCell("Description", "Clear ZNC's MOTD"); - - Table.AddRow(); - Table.SetCell("Command", "ListPorts"); - Table.SetCell("Description", "Show all active listeners"); - - Table.AddRow(); - Table.SetCell("Command", "AddPort"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Add another port for ZNC to listen on"); - - Table.AddRow(); - Table.SetCell("Command", "DelPort"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "Remove a port from ZNC"); - - Table.AddRow(); - Table.SetCell("Command", "Rehash"); - Table.SetCell("Description", "Reload znc.conf from disk"); - - Table.AddRow(); - Table.SetCell("Command", "SaveConfig"); - Table.SetCell("Description", "Save the current settings to disk"); - - Table.AddRow(); - Table.SetCell("Command", "ListUsers"); - Table.SetCell("Description", "List all ZNC users and their connection status"); - - Table.AddRow(); - Table.SetCell("Command", "ListAllUserNetworks"); - Table.SetCell("Description", "List all ZNC users and their networks"); - - Table.AddRow(); - Table.SetCell("Command", "ListChans"); - Table.SetCell("Arguments", "[User ]"); - Table.SetCell("Description", "List all channels"); - - Table.AddRow(); - Table.SetCell("Command", "ListClients"); - Table.SetCell("Arguments", "[User]"); - Table.SetCell("Description", "List all connected clients"); - - Table.AddRow(); - Table.SetCell("Command", "Traffic"); - Table.SetCell("Description", "Show basic traffic stats for all ZNC users"); - - Table.AddRow(); - Table.SetCell("Command", "Broadcast"); - Table.SetCell("Arguments", "[message]"); - Table.SetCell("Description", "Broadcast a message to all ZNC users"); - - Table.AddRow(); - Table.SetCell("Command", "Shutdown"); - Table.SetCell("Arguments", "[message]"); - Table.SetCell("Description", "Shut down ZNC completely"); - - Table.AddRow(); - Table.SetCell("Command", "Restart"); - Table.SetCell("Arguments", "[message]"); - Table.SetCell("Description", "Restart ZNC"); + AddCommandHelp(Table, "SetMOTD", "", "Set ZNC's message of the day", sFilter); + AddCommandHelp(Table, "AddMOTD", "", "Append to ZNC's MOTD", sFilter); + AddCommandHelp(Table, "ClearMOTD", "", "Clear ZNC's MOTD", sFilter); + AddCommandHelp(Table, "ListPorts", "", "Show all active listeners", sFilter); + AddCommandHelp(Table, "AddPort", "<[+]port> [bindhost [uriprefix]]", "Add another port for ZNC to listen on", sFilter); + AddCommandHelp(Table, "DelPort", " [bindhost]", "Remove a port from ZNC", sFilter); + AddCommandHelp(Table, "Rehash", "", "Reload znc.conf from disk", sFilter); + AddCommandHelp(Table, "SaveConfig", "", "Save the current settings to disk", sFilter); + AddCommandHelp(Table, "ListUsers", "", "List all ZNC users and their connection status", sFilter); + AddCommandHelp(Table, "ListAllUserNetworks", "", "List all ZNC users and their networks", sFilter); + AddCommandHelp(Table, "ListChans", "[user ]", "List all channels", sFilter); + AddCommandHelp(Table, "ListClients", "[user]", "List all connected clients", sFilter); + AddCommandHelp(Table, "Traffic", "", "Show basic traffic stats for all ZNC users", sFilter); + AddCommandHelp(Table, "Broadcast", "[message]", "Broadcast a message to all ZNC users", sFilter); + AddCommandHelp(Table, "Shutdown", "[message]", "Shut down ZNC completely", sFilter); + AddCommandHelp(Table, "Restart", "[message]", "Restart ZNC", sFilter); } PutStatus(Table); diff --git a/src/Modules.cpp b/src/Modules.cpp index 32c39276..5420368a 100644 --- a/src/Modules.cpp +++ b/src/Modules.cpp @@ -570,7 +570,7 @@ bool CModule::HandleCommand(const CString& sLine) { } void CModule::HandleHelpCommand(const CString& sLine) { - CString sFilter = sLine.Token(1, true); + CString sFilter = sLine.Token(1); CString::size_type iFilterLength = sFilter.size(); CTable Table; map::const_iterator it;