mirror of
https://github.com/znc/znc.git
synced 2026-05-07 22:04:46 +02:00
Pass CMessage to buffer playback hooks
This commit is contained in:
@@ -658,6 +658,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual EModRet OnChanBufferPlayLine2(CChan& Chan, CClient& Client, CString& sLine, const timeval& tv);
|
virtual EModRet OnChanBufferPlayLine2(CChan& Chan, CClient& Client, CString& sLine, const timeval& tv);
|
||||||
virtual EModRet OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine);
|
virtual EModRet OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine);
|
||||||
|
virtual EModRet OnChanBufferPlayMessage(CMessage& Message);
|
||||||
/** Called when a line from the query buffer is played back.
|
/** Called when a line from the query buffer is played back.
|
||||||
* @param Client The client this line will go to.
|
* @param Client The client this line will go to.
|
||||||
* @param sLine The raw IRC traffic line from the buffer.
|
* @param sLine The raw IRC traffic line from the buffer.
|
||||||
@@ -666,6 +667,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual EModRet OnPrivBufferPlayLine2(CClient& Client, CString& sLine, const timeval& tv);
|
virtual EModRet OnPrivBufferPlayLine2(CClient& Client, CString& sLine, const timeval& tv);
|
||||||
virtual EModRet OnPrivBufferPlayLine(CClient& Client, CString& sLine);
|
virtual EModRet OnPrivBufferPlayLine(CClient& Client, CString& sLine);
|
||||||
|
virtual EModRet OnPrivBufferPlayMessage(CMessage& Message);
|
||||||
|
|
||||||
/** Called when a client successfully logged in to ZNC. */
|
/** Called when a client successfully logged in to ZNC. */
|
||||||
virtual void OnClientLogin();
|
virtual void OnClientLogin();
|
||||||
@@ -1219,6 +1221,8 @@ public:
|
|||||||
bool OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine);
|
bool OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine);
|
||||||
bool OnPrivBufferPlayLine2(CClient& Client, CString& sLine, const timeval& tv);
|
bool OnPrivBufferPlayLine2(CClient& Client, CString& sLine, const timeval& tv);
|
||||||
bool OnPrivBufferPlayLine(CClient& Client, CString& sLine);
|
bool OnPrivBufferPlayLine(CClient& Client, CString& sLine);
|
||||||
|
bool OnChanBufferPlayMessage(CMessage& Message);
|
||||||
|
bool OnPrivBufferPlayMessage(CMessage& Message);
|
||||||
|
|
||||||
bool OnClientLogin();
|
bool OnClientLogin();
|
||||||
bool OnClientDisconnect();
|
bool OnClientDisconnect();
|
||||||
|
|||||||
+10
-6
@@ -20,6 +20,7 @@
|
|||||||
#include <znc/IRCNetwork.h>
|
#include <znc/IRCNetwork.h>
|
||||||
#include <znc/Config.h>
|
#include <znc/Config.h>
|
||||||
#include <znc/znc.h>
|
#include <znc/znc.h>
|
||||||
|
#include <znc/Message.h>
|
||||||
|
|
||||||
using std::set;
|
using std::set;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@@ -610,16 +611,19 @@ void CChan::SendBuffer(CClient* pClient, const CBuffer& Buffer) {
|
|||||||
size_t uSize = Buffer.Size();
|
size_t uSize = Buffer.Size();
|
||||||
for (size_t uIdx = 0; uIdx < uSize; uIdx++) {
|
for (size_t uIdx = 0; uIdx < uSize; uIdx++) {
|
||||||
const CBufLine& BufLine = Buffer.GetBufLine(uIdx);
|
const CBufLine& BufLine = Buffer.GetBufLine(uIdx);
|
||||||
CString sLine = BufLine.GetLine(*pUseClient, MCString::EmptyMap);
|
CMessage Message(BufLine.GetLine(*pUseClient, MCString::EmptyMap));
|
||||||
|
Message.SetChan(this);
|
||||||
|
Message.SetNetwork(m_pNetwork);
|
||||||
|
Message.SetClient(pClient);
|
||||||
|
Message.SetTime(BufLine.GetTime());
|
||||||
|
Message.SetTags(BufLine.GetTags());
|
||||||
if (bBatch) {
|
if (bBatch) {
|
||||||
MCString msBatchTags = CUtils::GetMessageTags(sLine);
|
Message.SetTag("batch", sBatchName);
|
||||||
msBatchTags["batch"] = sBatchName;
|
|
||||||
CUtils::SetMessageTags(sLine, msBatchTags);
|
|
||||||
}
|
}
|
||||||
bool bNotShowThisLine = false;
|
bool bNotShowThisLine = false;
|
||||||
NETWORKMODULECALL(OnChanBufferPlayLine2(*this, *pUseClient, sLine, BufLine.GetTime()), m_pNetwork->GetUser(), m_pNetwork, nullptr, &bNotShowThisLine);
|
NETWORKMODULECALL(OnChanBufferPlayMessage(Message), m_pNetwork->GetUser(), m_pNetwork, nullptr, &bNotShowThisLine);
|
||||||
if (bNotShowThisLine) continue;
|
if (bNotShowThisLine) continue;
|
||||||
m_pNetwork->PutUser(sLine, pUseClient);
|
m_pNetwork->PutUser(Message, pUseClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
bSkipStatusMsg = pUseClient->HasServerTime();
|
bSkipStatusMsg = pUseClient->HasServerTime();
|
||||||
|
|||||||
+8
-3
@@ -22,6 +22,7 @@
|
|||||||
#include <znc/Server.h>
|
#include <znc/Server.h>
|
||||||
#include <znc/Chan.h>
|
#include <znc/Chan.h>
|
||||||
#include <znc/Query.h>
|
#include <znc/Query.h>
|
||||||
|
#include <znc/Message.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -642,11 +643,15 @@ void CIRCNetwork::ClientConnected(CClient *pClient) {
|
|||||||
uSize = m_NoticeBuffer.Size();
|
uSize = m_NoticeBuffer.Size();
|
||||||
for (uIdx = 0; uIdx < uSize; uIdx++) {
|
for (uIdx = 0; uIdx < uSize; uIdx++) {
|
||||||
const CBufLine& BufLine = m_NoticeBuffer.GetBufLine(uIdx);
|
const CBufLine& BufLine = m_NoticeBuffer.GetBufLine(uIdx);
|
||||||
CString sLine = BufLine.GetLine(*pClient, msParams);
|
CMessage Message(BufLine.GetLine(*pClient, msParams));
|
||||||
|
Message.SetNetwork(this);
|
||||||
|
Message.SetClient(pClient);
|
||||||
|
Message.SetTime(BufLine.GetTime());
|
||||||
|
Message.SetTags(BufLine.GetTags());
|
||||||
bool bContinue = false;
|
bool bContinue = false;
|
||||||
NETWORKMODULECALL(OnPrivBufferPlayLine2(*pClient, sLine, BufLine.GetTime()), m_pUser, this, nullptr, &bContinue);
|
NETWORKMODULECALL(OnPrivBufferPlayMessage(Message), m_pUser, this, nullptr, &bContinue);
|
||||||
if (bContinue) continue;
|
if (bContinue) continue;
|
||||||
pClient->PutClient(sLine);
|
pClient->PutClient(Message);
|
||||||
}
|
}
|
||||||
m_NoticeBuffer.Clear();
|
m_NoticeBuffer.Clear();
|
||||||
|
|
||||||
|
|||||||
@@ -660,6 +660,25 @@ CModule::EModRet CModule::OnPrivBufferPlayLine2(CClient& Client, CString& sLine,
|
|||||||
return OnPrivBufferPlayLine(Client, sLine);
|
return OnPrivBufferPlayLine(Client, sLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CModule::EModRet CModule::OnChanBufferPlayMessage(CMessage& Message) {
|
||||||
|
CString sOriginal, sModified;
|
||||||
|
sOriginal = sModified = Message.ToString(CMessage::ExcludeTags);
|
||||||
|
EModRet ret = OnChanBufferPlayLine2(*Message.GetChan(), *Message.GetClient(), sModified, Message.GetTime());
|
||||||
|
if (ret == CONTINUE && sOriginal != sModified) {
|
||||||
|
Message.Parse(sModified);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
CModule::EModRet CModule::OnPrivBufferPlayMessage(CMessage& Message) {
|
||||||
|
CString sOriginal, sModified;
|
||||||
|
sOriginal = sModified = Message.ToString(CMessage::ExcludeTags);
|
||||||
|
EModRet ret = OnPrivBufferPlayLine2(*Message.GetClient(), sModified, Message.GetTime());
|
||||||
|
if (ret == CONTINUE && sOriginal != sModified) {
|
||||||
|
Message.Parse(sModified);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void CModule::OnClientLogin() {}
|
void CModule::OnClientLogin() {}
|
||||||
void CModule::OnClientDisconnect() {}
|
void CModule::OnClientDisconnect() {}
|
||||||
CModule::EModRet CModule::OnUserRaw(CString& sLine) { return CONTINUE; }
|
CModule::EModRet CModule::OnUserRaw(CString& sLine) { return CONTINUE; }
|
||||||
@@ -905,6 +924,8 @@ bool CModules::OnChanBufferPlayLine2(CChan& Chan, CClient& Client, CString& sLin
|
|||||||
bool CModules::OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine) { MODHALTCHK(OnChanBufferPlayLine(Chan, Client, sLine)); }
|
bool CModules::OnChanBufferPlayLine(CChan& Chan, CClient& Client, CString& sLine) { MODHALTCHK(OnChanBufferPlayLine(Chan, Client, sLine)); }
|
||||||
bool CModules::OnPrivBufferPlayLine2(CClient& Client, CString& sLine, const timeval& tv) { MODHALTCHK(OnPrivBufferPlayLine2(Client, sLine, tv)); }
|
bool CModules::OnPrivBufferPlayLine2(CClient& Client, CString& sLine, const timeval& tv) { MODHALTCHK(OnPrivBufferPlayLine2(Client, sLine, tv)); }
|
||||||
bool CModules::OnPrivBufferPlayLine(CClient& Client, CString& sLine) { MODHALTCHK(OnPrivBufferPlayLine(Client, sLine)); }
|
bool CModules::OnPrivBufferPlayLine(CClient& Client, CString& sLine) { MODHALTCHK(OnPrivBufferPlayLine(Client, sLine)); }
|
||||||
|
bool CModules::OnChanBufferPlayMessage(CMessage& Message) { MODHALTCHK(OnChanBufferPlayMessage(Message)); }
|
||||||
|
bool CModules::OnPrivBufferPlayMessage(CMessage& Message) { MODHALTCHK(OnPrivBufferPlayMessage(Message)); }
|
||||||
bool CModules::OnCTCPReply(CNick& Nick, CString& sMessage) { MODHALTCHK(OnCTCPReply(Nick, sMessage)); }
|
bool CModules::OnCTCPReply(CNick& Nick, CString& sMessage) { MODHALTCHK(OnCTCPReply(Nick, sMessage)); }
|
||||||
bool CModules::OnPrivCTCP(CNick& Nick, CString& sMessage) { MODHALTCHK(OnPrivCTCP(Nick, sMessage)); }
|
bool CModules::OnPrivCTCP(CNick& Nick, CString& sMessage) { MODHALTCHK(OnPrivCTCP(Nick, sMessage)); }
|
||||||
bool CModules::OnPrivCTCPMessage(CPrivCTCP& Message) { MODHALTCHK(OnPrivCTCPMessage(Message)); }
|
bool CModules::OnPrivCTCPMessage(CPrivCTCP& Message) { MODHALTCHK(OnPrivCTCPMessage(Message)); }
|
||||||
|
|||||||
+10
-10
@@ -17,6 +17,7 @@
|
|||||||
#include <znc/Query.h>
|
#include <znc/Query.h>
|
||||||
#include <znc/User.h>
|
#include <znc/User.h>
|
||||||
#include <znc/IRCNetwork.h>
|
#include <znc/IRCNetwork.h>
|
||||||
|
#include <znc/Message.h>
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
@@ -55,24 +56,23 @@ void CQuery::SendBuffer(CClient* pClient, const CBuffer& Buffer) {
|
|||||||
size_t uSize = Buffer.Size();
|
size_t uSize = Buffer.Size();
|
||||||
for (size_t uIdx = 0; uIdx < uSize; uIdx++) {
|
for (size_t uIdx = 0; uIdx < uSize; uIdx++) {
|
||||||
const CBufLine& BufLine = Buffer.GetBufLine(uIdx);
|
const CBufLine& BufLine = Buffer.GetBufLine(uIdx);
|
||||||
|
CMessage Message(BufLine.GetLine(*pUseClient, MCString::EmptyMap));
|
||||||
if (!pUseClient->HasEchoMessage() && !pUseClient->HasSelfMessage()) {
|
if (!pUseClient->HasEchoMessage() && !pUseClient->HasSelfMessage()) {
|
||||||
CNick Sender(BufLine.GetFormat().Token(0));
|
if (Message.GetNick().NickEquals(pUseClient->GetNick())) {
|
||||||
if (Sender.NickEquals(pUseClient->GetNick())) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message.SetNetwork(m_pNetwork);
|
||||||
CString sLine = BufLine.GetLine(*pUseClient, msParams);
|
Message.SetClient(pUseClient);
|
||||||
|
Message.SetTime(BufLine.GetTime());
|
||||||
|
Message.SetTags(BufLine.GetTags());
|
||||||
if (bBatch) {
|
if (bBatch) {
|
||||||
MCString msBatchTags = CUtils::GetMessageTags(sLine);
|
Message.SetTag("batch", sBatchName);
|
||||||
msBatchTags["batch"] = sBatchName;
|
|
||||||
CUtils::SetMessageTags(sLine, msBatchTags);
|
|
||||||
}
|
}
|
||||||
bool bContinue = false;
|
bool bContinue = false;
|
||||||
NETWORKMODULECALL(OnPrivBufferPlayLine2(*pUseClient, sLine, BufLine.GetTime()), m_pNetwork->GetUser(), m_pNetwork, nullptr, &bContinue);
|
NETWORKMODULECALL(OnPrivBufferPlayMessage(Message), m_pNetwork->GetUser(), m_pNetwork, nullptr, &bContinue);
|
||||||
if (bContinue) continue;
|
if (bContinue) continue;
|
||||||
m_pNetwork->PutUser(sLine, pUseClient);
|
m_pNetwork->PutUser(Message, pUseClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bBatch) {
|
if (bBatch) {
|
||||||
|
|||||||
Reference in New Issue
Block a user