CChan: keep track of the state

Make CChan keep track of the channel key, and schedule saving of the
config file when appropriate. This is more robust than trying to do
it from within the chansaver module.
This commit is contained in:
J-P Nurmi
2014-10-12 22:13:07 +02:00
parent 206c149f48
commit c424bd7aca
2 changed files with 28 additions and 2 deletions
+26
View File
@@ -19,6 +19,7 @@
#include <znc/User.h>
#include <znc/IRCNetwork.h>
#include <znc/Config.h>
#include <znc/znc.h>
using std::set;
using std::vector;
@@ -364,6 +365,13 @@ void CChan::ModeChange(const CString& sModes, const CNick* pOpNick) {
if (!bList) {
(bAdd) ? AddMode(uMode, sArg) : RemMode(uMode);
}
// This is called when we join (ZNC requests the channel modes
// on join) *and* when someone changes the channel keys.
// We ignore channel key "*" because of some broken nets.
if (uMode == 'k' && !bNoChange && bAdd && sArg != "*") {
SetKey(sArg);
}
}
}
}
@@ -623,3 +631,21 @@ void CChan::Enable() {
ResetJoinTries();
m_bDisabled = false;
}
void CChan::SetKey(const CString& s) {
if (m_sKey != s) {
m_sKey = s;
if (m_bInConfig) {
CZNC::Get().SetConfigState(CZNC::ECONFIG_NEED_WRITE);
}
}
}
void CChan::SetInConfig(bool b) {
if (m_bInConfig != b) {
m_bInConfig = b;
if (m_bInConfig) {
CZNC::Get().SetConfigState(CZNC::ECONFIG_NEED_WRITE);
}
}
}