mirror of
https://github.com/znc/znc.git
synced 2026-07-04 08:51:14 +02:00
Remove antiidle module.
Antiidle utilities are bad as they waste bandwidth and might fill logs. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@841 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
#include "main.h"
|
||||
#include "User.h"
|
||||
#include "Nick.h"
|
||||
#include "Modules.h"
|
||||
|
||||
class CAntiIdle;
|
||||
|
||||
class CAntiIdleJob : public CTimer
|
||||
{
|
||||
public:
|
||||
CAntiIdleJob(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription)
|
||||
: CTimer(pModule, uInterval, uCycles, sLabel, sDescription) {}
|
||||
|
||||
virtual ~CAntiIdleJob() {}
|
||||
|
||||
protected:
|
||||
virtual void RunJob();
|
||||
};
|
||||
|
||||
class CAntiIdle : public CModule
|
||||
{
|
||||
public:
|
||||
MODCONSTRUCTOR(CAntiIdle) {
|
||||
SetInterval(30);
|
||||
}
|
||||
|
||||
virtual ~CAntiIdle() { }
|
||||
|
||||
virtual bool OnLoad(const CString& sArgs, CString& sErrorMsg)
|
||||
{
|
||||
if(!sArgs.Trim_n().empty())
|
||||
SetInterval(sArgs.ToInt());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void OnModCommand( const CString& sCommand )
|
||||
{
|
||||
CString sCmdName = sCommand.Token(0).AsLower();
|
||||
if(sCmdName == "set")
|
||||
{
|
||||
CString sInterval = sCommand.Token(1, true);
|
||||
SetInterval(sInterval.ToInt());
|
||||
|
||||
if(m_uiInterval == 0)
|
||||
PutModule("AntiIdle is now turned off.");
|
||||
else
|
||||
PutModule("AntiIdle is now set to " + CString(m_uiInterval) + " seconds.");
|
||||
} else if(sCmdName == "off") {
|
||||
SetInterval(0);
|
||||
PutModule("AntiIdle is now turned off");
|
||||
} else if(sCmdName == "show") {
|
||||
if(m_uiInterval == 0)
|
||||
PutModule("AntiIdle is turned off.");
|
||||
else
|
||||
PutModule("AntiIdle is set to " + CString(m_uiInterval) + " seconds.");
|
||||
} else
|
||||
{
|
||||
PutModule("Commands: set, off, show");
|
||||
}
|
||||
}
|
||||
|
||||
virtual EModRet OnPrivMsg(CNick &Nick, CString &sMessage) {
|
||||
if(Nick.GetNick() == GetUser()->GetIRCNick().GetNick()
|
||||
&& sMessage == "\xAE")
|
||||
return HALTCORE;
|
||||
|
||||
return CONTINUE;
|
||||
}
|
||||
|
||||
private:
|
||||
void SetInterval(uint i) {
|
||||
if(i < 0)
|
||||
return;
|
||||
|
||||
m_uiInterval = i;
|
||||
|
||||
RemTimer("AntiIdle");
|
||||
|
||||
if(m_uiInterval == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
AddTimer(new CAntiIdleJob(this, m_uiInterval, 0, "AntiIdle", "Periodically sends a msg to the user"));
|
||||
}
|
||||
|
||||
unsigned int m_uiInterval;
|
||||
};
|
||||
|
||||
//! This function sends a query with (r) back to the user
|
||||
void CAntiIdleJob::RunJob() {
|
||||
CString sNick = GetModule()->GetUser()->GetIRCNick().GetNick();
|
||||
GetModule()->PutIRC("PRIVMSG " + sNick + " :\xAE");
|
||||
}
|
||||
|
||||
MODULEDEFS(CAntiIdle, "Hides your real idle time")
|
||||
Reference in New Issue
Block a user