summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-19 21:39:53 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-19 21:39:53 +0000
commitfda0be18598ce59ef16c37b35e38b55979d07bc4 (patch)
treea4928f8623d3ff3741333aa4d91b721ad403d5ba /src
parent1824ae8d9d3e8c6117a055164d6bc2073a46f918 (diff)
Allow autoop to use long names
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12499 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_autoop.cpp58
1 files changed, 36 insertions, 22 deletions
diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp
index b96495bf7..427ebfab8 100644
--- a/src/modules/m_autoop.cpp
+++ b/src/modules/m_autoop.cpp
@@ -26,40 +26,50 @@ class AutoOpList : public ListModeBase
levelrequired = OP_VALUE;
}
+ 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 AccessCheck(User* source, Channel* channel, std::string &parameter, bool adding)
{
std::string::size_type pos = parameter.find(':');
if (pos == 0 || pos == std::string::npos)
return adding ? MOD_RES_DENY : MOD_RES_PASSTHRU;
unsigned int mylevel = channel->GetPrefixValue(source);
- while (pos > 0)
+ std::string mid = parameter.substr(0, pos);
+ ModeHandler* mh = FindMode(mid);
+
+ if (adding && (!mh || !mh->GetPrefixRank()))
{
- pos--;
- ModeHandler* mh = ServerInstance->Modes->FindMode(parameter[pos], MODETYPE_CHANNEL);
- if (adding && (!mh || !mh->GetPrefixRank()))
- {
- source->WriteNumeric(415, "%s %c :Cannot find prefix mode '%c' for autoop",
- source->nick.c_str(), parameter[pos], parameter[pos]);
- return MOD_RES_DENY;
- }
- else if (!mh)
- continue;
+ source->WriteNumeric(415, "%s %s :Cannot find prefix mode '%s' for autoop",
+ source->nick.c_str(), mid.c_str(), mid.c_str());
+ return MOD_RES_DENY;
+ }
+ else if (!mh)
+ return MOD_RES_PASSTHRU;
- std::string dummy;
- if (mh->AccessCheck(source, channel, dummy, true) == MOD_RES_DENY)
- return MOD_RES_DENY;
- if (mh->GetLevelRequired() > mylevel)
- {
- source->WriteNumeric(482, "%s %s :You must be able to set mode '%c' to include it in an autoop",
- source->nick.c_str(), channel->name.c_str(), parameter[pos]);
- return MOD_RES_DENY;
- }
+ std::string dummy;
+ if (mh->AccessCheck(source, channel, dummy, true) == MOD_RES_DENY)
+ return MOD_RES_DENY;
+ if (mh->GetLevelRequired() > mylevel)
+ {
+ source->WriteNumeric(482, "%s %s :You must be able to set mode '%s' to include it in an autoop",
+ source->nick.c_str(), channel->name.c_str(), mid.c_str());
+ return MOD_RES_DENY;
}
return MOD_RES_PASSTHRU;
}
};
-
class ModuleAutoOp : public Module
{
AutoOpList mh;
@@ -88,7 +98,11 @@ public:
if (colon == std::string::npos)
continue;
if (chan->CheckBan(user, it->mask.substr(colon+1)))
- privs += it->mask.substr(0, colon);
+ {
+ ModeHandler* given = mh.FindMode(it->mask.substr(0, colon));
+ if (given)
+ privs += given->GetModeChar();
+ }
}
}