From: Peter Powell Date: Thu, 27 Jul 2017 12:13:16 +0000 (+0100) Subject: Merge pull request #1271 from SaberUK/master+exemption X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=ff3b706b2506d7614bce5e54bc88657bd62ebd4d;p=user%2Fhenk%2Fcode%2Finspircd.git Merge pull request #1271 from SaberUK/master+exemption Move the OnCheckExemption hook out of the core. --- ff3b706b2506d7614bce5e54bc88657bd62ebd4d diff --cc src/coremods/core_channel/core_channel.cpp index 6fe6199db,b77aac7e2..3af809645 --- a/src/coremods/core_channel/core_channel.cpp +++ b/src/coremods/core_channel/core_channel.cpp @@@ -20,9 -20,8 +20,9 @@@ #include "inspircd.h" #include "core_channel.h" #include "invite.h" +#include "listmode.h" - class CoreModChannel : public Module + class CoreModChannel : public Module, public CheckExemption::EventListener { Invite::APIImpl invapi; CommandInvite cmdinvite; @@@ -57,32 -62,25 +63,49 @@@ for (unsigned int i = 0; i < sizeof(events)/sizeof(Implementation); i++) ServerInstance->Modules.Detach(events[i], this); } + + std::string current; + irc::spacesepstream defaultstream(optionstag->getString("exemptchanops")); + insp::flat_map exempts; + while (defaultstream.GetToken(current)) + { + std::string::size_type pos = current.find(':'); + if (pos == std::string::npos || (pos + 2) > current.size()) + throw ModuleException("Invalid exemptchanops value '" + current + "' at " + optionstag->getTagLocation()); + + const std::string restriction = current.substr(0, pos); + const char prefix = current[pos + 1]; + + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Exempting prefix %c from %s", prefix, restriction.c_str()); + exempts[restriction] = prefix; + } + exemptions.swap(exempts); } + void On005Numeric(std::map& tokens) CXX11_OVERRIDE + { + // Build a map of limits to their mode character. + insp::flat_map limits; + const ModeParser::ListModeList& listmodes = ServerInstance->Modes->GetListModes(); + for (ModeParser::ListModeList::const_iterator iter = listmodes.begin(); iter != listmodes.end(); ++iter) + { + const unsigned int limit = (*iter)->GetLowerLimit(); + limits[limit].push_back((*iter)->GetModeChar()); + } + + // Generate the MAXLIST token from the limits map. + std::string& buffer = tokens["MAXLIST"]; + for (insp::flat_map::const_iterator iter = limits.begin(); iter != limits.end(); ++iter) + { + if (!buffer.empty()) + buffer.push_back(','); + + buffer.append(iter->second); + buffer.push_back(':'); + buffer.append(ConvToStr(iter->first)); + } + } + void OnPostJoin(Membership* memb) CXX11_OVERRIDE { Channel* const chan = memb->chan;