Skip to content
Browse files

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 <psychon@znc.in>
  • Loading branch information...
1 parent 891d7a3 commit fe05574f24f62d172210abba87b017d234502fcc @psychon psychon committed Sep 4, 2011
Showing with 12 additions and 2 deletions.
  1. +12 −2 modules/autocycle.cpp
View
14 modules/autocycle.cpp
@@ -11,7 +11,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) {
@@ -119,14 +122,20 @@ class CAutoCycleMod : public CModule {
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_pUser->GetCurNick()))
+ if (!pNick.HasPerm(CChan::Op) && pNick.GetNick().Equals(m_pUser->GetCurNick())) {
Channel.Cycle();
+ m_recentlyCycled.AddItem(Channel.GetName());
+ }
}
bool AlreadyAdded(const CString& sInput) {
@@ -222,6 +231,7 @@ class CAutoCycleMod : public CModule {
private:
vector<CString> m_vsChans;
vector<CString> m_vsNegChans;
+ TCacheMap<CString> m_recentlyCycled;
};
template<> void TModInfo<CAutoCycleMod>(CModInfo& Info) {

0 comments on commit fe05574

Please sign in to comment.
Something went wrong with that request. Please try again.