*/
unsigned int GetLimit(Channel* channel);
+ /** Gets the lower list limit for this listmode.
+ */
+ unsigned int GetLowerLimit();
+
/** Retrieves the list of all modes set on the given channel
* @param channel Channel to get the list from
* @return A list with all modes of this type set on the given channel, can be NULL
#include "inspircd.h"
#include "core_channel.h"
#include "invite.h"
+#include "listmode.h"
class CoreModChannel : public Module
{
}
}
+ void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
+ {
+ // Build a map of limits to their mode character.
+ insp::flat_map<int, std::string> 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<int, std::string>::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;
return GetLimitInternal(channel->name, cd);
}
+unsigned int ListModeBase::GetLowerLimit()
+{
+ unsigned int limit = UINT_MAX;
+ for (limitlist::iterator iter = chanlimits.begin(); iter != chanlimits.end(); ++iter)
+ {
+ if (iter->limit < limit)
+ limit = iter->limit;
+ }
+ return limit == UINT_MAX ? DEFAULT_LIST_SIZE : limit;
+}
+
ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding)
{
// Try and grab the list
tokens["CHANTYPES"] = "#";
tokens["ELIST"] = "MU";
tokens["KICKLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxKick);
- tokens["MAXBANS"] = "64"; // TODO: make this a config setting.
tokens["MAXTARGETS"] = ConvToStr(ServerInstance->Config->MaxTargets);
tokens["MODES"] = ConvToStr(ServerInstance->Config->Limits.MaxModes);
tokens["NETWORK"] = ServerInstance->Config->Network;