diff --git a/Modules.cpp b/Modules.cpp index 5de5a1e8..7a84251f 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -401,6 +401,7 @@ void CModule::OnIRCConnected() {} CModule::EModRet CModule::OnIRCConnecting(CIRCSock *IRCSock) { return CONTINUE; } 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::OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan) { return CONTINUE; } void CModule::OnWriteUserConfig(CFile& Config) {} void CModule::OnWriteChanConfig(CFile& Config, CChan& Chan) {} @@ -497,7 +498,6 @@ bool CModule::PutModNotice(const CString& sLine, const CString& sIdent, const CS /////////////////// // CGlobalModule // /////////////////// -CModule::EModRet CGlobalModule::OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan) { return CONTINUE; } CModule::EModRet CGlobalModule::OnWriteConfig(CFile& Config) { return CONTINUE; } CModule::EModRet CGlobalModule::OnAddUser(CUser& User, CString& sErrorRet) { return CONTINUE; } CModule::EModRet CGlobalModule::OnDeleteUser(CUser& User) { return CONTINUE; } @@ -546,6 +546,7 @@ bool CModules::OnIRCConnected() { MODUNLOADCHK(OnIRCConnected()); return false; bool CModules::OnIRCConnecting(CIRCSock *pIRCSock) { MODHALTCHK(OnIRCConnecting(pIRCSock)); } 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::OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan) { GLOBALMODHALTCHK(OnConfigLine(sName, sValue, pUser, pChan)); } bool CModules::OnWriteUserConfig(CFile& Config) { MODUNLOADCHK(OnWriteUserConfig(Config)); return false; } bool CModules::OnWriteChanConfig(CFile& Config, CChan& Chan) { MODUNLOADCHK(OnWriteChanConfig(Config, Chan)); return false; } bool CModules::OnIRCDisconnected() { MODUNLOADCHK(OnIRCDisconnected()); return false; } @@ -600,10 +601,6 @@ bool CModules::OnModCTCP(const CString& sMessage) { MODUNLOADCHK(OnModCTCP(sMess //////////////////// // CGlobalModules // //////////////////// -bool CGlobalModules::OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan) { - GLOBALMODHALTCHK(OnConfigLine(sName, sValue, pUser, pChan)); -} - bool CGlobalModules::OnWriteConfig(CFile& Config) { GLOBALMODHALTCHK(OnWriteConfig(Config)); } diff --git a/Modules.h b/Modules.h index 756aa510..4eea5031 100644 --- a/Modules.h +++ b/Modules.h @@ -345,6 +345,17 @@ public: */ virtual EModRet OnBroadcast(CString& sMessage); + /** Called when a module-specific config line is read from znc.conf. + * Module specific config lines are always prefixed with "GM:". + * @param sName Name of the config entry without the "GM:" prefix. + * @param sValue The value of the config entry. + * @param pUser If this line was found in a user section, then this is + * the corresponding CUser instance. + * @param pChan If this line was found in a chan section, then this is + * the corresponding CChan instance. + * @return See CModule::EModRet. + */ + virtual EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan); /** Called just before ZNC finishes a user section in the config file. * This can be used to re-write the "GM:" lines for OnConfigLine() * which would get lost otherwise. @@ -806,6 +817,7 @@ public: bool OnIRCConnecting(CIRCSock *pIRCSock); bool OnIRCRegistration(CString& sPass, CString& sNick, CString& sIdent, CString& sRealName); bool OnBroadcast(CString& sMessage); + bool OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan); bool OnWriteUserConfig(CFile& Config); bool OnWriteChanConfig(CFile& Config, CChan& Chan); @@ -905,17 +917,6 @@ public: const CString &sDataDir) : CModule(pDLL, sModName, sDataDir) {} virtual ~CGlobalModule() {} - /** Called when a module-specific config line is read from znc.conf. - * Module specific config lines are always prefixed with "GM:". - * @param sName Name of the config entry without the "GM:" prefix. - * @param sValue The value of the config entry. - * @param pUser If this line was found in a user section, then this is - * the corresponding CUser instance. - * @param pChan If this line was found in a chan section, then this is - * the corresponding CChan instance. - * @return See CModule::EModRet. - */ - virtual EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan); /** Called when ZNC starts rewriting the config file. This can be used * re-write the "GM:" lines for OnConfigLine() which would get lost * otherwise. @@ -972,7 +973,6 @@ public: CGlobalModules() : CModules() {} ~CGlobalModules() {} - bool OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan); bool OnWriteConfig(CFile& Config); bool OnAddUser(CUser& User, CString& sErrorRet); bool OnDeleteUser(CUser& User); diff --git a/znc.cpp b/znc.cpp index 384db20e..17a53411 100644 --- a/znc.cpp +++ b/znc.cpp @@ -1672,8 +1672,13 @@ bool CZNC::DoRehash(CString& sError) { if ((pChan && pChan == it->m_pChan) || (pUser && pUser == it->m_pUser)) continue; // skip unclosed user or chan - if (!GetModules().OnConfigLine(it->m_sName, it->m_sValue, it->m_pUser, it->m_pChan)) - { + bool bHandled = false; + if (it->m_pUser) { + MODULECALL(OnConfigLine(it->m_sName, it->m_sValue, it->m_pUser, it->m_pChan), it->m_pUser, NULL, bHandled = true); + } else { + bHandled = GetModules().OnConfigLine(it->m_sName, it->m_sValue, it->m_pUser, it->m_pChan)); + } + if (!bHandled) { CUtils::PrintMessage("unhandled global module config line [GM:" + it->m_sName + "] = [" + it->m_sValue + "]"); } }