summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-20 07:28:33 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-20 07:28:33 +0000
commita5263a8adad14fa05bdc6f55d7d3fd84dd108903 (patch)
tree12ecc9baabb9b859c892011a7c49a3489fd20b22
parent60b5a882c45cea0d93119e499f6bb5947036abc5 (diff)
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
-rw-r--r--src/modules/m_exemptchanops.cpp21
1 files changed, 17 insertions, 4 deletions
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;
}