From b450fde4f64a7be149e7a24939e739158d060966 Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Thu, 9 Feb 2012 18:57:51 +0000 Subject: [PATCH] autoop: Check for autoops when we are opped ourself #120 --- modules/autoop.cpp | 47 ++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/modules/autoop.cpp b/modules/autoop.cpp index e989f488..692be30f 100644 --- a/modules/autoop.cpp +++ b/modules/autoop.cpp @@ -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::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& msNicks = Channel.GetNicks(); + + for (map::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::iterator it = m_msUsers.find(sUser.AsLower());