mirror of
https://github.com/znc/znc.git
synced 2026-08-07 09:22:55 +02:00
Merge pull request #670 from jpnurmi/quit-msg
Allow network specific quit messages
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;
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -59,6 +59,12 @@
|
||||
<div style="clear: both;"></div>
|
||||
<? ENDIF ?>
|
||||
|
||||
<div class="subsection">
|
||||
<div class="inputlabel">Quit Message:</div>
|
||||
<input type="text" name="quitmsg" value="<? VAR QuitMsg ?>" class="full" maxlength="256"
|
||||
title="You may define a Message shown, when you quit IRC." />
|
||||
</div>
|
||||
|
||||
<div class="subsection">
|
||||
<div class="inputlabel">Active:</div>
|
||||
<div class="checkbox"><input type="checkbox" name="doconnect" id="doconnect_checkbox"<? IF IRCConnectEnabled ?> checked="checked"<? ENDIF ?> />
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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