From 67f4a73f4b49f8540f014b8a9806121ea5b6fca1 Mon Sep 17 00:00:00 2001 From: prozacx Date: Sun, 7 Nov 2004 04:28:16 +0000 Subject: [PATCH] Added option for AutoCycle git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@31 726aef4b-f618-498e-8847-2d620e286838 --- Chan.cpp | 4 +++- Chan.h | 4 ++++ znc.conf | 6 ++++++ znc.cpp | 10 ++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Chan.cpp b/Chan.cpp index 2b9dc07b..b74ee87b 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -18,7 +18,9 @@ void CChan::Joined() { } void CChan::Cycle() const { - m_pUser->PutIRC("PART " + GetName() + "\r\nJOIN " + GetName() + " " + GetKey()); + if (AutoCycle()) { + m_pUser->PutIRC("PART " + GetName() + "\r\nJOIN " + GetName() + " " + GetKey()); + } } string CChan::GetModeString() const { diff --git a/Chan.h b/Chan.h index 3f1beba6..3313139e 100644 --- a/Chan.h +++ b/Chan.h @@ -27,6 +27,7 @@ public: m_sName = sName; m_pUser = pUser; m_bKeepBuffer = false; + m_bAutoCycle = true; m_uBufferCount = uBufferCount; Reset(); } @@ -78,6 +79,7 @@ public: void DecVoiceCount() { m_uVoiceCount -= (m_uVoiceCount > 0); } void SetBufferCount(unsigned int u) { m_uBufferCount = u; } void SetKeepBuffer(bool b) { m_bKeepBuffer = b; } + void SetAutoCycle(bool b) { m_bAutoCycle = b; } void SetWhoDone(bool b = true) { m_bWhoDone = b; } // !Setters @@ -98,12 +100,14 @@ public: unsigned int GetBufferCount() const { return m_uBufferCount; } bool HasMode(EMode eMode) const { return (m_uModes & eMode); } bool KeepBuffer() const { return m_bKeepBuffer; } + bool AutoCycle() const { return m_bAutoCycle; } // !Getters private: protected: bool m_bIsOn; bool m_bWhoDone; bool m_bKeepBuffer; + bool m_bAutoCycle; string m_sName; string m_sKey; string m_sTopic; diff --git a/znc.conf b/znc.conf index d20cc387..69fe40d5 100644 --- a/znc.conf +++ b/znc.conf @@ -39,6 +39,9 @@ StatusPrefix = * ChanModes = +stn KeepNick = true + // You may choose not to take advantage of znc's auto cycle which will cycle the channel if you are the last person and not opped + #AutoCycle = false + // You may use multiple Allow lines to restrict access to this user. All connections are denied by default unless they match an ip below. // Note: IPs only! Allow = * @@ -74,6 +77,9 @@ StatusPrefix = * Key = znc Modes = +sn-t + // You can override the user's auto cycle on a per channel basis + #AutoCycle = true + // This is the playback buffer size (in LINES) - WARNING: setting this too high could cause you to get a lot of text when you attach Buffer = 50 diff --git a/znc.cpp b/znc.cpp index 333d4a40..a45de6b9 100644 --- a/znc.cpp +++ b/znc.cpp @@ -227,6 +227,7 @@ bool CZNC::ParseConfig(const string& sConfigFile) { string sLine; bool bCommented = false; // support for /**/ style comments + bool bAutoCycle = true; CUser* pUser = NULL; // Used to keep track of which user block we are in CChan* pChan = NULL; // Used to keep track of which chan block we are in @@ -298,6 +299,8 @@ bool CZNC::ParseConfig(const string& sConfigFile) { } pUser = new CUser(sValue, this); + bAutoCycle = true; + if (!sStatusPrefix.empty()) { if (!pUser->SetStatusPrefix(sStatusPrefix)) { cerr << "Invalid StatusPrefix [" + sStatusPrefix + "] Must be 1-5 chars, no spaces." << endl; @@ -317,6 +320,7 @@ bool CZNC::ParseConfig(const string& sConfigFile) { } pChan = new CChan(sValue, pUser); + pChan->SetAutoCycle(bAutoCycle); continue; } } @@ -336,6 +340,9 @@ bool CZNC::ParseConfig(const string& sConfigFile) { } else if (strcasecmp(sName.c_str(), "KeepBuffer") == 0) { pChan->SetKeepBuffer((strcasecmp(sValue.c_str(), "true") == 0)); continue; + } else if (strcasecmp(sName.c_str(), "AutoCycle") == 0) { + pChan->SetAutoCycle((strcasecmp(sValue.c_str(), "true") == 0)); + continue; } else if (strcasecmp(sName.c_str(), "Key") == 0) { pChan->SetKey(sValue); continue; @@ -359,6 +366,9 @@ bool CZNC::ParseConfig(const string& sConfigFile) { pUser->SetPass(sValue, false); } + continue; + } else if (strcasecmp(sName.c_str(), "AutoCycle") == 0) { + bAutoCycle = (strcasecmp(sValue.c_str(), "true") == 0); continue; } else if (strcasecmp(sName.c_str(), "Ident") == 0) { pUser->SetIdent(sValue);