mirror of
https://github.com/znc/znc.git
synced 2026-07-05 09:21:31 +02:00
Added OnDeleteUser() global module hook
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@702 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -515,6 +515,7 @@ 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::OnDeleteUser(CUser& User) { return CONTINUE; }
|
||||
CModule::EModRet CGlobalModule::OnLoginAttempt(CSmartPtr<CAuthBase> Auth) { return CONTINUE; }
|
||||
|
||||
|
||||
@@ -596,6 +597,10 @@ bool CGlobalModules::OnConfigLine(const CString& sName, const CString& sValue, C
|
||||
GLOBALMODHALTCHK(OnConfigLine(sName, sValue, pUser, pChan));
|
||||
}
|
||||
|
||||
bool CGlobalModules::OnDeleteUser(CUser& User) {
|
||||
GLOBALMODHALTCHK(OnDeleteUser(User));
|
||||
}
|
||||
|
||||
bool CGlobalModules::OnLoginAttempt(CSmartPtr<CAuthBase> Auth) {
|
||||
GLOBALMODHALTCHK(OnLoginAttempt(Auth));
|
||||
}
|
||||
|
||||
@@ -390,6 +390,7 @@ public:
|
||||
virtual ~CGlobalModule() {}
|
||||
|
||||
virtual EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan);
|
||||
virtual EModRet OnDeleteUser(CUser& User);
|
||||
virtual EModRet OnLoginAttempt(CSmartPtr<CAuthBase> Auth);
|
||||
private:
|
||||
};
|
||||
@@ -400,6 +401,7 @@ public:
|
||||
virtual ~CGlobalModules() {}
|
||||
|
||||
virtual bool OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan);
|
||||
virtual bool OnDeleteUser(CUser& User);
|
||||
virtual bool OnLoginAttempt(CSmartPtr<CAuthBase> Auth);
|
||||
private:
|
||||
};
|
||||
|
||||
+23
-1
@@ -32,6 +32,28 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual EModRet OnDeleteUser(CUser& User) {
|
||||
const CString& sNick = User.GetUserName();
|
||||
CString sHost = User.GetVHost();
|
||||
|
||||
CUser* pTmp = m_pUser;
|
||||
m_pUser = &User;
|
||||
|
||||
for (map<CString, set<CString> >::iterator it = m_msChans.begin(); it != m_msChans.end(); it++) { // Loop through each chan
|
||||
const CString& sChannel = it->first;
|
||||
set<CString>& ssNicks = it->second;
|
||||
|
||||
if (ssNicks.find(User.GetUserName()) != ssNicks.end()) { // If the user is on this chan
|
||||
User.PutUser(":*" + GetModName() + "!znc@rottenboy.com KICK " + sChannel + " " + sNick + " :User Deleted");
|
||||
PutChan(ssNicks, ":*" + GetModName() + "!znc@rottenboy.com KICK " + sChannel + " ?" + sNick + " :User Deleted", false);
|
||||
}
|
||||
}
|
||||
|
||||
m_pUser = pTmp;
|
||||
|
||||
return CONTINUE;
|
||||
}
|
||||
|
||||
virtual EModRet OnRaw(CString& sLine) {
|
||||
if (sLine.Token(1) == "005") {
|
||||
CString::size_type uPos = sLine.AsUpper().find("CHANTYPES=");
|
||||
@@ -98,7 +120,7 @@ public:
|
||||
return HALT;
|
||||
}
|
||||
|
||||
set<CString>& ssNicks = m_msChans[sChannel.AsLower()];
|
||||
set<CString>& ssNicks = m_msChans[sChannel.AsLower()]; // @todo do a lookup first
|
||||
const CString& sNick = m_pUser->GetUserName();
|
||||
|
||||
if (ssNicks.find(sNick) != ssNicks.end()) {
|
||||
|
||||
@@ -76,6 +76,12 @@ int CZNC::Loop() {
|
||||
if (m_ssDelUsers.size()) {
|
||||
for (set<CUser*>::iterator it = m_ssDelUsers.begin(); it != m_ssDelUsers.end(); it++) {
|
||||
CUser* pUser = *it;
|
||||
|
||||
#ifdef _MODULES
|
||||
if (GetModules().OnDeleteUser(*pUser)) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
m_msUsers.erase(pUser->GetUserName());
|
||||
|
||||
CIRCSock* pIRCSock = pUser->GetIRCSock();
|
||||
|
||||
Reference in New Issue
Block a user