From 2583b7e9ffb333a4b24b2bc6097f54858a1762b5 Mon Sep 17 00:00:00 2001 From: psychon Date: Tue, 3 Jun 2008 07:15:52 +0000 Subject: [PATCH] Handle channel CTCP the same way we do for private CTCPs This patch doesn't actually change anything for private CTCPs, it's only the indentation level that changes! (Well, and that this code gets its own function...) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1082 726aef4b-f618-498e-8847-2d620e286838 --- IRCSock.cpp | 53 +++++++++++++++++++++++++++++++---------------------- IRCSock.h | 1 + 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/IRCSock.cpp b/IRCSock.cpp index 9dd2106e..24d7655b 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -786,35 +786,41 @@ bool CIRCSock::OnPrivCTCP(CNick& Nick, CString& sMessage) { return true; } else { - const MCString& mssCTCPReplies = m_pUser->GetCTCPReplies(); - MCString::const_iterator it = mssCTCPReplies.find(sMessage.AsUpper()); - CString sQuery = sMessage.Token(0).AsUpper(); - bool bHaveReply = false; - CString sReply; + return OnGeneralCTCP(Nick, sMessage); + } - if (it == mssCTCPReplies.end()) { - it = mssCTCPReplies.find(sQuery); - } + return false; +} - if (it != mssCTCPReplies.end()) { - sReply = it->second; - bHaveReply = true; - } +bool CIRCSock::OnGeneralCTCP(CNick& Nick, CString& sMessage) { + const MCString& mssCTCPReplies = m_pUser->GetCTCPReplies(); + MCString::const_iterator it = mssCTCPReplies.find(sMessage.AsUpper()); + CString sQuery = sMessage.Token(0).AsUpper(); + bool bHaveReply = false; + CString sReply; - if (!bHaveReply && !m_pUser->IsUserAttached()) { - if (sQuery == "VERSION") { - sReply = CZNC::GetTag(); - } else if (sQuery == "PING") { - sReply = sMessage.Token(1, true); - } - } + if (it == mssCTCPReplies.end()) { + it = mssCTCPReplies.find(sQuery); + } - if (!sReply.empty()) { - PutIRC("NOTICE " + Nick.GetNick() + " :\001" + sQuery + " " + sReply + "\001"); - return true; + if (it != mssCTCPReplies.end()) { + sReply = it->second; + bHaveReply = true; + } + + if (!bHaveReply && !m_pUser->IsUserAttached()) { + if (sQuery == "VERSION") { + sReply = CZNC::GetTag(); + } else if (sQuery == "PING") { + sReply = sMessage.Token(1, true); } } + if (!sReply.empty()) { + PutIRC("NOTICE " + Nick.GetNick() + " :\001" + sQuery + " " + sReply + "\001"); + return true; + } + return false; } @@ -855,6 +861,9 @@ bool CIRCSock::OnChanCTCP(CNick& Nick, const CString& sChan, CString& sMessage) MODULECALL(OnChanCTCP(Nick, *pChan, sMessage), m_pUser, NULL, return true); } + if (OnGeneralCTCP(Nick, sMessage)) + return true; + return (pChan && pChan->IsDetached()); } diff --git a/IRCSock.h b/IRCSock.h index b9de2e40..9df048d3 100644 --- a/IRCSock.h +++ b/IRCSock.h @@ -33,6 +33,7 @@ public: bool OnCTCPReply(CNick& Nick, CString& sMessage); bool OnPrivCTCP(CNick& Nick, CString& sMessage); bool OnChanCTCP(CNick& Nick, const CString& sChan, CString& sMessage); + bool OnGeneralCTCP(CNick& Nick, CString& sMessage); bool OnPrivMsg(CNick& Nick, CString& sMessage); bool OnChanMsg(CNick& Nick, const CString& sChan, CString& sMessage); bool OnPrivNotice(CNick& Nick, CString& sMessage);