From 7f8fbc2294dc86c162fe2fa4cc855c29a1582901 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Tue, 21 Feb 2012 19:59:10 +0700 Subject: [PATCH] Drop antiidle, fakeonline and motdfile. If someone needs them, feel free to resurrect. --- modules/antiidle.cpp | 113 ----------------------------------------- modules/fakeonline.cpp | 100 ------------------------------------ modules/motdfile.cpp | 40 --------------- 3 files changed, 253 deletions(-) delete mode 100644 modules/antiidle.cpp delete mode 100644 modules/fakeonline.cpp delete mode 100644 modules/motdfile.cpp diff --git a/modules/antiidle.cpp b/modules/antiidle.cpp deleted file mode 100644 index e4123928..00000000 --- a/modules/antiidle.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2004-2012 See the AUTHORS file for details. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation. - */ - -#include -#include - -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() == m_pNetwork->GetIRCNick().GetNick() - && sMessage == "\xAE") - return HALT; - - return CONTINUE; - } - - virtual EModRet OnRaw(CString &sLine) { - /* If we send a message to ourselfs while we are away, this - * will result in the server sending a 301 which we shouldn't - * forward to the client */ - - if (sLine.Token(1).Equals("301") && sLine.Token(3).Equals(m_pNetwork->GetIRCNick().GetNick())) { - return HALT; - } - - return CONTINUE; - } - -private: - void SetInterval(int 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()->GetNetwork()->GetIRCNick().GetNick(); - GetModule()->PutIRC("PRIVMSG " + sNick + " :\xAE"); -} - -NETWORKMODULEDEFS(CAntiIdle, "Hides your real idle time") diff --git a/modules/fakeonline.cpp b/modules/fakeonline.cpp deleted file mode 100644 index d8626550..00000000 --- a/modules/fakeonline.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2008-2012 See the AUTHORS file for details. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation. - */ - -#include -#include -#include - -class CFOModule : public CModule { -public: - MODCONSTRUCTOR(CFOModule) {} - virtual ~CFOModule() {} - - bool IsOnlineModNick(const CString& sNick) { - const CString& sPrefix = m_pUser->GetStatusPrefix(); - if (!sNick.Equals(sPrefix, false, sPrefix.length())) - return false; - - CString sModNick = sNick.substr(sPrefix.length()); - if (!sModNick.Equals("status") && - !m_pUser->GetModules().FindModule(sModNick) && - !CZNC::Get().GetModules().FindModule(sModNick)) - return false; - return true; - } - - virtual EModRet OnUserRaw(CString& sLine) { - //Handle ISON - if (sLine.Token(0).Equals("ison")) { - VCString vsNicks; - VCString::const_iterator it; - - // Get the list of nicks which are being asked for - sLine.Token(1, true).TrimLeft_n(":").Split(" ", vsNicks, false); - - CString sBNCNicks; - for (it = vsNicks.begin(); it != vsNicks.end(); ++it) { - if (IsOnlineModNick(*it)) { - sBNCNicks += " " + *it; - } - } - // Remove the leading space - sBNCNicks.LeftChomp(); - - if (!m_pNetwork->GetIRCSock()) { - // if we are not connected to any IRC server, send - // an empty or module-nick filled response. - PutUser(":irc.znc.in 303 " + m_pClient->GetNick() + " :" + sBNCNicks); - } else { - // We let the server handle this request and then act on - // the 303 response from the IRC server. - m_ISONRequests.push_back(sBNCNicks); - } - } - - //Handle WHOIS - if (sLine.Token(0).Equals("whois")) { - CString sNick = sLine.Token(1); - - if (IsOnlineModNick(sNick)) { - PutUser(":znc.in 311 " + m_pNetwork->GetCurNick() + " " + sNick + " " + sNick + " znc.in * :" + sNick); - PutUser(":znc.in 312 " + m_pNetwork->GetCurNick() + " " + sNick + " *.znc.in :Bouncer"); - PutUser(":znc.in 318 " + m_pNetwork->GetCurNick() + " " + sNick + " :End of /WHOIS list."); - - return HALT; - } - } - - return CONTINUE; - } - - virtual EModRet OnRaw(CString& sLine) { - //Handle 303 reply if m_Requests is not empty - if (sLine.Token(1) == "303" && !m_ISONRequests.empty()) { - VCString::iterator it = m_ISONRequests.begin(); - - sLine.Trim(); - - // Only append a space if this isn't an empty reply - if (sLine.Right(1) != ":") { - sLine += " "; - } - - //add BNC nicks to the reply - sLine += *it; - m_ISONRequests.erase(it); - } - - return CONTINUE; - } - -private: - VCString m_ISONRequests; -}; - -NETWORKMODULEDEFS(CFOModule, "Fakes online status of ZNC *-users.") diff --git a/modules/motdfile.cpp b/modules/motdfile.cpp deleted file mode 100644 index d7d8367a..00000000 --- a/modules/motdfile.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2004-2012 See the AUTHORS file for details. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation. - */ - -#include -#include -#include - -class CMotdFileMod : public CModule { -public: - MODCONSTRUCTOR(CMotdFileMod) {} - virtual ~CMotdFileMod() {} - - virtual bool OnLoad(const CString& sArgs, CString& sMessage) { - if (sArgs.empty()) { - sMessage = "Argument must be path to a MOTD file"; - return false; - } - return true; - } - - virtual void OnClientLogin() { - CString sFile = GetArgs(); - CString sBuffer; - CFile cFile(sFile); - if (!cFile.Open(O_RDONLY)) { - m_pClient->PutStatusNotice("Could not open MOTD file"); - return; - } - while (cFile.ReadLine(sBuffer)) - m_pClient->PutStatusNotice(sBuffer); - cFile.Close(); - } -}; - -GLOBALMODULEDEFS(CMotdFileMod, "Send MOTD from a file")