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/modules/controlpanel.cpp b/modules/controlpanel.cpp index de6e138a..cb9e0c63 100644 --- a/modules/controlpanel.cpp +++ b/modules/controlpanel.cpp @@ -116,6 +116,7 @@ class CAdminMod : public CModule { #ifdef HAVE_ICU {"Encoding", str}, #endif + {"QuitMsg", str}, }; for (unsigned int i = 0; i != ARRAY_SIZE(nvars); ++i) { if (sVarFilter.empty() || sVarFilter.Equals(nvars[i][0], false, iVarLength)) { @@ -498,6 +499,8 @@ class CAdminMod : public CModule { } else if (sVar.Equals("encoding")) { PutModule("Encoding = " + pNetwork->GetEncoding()); #endif + } else if (sVar.Equals("quitmsg")) { + PutModule("QuitMsg = " + pNetwork->GetQuitMsg()); } else { PutModule("Error: Unknown variable"); } @@ -586,6 +589,9 @@ class CAdminMod : public CModule { pNetwork->SetEncoding(sValue); PutModule("Encoding = " + pNetwork->GetEncoding()); #endif + } else if (sVar.Equals("quitmsg")) { + pNetwork->SetQuitMsg(sValue); + PutModule("QuitMsg = " + pNetwork->GetQuitMsg()); } else { PutModule("Error: Unknown variable"); } diff --git a/modules/data/webadmin/tmpl/add_edit_network.tmpl b/modules/data/webadmin/tmpl/add_edit_network.tmpl index ed2af746..0ef92c55 100644 --- a/modules/data/webadmin/tmpl/add_edit_network.tmpl +++ b/modules/data/webadmin/tmpl/add_edit_network.tmpl @@ -59,6 +59,12 @@
+
+
Quit Message:
+ +
+
Active:
checked="checked" /> diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp index f575e76c..e529c358 100644 --- a/modules/webadmin.cpp +++ b/modules/webadmin.cpp @@ -809,6 +809,8 @@ public: Tmpl["Ident"] = pNetwork->GetIdent(); Tmpl["RealName"] = pNetwork->GetRealName(); + Tmpl["QuitMsg"] = pNetwork->GetQuitMsg(); + Tmpl["FloodProtection"] = CString(CIRCSock::IsFloodProtected(pNetwork->GetFloodRate())); Tmpl["FloodRate"] = CString(pNetwork->GetFloodRate()); Tmpl["FloodBurst"] = CString(pNetwork->GetFloodBurst()); @@ -900,6 +902,8 @@ public: pNetwork->SetIdent(WebSock.GetParam("ident")); pNetwork->SetRealName(WebSock.GetParam("realname")); + pNetwork->SetQuitMsg(WebSock.GetParam("quitmsg")); + pNetwork->SetIRCConnectEnabled(WebSock.GetParam("doconnect").ToBool()); sArg = WebSock.GetParam("bindhost"); 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); }