From 36da0833c5512a72cbf500a2f5faef5a26ed8dae Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Wed, 19 Dec 2018 09:02:09 +0000 Subject: Add the tag and switch ListModeBase to always use it. The old method of doing this was: 1. Extremely inconsistently used. Some list modes used and some used their own config tag. 2. Not documented in the slightest. There was a small reference to for the ban mode but nothing else. 3. In some cases conflicting with other config tags. The chanfilter module defined a tag for general config whilst also using it for the max list settings. The new tag avoids these issues entirely. --- src/listmode.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/listmode.cpp') diff --git a/src/listmode.cpp b/src/listmode.cpp index 6b5fb13c5..c11790aea 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -19,10 +19,12 @@ #include "inspircd.h" #include "listmode.h" -ListModeBase::ListModeBase(Module* Creator, const std::string& Name, char modechar, const std::string &eolstr, unsigned int lnum, unsigned int eolnum, bool autotidy, const std::string &ctag) - : ModeHandler(Creator, Name, modechar, PARAM_ALWAYS, MODETYPE_CHANNEL, MC_LIST), - listnumeric(lnum), endoflistnumeric(eolnum), endofliststring(eolstr), tidy(autotidy), - configtag(ctag) +ListModeBase::ListModeBase(Module* Creator, const std::string& Name, char modechar, const std::string& eolstr, unsigned int lnum, unsigned int eolnum, bool autotidy) + : ModeHandler(Creator, Name, modechar, PARAM_ALWAYS, MODETYPE_CHANNEL, MC_LIST) + , listnumeric(lnum) + , endoflistnumeric(eolnum) + , endofliststring(eolstr) + , tidy(autotidy) , extItem("listbase_mode_" + name + "_list", ExtensionItem::EXT_CHANNEL, Creator) { list = true; @@ -60,21 +62,23 @@ void ListModeBase::RemoveMode(Channel* channel, Modes::ChangeList& changelist) void ListModeBase::DoRehash() { - ConfigTagList tags = ServerInstance->Config->ConfTags(configtag); - + ConfigTagList tags = ServerInstance->Config->ConfTags("maxlist"); limitlist newlimits; - for (ConfigIter i = tags.first; i != tags.second; i++) { - // For each tag ConfigTag* c = i->second; - ListLimit limit(c->getString("chan"), c->getUInt("limit", 0)); + + const std::string mname = c->getString("mode"); + if (!mname.empty() && !stdalgo::string::equalsci(mname, name) && !(mname.length() == 1 && GetModeChar() == mname[0])) + continue; + + ListLimit limit(c->getString("chan", "*"), c->getUInt("limit", 0)); if (limit.mask.empty()) - throw ModuleException(InspIRCd::Format("<%s:chan> is empty at %s", configtag.c_str(), c->getTagLocation().c_str())); + throw ModuleException(InspIRCd::Format(" is empty, at %s", c->getTagLocation().c_str())); if (limit.limit <= 0) - throw ModuleException(InspIRCd::Format("<%s:limit> must be greater than 0, at %s", configtag.c_str(), c->getTagLocation().c_str())); + throw ModuleException(InspIRCd::Format(" must be non-zero, at %s", c->getTagLocation().c_str())); newlimits.push_back(limit); } -- cgit v1.3.1-10-gc9f91