From c71565103c61c6bdaf35309995f7bb531f67729d Mon Sep 17 00:00:00 2001 From: silverleo Date: Mon, 24 Nov 2008 17:56:34 +0000 Subject: [PATCH] Added OnIRCRegistration(). Patch from Freman. Thanks :) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1271 726aef4b-f618-498e-8847-2d620e286838 --- IRCSock.cpp | 15 +++++++++++---- Modules.cpp | 2 ++ Modules.h | 2 ++ modules/modperl.cpp | 4 ++++ modules/sample.cpp | 5 +++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/IRCSock.cpp b/IRCSock.cpp index c6823ac8..6d64c942 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -805,12 +805,19 @@ void CIRCSock::Connected() { DEBUG_ONLY(cout << GetSockName() << " == Connected()" << endl); m_pUser->IRCConnected(this); - if (!m_sPass.empty()) { - PutIRC("PASS " + m_sPass); + CString sPass = m_sPass; + CString sNick = m_pUser->GetNick(); + CString sIdent = m_pUser->GetIdent(); + CString sRealName = m_pUser->GetRealName(); + + MODULECALL(OnIRCRegistration(sPass, sNick, sIdent, sRealName), m_pUser, NULL, return); + + if (!sPass.empty()) { + PutIRC("PASS " + sPass); } - PutIRC("NICK " + m_pUser->GetNick()); - PutIRC("USER " + m_pUser->GetIdent() + " \"" + m_pUser->GetIdent() + "\" \"" + m_pUser->GetIdent() + "\" :" + m_pUser->GetRealName()); + PutIRC("NICK " + sNick); + PutIRC("USER " + sIdent + " \"" + sIdent + "\" \"" + sIdent + "\" :" + sRealName); } void CIRCSock::Disconnected() { diff --git a/Modules.cpp b/Modules.cpp index 954d91a9..9840933f 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -448,6 +448,7 @@ void CModule::OnPreRehash() {} void CModule::OnPostRehash() {} void CModule::OnIRCDisconnected() {} void CModule::OnIRCConnected() {} +CModule::EModRet CModule::OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName) { return CONTINUE; } CModule::EModRet CModule::OnBroadcast(CString& sMessage) { return CONTINUE; } CModule::EModRet CModule::OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize) { return CONTINUE; } @@ -580,6 +581,7 @@ bool CModules::OnBoot() { bool CModules::OnPreRehash() { MODUNLOADCHK(OnPreRehash()); return false; } bool CModules::OnPostRehash() { MODUNLOADCHK(OnPostRehash()); return false; } bool CModules::OnIRCConnected() { MODUNLOADCHK(OnIRCConnected()); return false; } +bool CModules::OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName) { MODHALTCHK(OnIRCRegistration(sPass, sNick, sIdent, sRealName)); } bool CModules::OnBroadcast(CString& sMessage) { MODHALTCHK(OnBroadcast(sMessage)); } bool CModules::OnIRCDisconnected() { MODUNLOADCHK(OnIRCDisconnected()); return false; } bool CModules::OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize) { MODHALTCHK(OnDCCUserSend(RemoteNick, uLongIP, uPort, sFile, uFileSize)); } diff --git a/Modules.h b/Modules.h index ea5338a7..8259f378 100644 --- a/Modules.h +++ b/Modules.h @@ -229,6 +229,7 @@ public: virtual void OnPostRehash(); virtual void OnIRCDisconnected(); virtual void OnIRCConnected(); + virtual EModRet OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName); virtual EModRet OnBroadcast(CString& sMessage); virtual EModRet OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize); @@ -372,6 +373,7 @@ public: virtual bool OnPostRehash(); virtual bool OnIRCDisconnected(); virtual bool OnIRCConnected(); + virtual bool OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName); virtual bool OnBroadcast(CString& sMessage); virtual bool OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize); diff --git a/modules/modperl.cpp b/modules/modperl.cpp index 0db72d37..c14f0d63 100644 --- a/modules/modperl.cpp +++ b/modules/modperl.cpp @@ -333,6 +333,10 @@ public: virtual EModRet OnUserRaw(CString& sLine) { return(CBSingle("OnUserRaw", sLine)); } virtual EModRet OnRaw(CString& sLine) { return(CBSingle("OnRaw", sLine)); } + virtual EModRet OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName) { + return(CBFour("OnIRCRegistration", sPass, sNick, sIdent, sRealName)); + } + virtual void OnModCommand(const CString& sCommand) { if (CBSingle("OnModCommand", sCommand) == 0) diff --git a/modules/sample.cpp b/modules/sample.cpp index e0a7f025..ff54e5ac 100644 --- a/modules/sample.cpp +++ b/modules/sample.cpp @@ -52,6 +52,11 @@ public: PutModule("You got disconnected BoyOh."); } + virtual EModRet OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName) { + sRealName += " - ZNC"; + return CONTINUE; + } + virtual EModRet OnBroadcast(CString& sMessage) { PutModule("------ [" + sMessage + "]"); sMessage = "======== [" + sMessage + "] ========";