diff --git a/modules/clientnotify.cpp b/modules/clientnotify.cpp index 64fface8..25b78374 100644 --- a/modules/clientnotify.cpp +++ b/modules/clientnotify.cpp @@ -44,6 +44,11 @@ protected: public: MODCONSTRUCTOR(CClientNotifyMod) { + AddHelpCommand(); + AddCommand("Method", static_cast(&CClientNotifyMod::OnMethodCommand), "", "Sets the notify method"); + AddCommand("NewOnly", static_cast(&CClientNotifyMod::OnNewOnlyCommand), "", "Turns notifies for unseen IP addresses only on or off"); + AddCommand("OnDisconnect", static_cast(&CClientNotifyMod::OnDisconnectCommand), "", "Turns notifies on disconnecting clients on or off"); + AddCommand("Show", static_cast(&CClientNotifyMod::OnShowCommand), "", "Show the current settings"); } bool OnLoad(const CString& sArgs, CString& sMessage) { @@ -81,35 +86,48 @@ public: } } - void OnModCommand(const CString& sCommand) { - const CString& sCmd = sCommand.Token(0).AsLower(); + void OnMethodCommand(const CString& sCommand) { const CString& sArg = sCommand.Token(1, true).AsLower(); - if (sCmd.Equals("method") && !sArg.empty()) { - if(sArg != "notice" && sArg != "message" && sArg != "off") { - PutModule("Unknown method. Use one of: message / notice / off"); - } - else { - m_sMethod = sArg; - SaveSettings(); - PutModule("Saved."); - } + if (sArg != "notice" && sArg != "message" && sArg != "off") { + PutModule("Usage: Method "); + return; } - else if (sCmd.Equals("newonly") && !sArg.empty()) { - m_bNewOnly = (sArg == "on" || sArg == "true"); - SaveSettings(); - PutModule("Saved."); + + m_sMethod = sArg; + SaveSettings(); + PutModule("Saved."); + } + + void OnNewOnlyCommand(const CString& sCommand) { + const CString& sArg = sCommand.Token(1, true).AsLower(); + + if (sArg.empty()) { + PutModule("Usage: NewOnly "); + return; } - else if (sCmd.Equals("ondisconnect") && !sArg.empty()) { - m_bOnDisconnect = (sArg == "on" || sArg == "true"); - SaveSettings(); - PutModule("Saved."); - } - else { - PutModule("Current settings: Method: " + m_sMethod + ", for unseen IP addresses only: " + CString(m_bNewOnly) + - ", notify on disconnecting clients: " + CString(m_bOnDisconnect)); - PutModule("Commands: show, method , newonly , ondisconnect "); + + m_bNewOnly = sArg.ToBool(); + SaveSettings(); + PutModule("Saved."); + } + + void OnDisconnectCommand(const CString& sCommand) { + const CString& sArg = sCommand.Token(1, true).AsLower(); + + if (sArg.empty()) { + PutModule("Usage: OnDisconnect "); + return; } + + m_bOnDisconnect = sArg.ToBool(); + SaveSettings(); + PutModule("Saved."); + } + + void OnShowCommand(const CString& sLine) { + PutModule("Current settings: Method: " + m_sMethod + ", for unseen IP addresses only: " + CString(m_bNewOnly) + + ", notify on disconnecting clients: " + CString(m_bOnDisconnect)); } };