diff --git a/modules/flooddetach.cpp b/modules/flooddetach.cpp index f4ed8921..2c17d519 100644 --- a/modules/flooddetach.cpp +++ b/modules/flooddetach.cpp @@ -24,6 +24,12 @@ public: MODCONSTRUCTOR(CFloodDetachMod) { m_iThresholdSecs = 0; m_iThresholdMsgs = 0; + + AddHelpCommand(); + AddCommand("Show", static_cast(&CFloodDetachMod::ShowCommand), ""); + AddCommand("Secs", static_cast(&CFloodDetachMod::SecsCommand), "[]"); + AddCommand("Lines", static_cast(&CFloodDetachMod::LinesCommand), "[]"); + AddCommand("Silent", static_cast(&CFloodDetachMod::SilentCommand), "[yes|no]"); } ~CFloodDetachMod() { @@ -80,8 +86,10 @@ public: // channels which we detached, this means that // we detached because of a flood. - PutModule("Flood in [" + pChan->GetName() + "] is over, " - "re-attaching..."); + if (!GetNV("silent").ToBool()) { + PutModule("Flood in [" + pChan->GetName() + "] is over, " + "re-attaching..."); + } // No buffer playback, makes sense, doesn't it? pChan->ClearBuffer(); pChan->JoinUser(); @@ -138,8 +146,10 @@ public: it->second.first = now; Channel.DetachUser(); - PutModule("Channel [" + Channel.GetName() + "] was " - "flooded, you've been detached"); + if (!GetNV("silent").ToBool()) { + PutModule("Channel [" + Channel.GetName() + "] was " + "flooded, you've been detached"); + } } EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage) { @@ -163,31 +173,55 @@ public: return CONTINUE; } - void OnModCommand(const CString& sCommand) { - const CString& sCmd = sCommand.Token(0); - const CString& sArg = sCommand.Token(1, true); + void ShowCommand(const CString& sLine) { + PutModule("Current limit is " + CString(m_iThresholdMsgs) + " lines " + "in " + CString(m_iThresholdSecs) + " secs."); + } - if (sCmd.Equals("secs") && !sArg.empty()) { + void SecsCommand(const CString& sLine) { + const CString sArg = sLine.Token(1, true); + + if (sArg.empty()) { + PutModule("Seconds limit is [" + CString(m_iThresholdSecs) + "]"); + } else { m_iThresholdSecs = sArg.ToUInt(); if (m_iThresholdSecs == 0) m_iThresholdSecs = 1; PutModule("Set seconds limit to [" + CString(m_iThresholdSecs) + "]"); Save(); - } else if (sCmd.Equals("lines") && !sArg.empty()) { + } + } + + void LinesCommand(const CString& sLine) { + const CString sArg = sLine.Token(1, true); + + if (sArg.empty()) { + PutModule("Lines limit is [" + CString(m_iThresholdMsgs) + "]"); + } else { m_iThresholdMsgs = sArg.ToUInt(); if (m_iThresholdMsgs == 0) m_iThresholdMsgs = 2; PutModule("Set lines limit to [" + CString(m_iThresholdMsgs) + "]"); Save(); - } else if (sCmd.Equals("show")) { - PutModule("Current limit is " + CString(m_iThresholdMsgs) + " lines " - "in " + CString(m_iThresholdSecs) + " secs."); - } else { - PutModule("Commands: show, secs , lines "); } } + + void SilentCommand(const CString& sLine) { + const CString sArg = sLine.Token(1, true); + + if (!sArg.empty()) { + SetNV("silent", CString(sArg.ToBool())); + } + + if (GetNV("silent").ToBool()) { + PutModule("Module messages are disabled"); + } else { + PutModule("Module messages are enabled"); + } + } + private: typedef map > Limits; Limits m_chans;