mirror of
https://github.com/znc/znc.git
synced 2026-07-05 17:31:06 +02:00
autoop: Check for autoops when we are opped ourself #120
This commit is contained in:
+31
-16
@@ -160,22 +160,7 @@ public:
|
||||
virtual void OnJoin(const CNick& Nick, CChan& Channel) {
|
||||
// If we have ops in this chan
|
||||
if (Channel.HasPerm(CChan::Op)) {
|
||||
for (map<CString, CAutoOpUser*>::iterator it = m_msUsers.begin(); it != m_msUsers.end(); ++it) {
|
||||
// and the nick who joined is a valid user
|
||||
if (it->second->HostMatches(Nick.GetHostMask()) && it->second->ChannelMatches(Channel.GetName())) {
|
||||
if (it->second->GetUserKey().Equals("__NOKEY__")) {
|
||||
PutIRC("MODE " + Channel.GetName() + " +o " + Nick.GetNick());
|
||||
} else {
|
||||
// then insert this nick into the queue, the timer does the rest
|
||||
CString sNick = Nick.GetNick().AsLower();
|
||||
if (m_msQueue.find(sNick) == m_msQueue.end()) {
|
||||
m_msQueue[sNick] = "";
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
CheckAutoOp(Nick, Channel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,6 +198,18 @@ public:
|
||||
return HALTCORE;
|
||||
}
|
||||
|
||||
virtual void OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange) {
|
||||
if (Nick.GetNick() == m_pNetwork->GetIRCNick().GetNick()) {
|
||||
const map<CString,CNick>& msNicks = Channel.GetNicks();
|
||||
|
||||
for (map<CString,CNick>::const_iterator it = msNicks.begin(); it != msNicks.end(); ++it) {
|
||||
if (!it->second.HasPerm(CChan::Op)) {
|
||||
CheckAutoOp(it->second, Channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnModCommand(const CString& sLine) {
|
||||
CString sCommand = sLine.Token(0).AsUpper();
|
||||
|
||||
@@ -309,6 +306,24 @@ public:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CheckAutoOp(const CNick& Nick, CChan& Channel) {
|
||||
CAutoOpUser *pUser = FindUserByHost(Nick.GetHostMask(), Channel.GetName());
|
||||
|
||||
if (pUser) {
|
||||
if (pUser->GetUserKey().Equals("__NOKEY__")) {
|
||||
PutIRC("MODE " + Channel.GetName() + " +o " + Nick.GetNick());
|
||||
} else {
|
||||
// then insert this nick into the queue, the timer does the rest
|
||||
CString sNick = Nick.GetNick().AsLower();
|
||||
if (m_msQueue.find(sNick) == m_msQueue.end()) {
|
||||
m_msQueue[sNick] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pUser;
|
||||
}
|
||||
|
||||
void DelUser(const CString& sUser) {
|
||||
map<CString, CAutoOpUser*>::iterator it = m_msUsers.find(sUser.AsLower());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user