mirror of
https://github.com/znc/znc.git
synced 2026-07-05 17:31:06 +02:00
ctcpflood: use CModCommand
This commit is contained in:
+37
-21
@@ -22,6 +22,11 @@ public:
|
||||
MODCONSTRUCTOR(CCtcpFloodMod) {
|
||||
m_tLastCTCP = 0;
|
||||
m_iNumCTCP = 0;
|
||||
|
||||
AddHelpCommand();
|
||||
AddCommand("Secs", static_cast<CModCommand::ModCmdFunc>(&CCtcpFloodMod::OnSecsCommand), "<limit>", "Set seconds limit");
|
||||
AddCommand("Lines", static_cast<CModCommand::ModCmdFunc>(&CCtcpFloodMod::OnLinesCommand), "<limit>", "Set lines limit");
|
||||
AddCommand("Show", static_cast<CModCommand::ModCmdFunc>(&CCtcpFloodMod::OnShowCommand), "", "Show the current limits");
|
||||
}
|
||||
|
||||
~CCtcpFloodMod() {
|
||||
@@ -87,30 +92,41 @@ public:
|
||||
return Message(Nick, sMessage);
|
||||
}
|
||||
|
||||
void OnModCommand(const CString& sCommand) {
|
||||
const CString& sCmd = sCommand.Token(0);
|
||||
void OnSecsCommand(const CString& sCommand) {
|
||||
const CString& sArg = sCommand.Token(1, true);
|
||||
|
||||
if (sCmd.Equals("secs") && !sArg.empty()) {
|
||||
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()) {
|
||||
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) + " CTCPs "
|
||||
"in " + CString(m_iThresholdSecs) + " secs");
|
||||
} else {
|
||||
PutModule("Commands: show, secs [limit], lines [limit]");
|
||||
if (sArg.empty()) {
|
||||
PutModule("Usage: Secs <limit>");
|
||||
return;
|
||||
}
|
||||
|
||||
m_iThresholdSecs = sArg.ToUInt();
|
||||
if (m_iThresholdSecs == 0)
|
||||
m_iThresholdSecs = 1;
|
||||
|
||||
PutModule("Set seconds limit to [" + CString(m_iThresholdSecs) + "]");
|
||||
Save();
|
||||
}
|
||||
|
||||
void OnLinesCommand(const CString& sCommand) {
|
||||
const CString& sArg = sCommand.Token(1, true);
|
||||
|
||||
if (sArg.empty()) {
|
||||
PutModule("Usage: Lines <limit>");
|
||||
return;
|
||||
}
|
||||
|
||||
m_iThresholdMsgs = sArg.ToUInt();
|
||||
if (m_iThresholdMsgs == 0)
|
||||
m_iThresholdMsgs = 2;
|
||||
|
||||
PutModule("Set lines limit to [" + CString(m_iThresholdMsgs) + "]");
|
||||
Save();
|
||||
}
|
||||
|
||||
void OnShowCommand(const CString& sCommand) {
|
||||
PutModule("Current limit is " + CString(m_iThresholdMsgs) + " CTCPs "
|
||||
"in " + CString(m_iThresholdSecs) + " secs");
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user