diff --git a/IRCSock.cpp b/IRCSock.cpp index eeb1ba87..dd025177 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -621,12 +621,7 @@ bool CIRCSock::OnCTCPReply(const CString& sNickMask, CString& sMessage) { bool CIRCSock::OnPrivCTCP(const CString& sNickMask, CString& sMessage) { MODULECALL(OnPrivCTCP(sNickMask, sMessage)); - if (sMessage.CaseCmp("VERSION") == 0) { - if (!IsUserAttached()) { - CString sVersionReply = m_pUser->GetVersionReply(); - PutServ("NOTICE " + CNick(sNickMask).GetNick() + " :\001VERSION " + sVersionReply + "\001"); - } - } else if (strncasecmp(sMessage.c_str(), "DCC ", 4) == 0 && m_pUser && m_pUser->BounceDCCs()) { + if (strncasecmp(sMessage.c_str(), "DCC ", 4) == 0 && m_pUser && m_pUser->BounceDCCs()) { // DCC CHAT chat 2453612361 44592 CString sType = sMessage.Token(1); CString sFile = sMessage.Token(2); @@ -674,6 +669,25 @@ bool CIRCSock::OnPrivCTCP(const CString& sNickMask, CString& sMessage) { } return true; + } else { + if (!IsUserAttached()) { + const MCString& mssCTCPReplies = m_pUser->GetCTCPReplies(); + MCString::const_iterator it = mssCTCPReplies.find(sMessage.AsUpper()); + CString sQuery = sMessage.Token(0).AsUpper(); + CString sReply; + + if (it != mssCTCPReplies.end()) { + sReply = it->second; + } + + if (sReply.empty() && sQuery == "VERSION") { + sReply = "ZNC by prozac - http://znc.sourceforge.net"; + } + + if (!sReply.empty()) { + PutServ("NOTICE " + CNick(sNickMask).GetNick() + " :\001" + sQuery + " " + sReply + "\001"); + } + } } return false; diff --git a/User.cpp b/User.cpp index f09bb679..67fa58b2 100644 --- a/User.cpp +++ b/User.cpp @@ -461,7 +461,7 @@ void CUser::SetDefaultChanModes(const CString& s) { m_sDefaultChanModes = s; } void CUser::SetIRCNick(const CNick& n) { m_IRCNick = n; } void CUser::SetIRCServer(const CString& s) { m_sIRCServer = s; } void CUser::SetQuitMsg(const CString& s) { m_sQuitMsg = s; } -void CUser::SetVersionReply(const CString& s) { m_sVersionReply = s; } +void CUser::AddCTCPReply(const CString& sCTCP, const CString& sReply) { m_mssCTCPReplies[sCTCP.AsUpper()] = sReply; } void CUser::SetBufferCount(unsigned int u) { m_uBufferCount = u; } void CUser::SetKeepBuffer(bool b) { m_bKeepBuffer = b; } @@ -539,7 +539,7 @@ const vector& CUser::GetServers() const { return m_vServers; } const CNick& CUser::GetIRCNick() const { return m_IRCNick; } const CString& CUser::GetIRCServer() const { return m_sIRCServer; } CString CUser::GetQuitMsg() const { return (!m_sQuitMsg.empty()) ? m_sQuitMsg : "ZNC by prozac - http://znc.sourceforge.net"; } -CString CUser::GetVersionReply() const { return (!m_sVersionReply.empty()) ? m_sVersionReply : "ZNC by prozac - http://znc.sourceforge.net"; } +const MCString& CUser::GetCTCPReplies() const { return m_mssCTCPReplies; } unsigned int CUser::GetBufferCount() const { return m_uBufferCount; } bool CUser::KeepBuffer() const { return m_bKeepBuffer; } // !Getters diff --git a/User.h b/User.h index 504a585c..b47b1466 100644 --- a/User.h +++ b/User.h @@ -80,7 +80,7 @@ public: void SetIRCNick(const CNick& n); void SetIRCServer(const CString& s); void SetQuitMsg(const CString& s); - void SetVersionReply(const CString& s); + void AddCTCPReply(const CString& sCTCP, const CString& sReply); void SetBufferCount(unsigned int u); void SetKeepBuffer(bool b); // !Setters @@ -118,7 +118,7 @@ public: const CNick& GetIRCNick() const; const CString& GetIRCServer() const; CString GetQuitMsg() const; - CString GetVersionReply() const; + const MCString& GetCTCPReplies() const; unsigned int GetBufferCount() const; bool KeepBuffer() const; // !Getters @@ -140,7 +140,7 @@ protected: CNick m_IRCNick; CString m_sIRCServer; CString m_sQuitMsg; - CString m_sVersionReply; + MCString m_mssCTCPReplies; // Paths CString m_sUserPath; diff --git a/znc.conf b/znc.conf index efc25eb7..38ca931d 100644 --- a/znc.conf +++ b/znc.conf @@ -46,7 +46,7 @@ StatusPrefix = * RealName = Got ZNC? #VHost = uncomment.and.put.your.vhost.here.com QuitMsg = ZNC by prozac - http://znc.sourceforge.net - VersionReply = ZNC by prozac - http://znc.sourceforge.net + CTCPReply = VERSION ZNC by prozac - http://znc.sourceforge.net ChanModes = +stn KeepNick = true diff --git a/znc.cpp b/znc.cpp index 18a6ceb4..412d0566 100644 --- a/znc.cpp +++ b/znc.cpp @@ -676,8 +676,8 @@ bool CZNC::ParseConfig(const CString& sConfig) { } else if (sName.CaseCmp("Nick") == 0) { pUser->SetNick(sValue); continue; - } else if (sName.CaseCmp("VersionReply") == 0) { - pUser->SetVersionReply(sValue); + } else if (sName.CaseCmp("CTCPReply") == 0) { + pUser->AddCTCPReply(sValue.Token(0), sValue.Token(1, true)); continue; } else if (sName.CaseCmp("QuitMsg") == 0) { pUser->SetQuitMsg(sValue);