diff options
| author | 2018-12-19 09:02:09 +0000 | |
|---|---|---|
| committer | 2018-12-19 09:02:09 +0000 | |
| commit | 36da0833c5512a72cbf500a2f5faef5a26ed8dae (patch) | |
| tree | 1ed37a2bb3f768ec7f48aec31aa0ddc5c95956a1 /src/listmode.cpp | |
| parent | Make more modules rehash atomically (#1535) (diff) | |
Add the <maxlist> tag and switch ListModeBase to always use it.
The old method of doing this was:
1. Extremely inconsistently used. Some list modes used <banlist>
and some used their own config tag.
2. Not documented in the slightest. There was a small reference to
<maxbans> for the ban mode but nothing else.
3. In some cases conflicting with other config tags. The chanfilter
module defined a <chanfilter> tag for general config whilst also
using it for the max list settings.
The new <maxlist> tag avoids these issues entirely.
Diffstat (limited to 'src/listmode.cpp')
| -rw-r--r-- | src/listmode.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
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 <banlist> 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("<maxlist:chan> 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("<maxlist:limit> must be non-zero, at %s", c->getTagLocation().c_str())); newlimits.push_back(limit); } |
