From 5279bb62a012bbf02ec377c310dc36ececed582f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 19 Aug 2014 19:57:27 +0200 Subject: [PATCH] flooddetach: add command "silent [yes|no]" Inspired by the route_replis module. Resolves #591. --- modules/flooddetach.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/modules/flooddetach.cpp b/modules/flooddetach.cpp index 72720264..2c17d519 100644 --- a/modules/flooddetach.cpp +++ b/modules/flooddetach.cpp @@ -29,6 +29,7 @@ public: 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() { @@ -85,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(); @@ -143,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) { @@ -203,6 +208,20 @@ public: } } + 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;