From 6ed10a1cf4eae511120a0502d27dcb84dfd43cd8 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 4 Sep 2011 21:00:06 +0200 Subject: [PATCH] autocycle: Only cycle once in 15 seconds This should stop all fights against ChanServ. Please note that nothing will happen if we are the only one in the channel after 15 secs since this module only checks if it needs to do something when someone leaves a channel. Signed-off-by: Uli Schlachter --- modules/extra/autocycle.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/extra/autocycle.cpp b/modules/extra/autocycle.cpp index 71bd2c42..a1a83811 100644 --- a/modules/extra/autocycle.cpp +++ b/modules/extra/autocycle.cpp @@ -12,7 +12,10 @@ class CAutoCycleMod : public CModule { public: - MODCONSTRUCTOR(CAutoCycleMod) {} + MODCONSTRUCTOR(CAutoCycleMod) { + m_recentlyCycled.SetTTL(15 * 1000); + } + virtual ~CAutoCycleMod() {} virtual bool OnLoad(const CString& sArgs, CString& sMessage) { @@ -120,14 +123,20 @@ protected: if (!IsAutoCycle(Channel.GetName())) return; + // Did we recently annoy opers via cycling of an empty channel? + if (m_recentlyCycled.HasItem(Channel.GetName())) + return; + // Is there only one person left in the channel? if (Channel.GetNickCount() != 1) return; // Is that person us and we don't have op? const CNick& pNick = Channel.GetNicks().begin()->second; - if (!pNick.HasPerm(CChan::Op) && pNick.GetNick().Equals(m_pNetwork->GetCurNick())) + if (!pNick.HasPerm(CChan::Op) && pNick.GetNick().Equals(m_pNetwork->GetCurNick())) { Channel.Cycle(); + m_recentlyCycled.AddItem(Channel.GetName()); + } } bool AlreadyAdded(const CString& sInput) { @@ -223,6 +232,7 @@ protected: private: vector m_vsChans; vector m_vsNegChans; + TCacheMap m_recentlyCycled; }; template<> void TModInfo(CModInfo& Info) {