Versions: the most recent 1.7 Docker release (and 1.7.x and master from unstable)
Not sure how realistic this is in the real world. May be totally pedantic/contrived, but anyway...
#include <znc/Chan.h> #include <znc/IRCNetwork.h> /* * 1. LoadMod dang * 2. JOIN #chan * 3. PART #chan (may have to repeat this and 2) */ class CDangMod : public CModule { private: CString m_sName; public: MODCONSTRUCTOR(CDangMod) {} bool OnLoad(const CString& sArgs, CString& sMessage) override { m_sName = sArgs.empty() ? "#chan" : sArgs; return true; } EModRet OnSendToClientMessage(CMessage& Message) override { DEBUG("(dang) Network chan: " << GetNetwork()->FindChan(m_sName)); CChan* pMsgChan = Message.GetChan(); if (!pMsgChan) return CONTINUE; DEBUG("(dang) Message chan: " << pMsgChan); try { m_sName = pMsgChan->GetName(); DEBUG("(dang) MsgChan name: " << m_sName); } catch (const std::bad_alloc& exc) { DEBUG("(dang) Error raised: " << exc.what()); } return CONTINUE; } }; MODULEDEFS(CDangMod, "dang")
This seems to make the example above behave:
src/IRCSock.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 259881dc..c00219bd 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -1002,6 +1002,7 @@ bool CIRCSock::OnPartMessage(CPartMessage& Message) { if (Nick.NickEquals(GetNick())) { m_pNetwork->DelChan(sChan); + Message.SetChan(nullptr); } /*
No dependencies set.
The note is not visible to the blocked user.
Versions: the most recent 1.7 Docker release (and 1.7.x and master from unstable)
Not sure how realistic this is in the real world. May be totally pedantic/contrived, but anyway...
This seems to make the example above behave: