From b8c2da95f1581db52a04c5e47c9bc9c86805655b Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Fri, 21 Oct 2011 00:18:01 +0000 Subject: [PATCH] Make the OnInvite hook return EModRet so we can ignore invites --- include/znc/Modules.h | 3 ++- modules/sample.cpp | 10 ++++++++++ src/IRCSock.cpp | 2 +- src/Modules.cpp | 4 ++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/znc/Modules.h b/include/znc/Modules.h index cbae0f60..fab06c09 100644 --- a/include/znc/Modules.h +++ b/include/znc/Modules.h @@ -555,8 +555,9 @@ public: /** Called when user is invited into a channel * @param Nick The nick who invited you. * @param sChan The channel the user got invited into + * @return See CModule::EModRet. */ - virtual void OnInvite(const CNick& Nick, const CString& sChan); + virtual EModRet OnInvite(const CNick& Nick, const CString& sChan); /** Called before a channel buffer is played back to a client. * @param Chan The channel which will be played back. diff --git a/modules/sample.cpp b/modules/sample.cpp index 48fa515b..a10db095 100644 --- a/modules/sample.cpp +++ b/modules/sample.cpp @@ -119,6 +119,16 @@ public: PutModule("* Parts: " + Nick.GetNick() + " (" + Nick.GetIdent() + "!" + Nick.GetHost() + ")"); } + virtual EModRet OnInvite(const CNick& Nick, const CString& sChan) { + if (sChan.Equals("#test")) { + PutModule(Nick.GetNick() + " invited us to " + sChan + ", ignoring invites to " + sChan); + return HALT; + } + + PutModule(Nick.GetNick() + " invited us to " + sChan); + return CONTINUE; + } + virtual void OnNick(const CNick& OldNick, const CString& sNewNick, const vector& vChans) { PutModule("* " + OldNick.GetNick() + " is now known as " + sNewNick); } diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index a856345e..8850c419 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -712,7 +712,7 @@ void CIRCSock::ReadLine(const CString& sData) { // Don't forward any CAP stuff to the client return; } else if (sCmd.Equals("INVITE")) { - NETWORKMODULECALL(OnInvite(Nick, sLine.Token(3).TrimPrefix_n(":")), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); + NETWORKMODULECALL(OnInvite(Nick, sLine.Token(3).TrimPrefix_n(":")), m_pNetwork->GetUser(), m_pNetwork, NULL, return); } } diff --git a/src/Modules.cpp b/src/Modules.cpp index e71f7da5..3fed2b12 100644 --- a/src/Modules.cpp +++ b/src/Modules.cpp @@ -513,7 +513,7 @@ void CModule::OnNick(const CNick& Nick, const CString& sNewNick, const vector