mirror of
https://github.com/znc/znc.git
synced 2026-08-07 01:13:25 +02:00
Allow network specific quit messages (resolves #273)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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<CServer*>& 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<bool> 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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user