mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Allow autoop to use long names
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12499 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
1824ae8d9d
commit
fda0be1859
@ -844,7 +844,7 @@ Closes all unregistered connections to the local server.">
|
||||
see themselves or themselves and the operators,
|
||||
while operators see all the users (requires
|
||||
auditorium module).
|
||||
w Adds basic channel access controls of [flag] to
|
||||
w [flag]:[banmask] Adds basic channel access controls of [flag] to
|
||||
[banmask], via the +w listmode.
|
||||
For example, +w o:R:Brain will op anyone identified
|
||||
to the account 'Brain' on join.
|
||||
|
@ -164,7 +164,7 @@ LOCKSERV UNLOCKSERV JUMPSERVER">
|
||||
see themselves or themselves and the operators,
|
||||
while operators see all the users (requires
|
||||
auditorium module).
|
||||
w Adds basic channel access controls of [flag] to
|
||||
w [flag]:[banmask] Adds basic channel access controls of [flag] to
|
||||
[banmask], via the +w listmode.
|
||||
For example, +w o:R:Brain will op anyone identified
|
||||
to the account 'Brain' on join.
|
||||
|
@ -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 ¶meter, 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)
|
||||
{
|
||||
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;
|
||||
std::string mid = parameter.substr(0, pos);
|
||||
ModeHandler* mh = FindMode(mid);
|
||||
|
||||
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;
|
||||
}
|
||||
if (adding && (!mh || !mh->GetPrefixRank()))
|
||||
{
|
||||
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 '%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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user