diff --git a/include/znc/IRCNetwork.h b/include/znc/IRCNetwork.h index 171f0aeb..28aff9f6 100644 --- a/include/znc/IRCNetwork.h +++ b/include/znc/IRCNetwork.h @@ -163,6 +163,7 @@ public: const CString& GetRealName() const; const CString& GetBindHost() const; const CString& GetEncoding() const; + CString GetQuitMsg() const; void SetNick(const CString& s); void SetAltNick(const CString& s); @@ -170,6 +171,7 @@ public: void SetRealName(const CString& s); void SetBindHost(const CString& s); void SetEncoding(const CString& s); + void SetQuitMsg(const CString& s); double GetFloodRate() const { return m_fFloodRate; } unsigned short int GetFloodBurst() const { return m_uFloodBurst; } @@ -191,6 +193,7 @@ protected: CString m_sRealName; CString m_sBindHost; CString m_sEncoding; + CString m_sQuitMsg; CModules* m_pModules; diff --git a/src/IRCNetwork.cpp b/src/IRCNetwork.cpp index 957f4f27..4739037d 100644 --- a/src/IRCNetwork.cpp +++ b/src/IRCNetwork.cpp @@ -162,6 +162,7 @@ void CIRCNetwork::Clone(const CIRCNetwork& Network, bool bCloneName) { SetRealName(Network.GetRealName()); SetBindHost(Network.GetBindHost()); SetEncoding(Network.GetEncoding()); + SetQuitMsg(Network.GetQuitMsg()); // Servers const vector& vServers = Network.GetServers(); @@ -332,6 +333,7 @@ bool CIRCNetwork::ParseConfig(CConfig *pConfig, CString& sError, bool bUpgrade) { "realname", &CIRCNetwork::SetRealName }, { "bindhost", &CIRCNetwork::SetBindHost }, { "encoding", &CIRCNetwork::SetEncoding }, + { "quitmsg", &CIRCNetwork::SetQuitMsg }, }; size_t numStringOptions = sizeof(StringOptions) / sizeof(StringOptions[0]); TOption BoolOptions[] = { @@ -480,6 +482,10 @@ CConfig CIRCNetwork::ToConfig() { config.AddKeyValuePair("FloodBurst", CString(GetFloodBurst())); config.AddKeyValuePair("Encoding", m_sEncoding); + if (!m_sQuitMsg.empty()) { + config.AddKeyValuePair("QuitMsg", m_sQuitMsg); + } + // Modules CModules& Mods = GetModules(); @@ -1269,6 +1275,14 @@ const CString& CIRCNetwork::GetEncoding() const { return m_sEncoding; } +CString CIRCNetwork::GetQuitMsg() const { + if (m_sQuitMsg.empty()) { + return m_pUser->GetQuitMsg(); + } + + return m_sQuitMsg; +} + void CIRCNetwork::SetNick(const CString& s) { if (m_pUser->GetNick().Equals(s)) { m_sNick = ""; @@ -1313,6 +1327,14 @@ void CIRCNetwork::SetEncoding(const CString& s) { m_sEncoding = s; } +void CIRCNetwork::SetQuitMsg(const CString& s) { + if (m_pUser->GetQuitMsg().Equals(s)) { + m_sQuitMsg = ""; + } else { + m_sQuitMsg = s; + } +} + CString CIRCNetwork::ExpandString(const CString& sStr) const { CString sRet; return ExpandString(sStr, sRet); diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 16f04bfc..cbf88fd6 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -124,7 +124,7 @@ void CIRCSock::Quit(const CString& sQuitMsg) { if (!sQuitMsg.empty()) { PutIRC("QUIT :" + sQuitMsg); } else { - PutIRC("QUIT :" + m_pNetwork->ExpandString(m_pNetwork->GetUser()->GetQuitMsg())); + PutIRC("QUIT :" + m_pNetwork->ExpandString(m_pNetwork->GetQuitMsg())); } Close(CLT_AFTERWRITE); }