From a5263a8adad14fa05bdc6f55d7d3fd84dd108903 Mon Sep 17 00:00:00 2001 From: danieldg Date: Sat, 20 Feb 2010 07:28:33 +0000 Subject: Extend +X to take named modes in addition to mode letters git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12501 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_exemptchanops.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp index 7751153e2..2677e66df 100644 --- a/src/modules/m_exemptchanops.cpp +++ b/src/modules/m_exemptchanops.cpp @@ -88,11 +88,24 @@ class ModuleExemptChanOps : public Module ec.DoSyncChannel(chan, proto, opaque); } + ModeHandler* FindMode(const std::string& mid) + { + if (mid.length() == 1) + return ServerInstance->Modes->FindMode(mid[0], MODETYPE_CHANNEL); + for(char c='A'; c < 'z'; c++) + { + ModeHandler* mh = ServerInstance->Modes->FindMode(c, MODETYPE_CHANNEL); + if (mh && mh->name == mid) + return mh; + } + return NULL; + } + ModResult OnChannelRestrictionApply(User* user, Channel* chan, const char* restriction) { unsigned int mypfx = chan->GetPrefixValue(user); irc::spacesepstream defaultstream(defaults); - char minmode = 0; + std::string minmode; std::string current; while (defaultstream.GetToken(current)) @@ -113,14 +126,14 @@ class ModuleExemptChanOps : public Module if (pos == std::string::npos) continue; if ((*i).mask.substr(0,pos) == restriction) - minmode = (*i).mask[pos+1]; + minmode = (*i).mask.substr(pos + 1); } } - ModeHandler* mh = ServerInstance->Modes->FindMode(minmode, MODETYPE_CHANNEL); + ModeHandler* mh = FindMode(minmode); if (mh && mypfx >= mh->GetPrefixRank()) return MOD_RES_ALLOW; - if (mh || minmode == '*') + if (mh || minmode == "*") return MOD_RES_DENY; return MOD_RES_PASSTHRU; } -- cgit v1.2.3