mirror of
https://github.com/znc/znc.git
synced 2026-08-07 09:22:55 +02:00
Make OnConfigLine() a user module hook
It's only called for stuff defined in that user's section. The stuff outside of a user section still can only be caught by global modules. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1849 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+2
-5
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 + "]");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user