mirror of
https://github.com/znc/znc.git
synced 2026-05-18 07:15:54 +02:00
Added a new module hook
EModRet OnAddUser(CUser& User, CString& sErrorRet) for global modules. Idea by BrianC. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1820 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -498,6 +498,7 @@ CModule::EModRet CGlobalModule::OnConfigLine(const CString& sName, const CString
|
||||
CModule::EModRet CGlobalModule::OnWriteConfig(CFile& Config) { return CONTINUE; }
|
||||
void CGlobalModule::OnWriteUserConfig(CFile& Config, CUser& User) {}
|
||||
void CGlobalModule::OnWriteChanConfig(CFile& Config, CChan& Chan) {}
|
||||
CModule::EModRet CGlobalModule::OnAddUser(CUser& User, CString& sErrorRet) { return CONTINUE; }
|
||||
CModule::EModRet CGlobalModule::OnDeleteUser(CUser& User) { return CONTINUE; }
|
||||
void CGlobalModule::OnClientConnect(CClient* pClient, const CString& sHost, unsigned short uPort) {}
|
||||
CModule::EModRet CGlobalModule::OnLoginAttempt(CSmartPtr<CAuthBase> Auth) { return CONTINUE; }
|
||||
@@ -612,6 +613,10 @@ void CGlobalModules::OnWriteChanConfig(CFile& Config, CChan& Chan) {
|
||||
GLOBALMODCALL(OnWriteChanConfig(Config, Chan));
|
||||
}
|
||||
|
||||
bool CGlobalModules::OnAddUser(CUser& User, CString& sErrorRet) {
|
||||
GLOBALMODHALTCHK(OnAddUser(User, sErrorRet));
|
||||
}
|
||||
|
||||
bool CGlobalModules::OnDeleteUser(CUser& User) {
|
||||
GLOBALMODHALTCHK(OnDeleteUser(User));
|
||||
}
|
||||
|
||||
@@ -888,6 +888,13 @@ public:
|
||||
* @param Chan The channel which is being written.
|
||||
*/
|
||||
virtual void OnWriteChanConfig(CFile& Config, CChan& Chan);
|
||||
/** This module hook is called when a user is being added.
|
||||
* @param User The user which will be added.
|
||||
* @param sErrorRet A message that may be displayed to the user if
|
||||
* the module stops adding the user.
|
||||
* @return See CModule::EModRet.
|
||||
*/
|
||||
virtual EModRet OnAddUser(CUser& User, CString& sErrorRet);
|
||||
/** This module hook is called when a user is deleted.
|
||||
* @param User The user which will be deleted.
|
||||
* @return See CModule::EModRet.
|
||||
@@ -933,6 +940,7 @@ public:
|
||||
bool OnWriteConfig(CFile& Config);
|
||||
void OnWriteUserConfig(CFile& Config, CUser& User);
|
||||
void OnWriteChanConfig(CFile& Config, CChan& Chan);
|
||||
bool OnAddUser(CUser& User, CString& sErrorRet);
|
||||
bool OnDeleteUser(CUser& User);
|
||||
void OnClientConnect(CClient* pClient, const CString& sHost, unsigned short uPort);
|
||||
bool OnLoginAttempt(CSmartPtr<CAuthBase> Auth);
|
||||
|
||||
@@ -1803,6 +1803,11 @@ bool CZNC::AddUser(CUser* pUser, CString& sErrorRet) {
|
||||
<< sErrorRet << "]");
|
||||
return false;
|
||||
}
|
||||
if (!GetModules().OnAddUser(*pUser, sErrorRet)) {
|
||||
DEBUG("AddUser [" << pUser->GetUserName() << "] aborted by a module ["
|
||||
<< sErrorRet << "]");
|
||||
return false;
|
||||
}
|
||||
m_msUsers[pUser->GetUserName()] = pUser;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user