mirror of
https://github.com/znc/znc.git
synced 2026-07-04 17:01:23 +02:00
Merge pull request #633 from jpnurmi/flooddetach
flooddetach: add command "silent [yes|no]"
This commit is contained in:
+48
-14
@@ -24,6 +24,12 @@ public:
|
||||
MODCONSTRUCTOR(CFloodDetachMod) {
|
||||
m_iThresholdSecs = 0;
|
||||
m_iThresholdMsgs = 0;
|
||||
|
||||
AddHelpCommand();
|
||||
AddCommand("Show", static_cast<CModCommand::ModCmdFunc>(&CFloodDetachMod::ShowCommand), "");
|
||||
AddCommand("Secs", static_cast<CModCommand::ModCmdFunc>(&CFloodDetachMod::SecsCommand), "[<limit>]");
|
||||
AddCommand("Lines", static_cast<CModCommand::ModCmdFunc>(&CFloodDetachMod::LinesCommand), "[<limit>]");
|
||||
AddCommand("Silent", static_cast<CModCommand::ModCmdFunc>(&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 <limit>, lines <limit>");
|
||||
}
|
||||
}
|
||||
|
||||
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<CString, std::pair<time_t, unsigned int> > Limits;
|
||||
Limits m_chans;
|
||||
|
||||
Reference in New Issue
Block a user