X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Flistmode.cpp;h=1ce0da500fca08dabe17a75b58a1b80181932335;hb=9ea8ecfaf395955a4e58c743c2f9e35a26528039;hp=23f98bf3fb616ed56347f895edd2b9f42220fccf;hpb=60658d0bdbc8d047c3dbfc19abb005e147b5b2b9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/listmode.cpp b/src/listmode.cpp index 23f98bf3f..1ce0da500 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -19,11 +19,13 @@ #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) - , extItem("listbase_mode_" + name + "_list", ExtensionItem::EXT_CHANNEL, Creator) +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(name + "_mode_list", ExtensionItem::EXT_CHANNEL, Creator) { list = true; } @@ -60,29 +62,37 @@ void ListModeBase::RemoveMode(Channel* channel, Modes::ChangeList& changelist) void ListModeBase::DoRehash() { - ConfigTagList tags = ServerInstance->Config->ConfTags(configtag); - - limitlist oldlimits = chanlimits; - chanlimits.clear(); - + 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->getInt("limit")); - if (limit.mask.size() && limit.limit > 0) - chanlimits.push_back(limit); + 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(" is empty, at %s", c->getTagLocation().c_str())); + + if (limit.limit <= 0) + throw ModuleException(InspIRCd::Format(" must be non-zero, at %s", c->getTagLocation().c_str())); + + newlimits.push_back(limit); } // Add the default entry. This is inserted last so if the user specifies a // wildcard record in the config it will take precedence over this entry. - chanlimits.push_back(ListLimit("*", DEFAULT_LIST_SIZE)); + newlimits.push_back(ListLimit("*", DEFAULT_LIST_SIZE)); // Most of the time our settings are unchanged, so we can avoid iterating the chanlist - if (oldlimits == chanlimits) + if (chanlimits == newlimits) return; + chanlimits.swap(newlimits); + const chan_hash& chans = ServerInstance->GetChans(); for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i) { @@ -221,15 +231,22 @@ bool ListModeBase::ValidateParam(User*, Channel*, std::string&) return true; } +void ListModeBase::OnParameterMissing(User*, User*, Channel*) +{ + // Intentionally left blank. +} + void ListModeBase::TellListTooLong(User* source, Channel* channel, std::string& parameter) { - source->WriteNumeric(ERR_BANLISTFULL, channel->name, parameter, "Channel ban list is full"); + source->WriteNumeric(ERR_BANLISTFULL, channel->name, parameter, mode, InspIRCd::Format("Channel %s list is full", name.c_str())); } -void ListModeBase::TellAlreadyOnList(User*, Channel*, std::string&) +void ListModeBase::TellAlreadyOnList(User* source, Channel* channel, std::string& parameter) { + source->WriteNumeric(ERR_LISTMODEALREADYSET, channel->name, parameter, mode, InspIRCd::Format("Channel %s list already contains %s", name.c_str(), parameter.c_str())); } -void ListModeBase::TellNotSet(User*, Channel*, std::string&) +void ListModeBase::TellNotSet(User* source, Channel* channel, std::string& parameter) { + source->WriteNumeric(ERR_LISTMODENOTSET, channel->name, parameter, mode, InspIRCd::Format("Channel %s list does not contain %s", name.c_str(), parameter.c_str())); }