diff options
author | Peter Powell <petpow@saberuk.com> | 2019-10-01 12:27:17 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-10-01 12:32:40 +0100 |
commit | 4d2391ee094553cc11ce84b7b81d39bdb89ec48e (patch) | |
tree | ccfb999be0acd0880a102f79a108bb4a52f448eb | |
parent | 32d96016bd21fd5dff54503df4222c10662e57e5 (diff) |
Show the list modes which have variable list lengths in 005.
-rw-r--r-- | include/listmode.h | 3 | ||||
-rw-r--r-- | src/coremods/core_channel/core_channel.cpp | 18 | ||||
-rw-r--r-- | src/server.cpp | 1 |
3 files changed, 17 insertions, 5 deletions
diff --git a/include/listmode.h b/include/listmode.h index 66c3b8446..6941b5aeb 100644 --- a/include/listmode.h +++ b/include/listmode.h @@ -120,6 +120,9 @@ class CoreExport ListModeBase : public ModeHandler */ ListModeBase(Module* Creator, const std::string& Name, char modechar, const std::string& eolstr, unsigned int lnum, unsigned int eolnum, bool autotidy); + /** Determines whether some channels have longer lists than others. */ + bool HasVariableLength() const { return chanlimits.size() > 1; } + /** Get limit of this mode on a channel * @param channel The channel to inspect * @return Maximum number of modes of this type that can be placed on the given channel diff --git a/src/coremods/core_channel/core_channel.cpp b/src/coremods/core_channel/core_channel.cpp index e95736ccc..b989f8778 100644 --- a/src/coremods/core_channel/core_channel.cpp +++ b/src/coremods/core_channel/core_channel.cpp @@ -205,16 +205,20 @@ class CoreModChannel : public Module, public CheckExemption::EventListener { tokens["KEYLEN"] = ConvToStr(ModeChannelKey::maxkeylen); - // Build a map of limits to their mode character. insp::flat_map<int, std::string> limits; + std::string vlist; 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()); + ListModeBase* lm = *iter; + + const unsigned int limit = lm->GetLowerLimit(); + limits[limit].push_back(lm->GetModeChar()); + + if (lm->HasVariableLength()) + vlist.push_back(lm->GetModeChar()); } - // Generate the MAXLIST token from the limits map. std::string& buffer = tokens["MAXLIST"]; for (insp::flat_map<int, std::string>::const_iterator iter = limits.begin(); iter != limits.end(); ++iter) { @@ -228,6 +232,12 @@ class CoreModChannel : public Module, public CheckExemption::EventListener buffer.push_back(':'); buffer.append(ConvToStr(iter->first)); } + + if (!vlist.empty()) + { + tokens["VBANLIST"]; // deprecated + tokens["VLIST"] = vlist; + } } ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string&, std::string&, const std::string& keygiven) CXX11_OVERRIDE diff --git a/src/server.cpp b/src/server.cpp index f2abfe0e2..39d30e37a 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -201,7 +201,6 @@ void ISupportManager::Build() tokens["STATUSMSG"] = ServerInstance->Modes->BuildPrefixes(false); tokens["TOPICLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxTopic); tokens["USERLEN"] = ConvToStr(ServerInstance->Config->Limits.IdentMax); - tokens["VBANLIST"]; // Modules can add new tokens and also edit or remove existing tokens FOREACH_MOD(On005Numeric, (tokens)); |