unsigned int Backlog;
unsigned int Lines;
unsigned int Diff;
- unsigned int Seconds;
+ unsigned long Seconds;
void serialize(std::string& out) const
{
{
}
- void OnUnset(User* source, Channel* chan)
+ void OnUnset(User* source, Channel* chan) CXX11_OVERRIDE
{
// Unset the per-membership extension when the mode is removed
const Channel::MemberMap& users = chan->GetUsers();
if (!ParseSettings(source, parameter, settings))
{
source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter,
- "Invalid repeat syntax. Syntax is {[~*]}[lines]:[time]{:[difference]}{:[backlog]}."));
+ "Invalid repeat syntax. Syntax is: [~|*]<lines>:<sec>[:<difference>][:<backlog>]"));
return MODEACTION_DENY;
}
if ((settings.Backlog > 0) && (settings.Lines > settings.Backlog))
{
source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter,
- "Invalid repeat syntax. You can't set needed lines higher than backlog."));
+ "Invalid repeat syntax. You can't set lines higher than backlog."));
return MODEACTION_DENY;
}
void ReadConfig()
{
ConfigTag* conf = ServerInstance->Config->ConfValue("repeat");
- ms.MaxLines = conf->getInt("maxlines", 20);
- ms.MaxBacklog = conf->getInt("maxbacklog", 20);
- ms.MaxSecs = conf->getDuration("maxtime", conf->getInt("maxsecs", 0));
+ ms.MaxLines = conf->getUInt("maxlines", 20);
+ ms.MaxBacklog = conf->getUInt("maxbacklog", 20);
+ ms.MaxSecs = conf->getDuration("maxtime", conf->getDuration("maxsecs", 0));
- ms.MaxDiff = conf->getInt("maxdistance", 50);
+ ms.MaxDiff = conf->getUInt("maxdistance", 50);
if (ms.MaxDiff > 100)
ms.MaxDiff = 100;
- unsigned int newsize = conf->getInt("size", 512);
+ unsigned int newsize = conf->getUInt("size", 512);
if (newsize > ServerInstance->Config->Limits.MaxLine)
newsize = ServerInstance->Config->Limits.MaxLine;
Resize(newsize);
else
settings.Action = ChannelSettings::ACT_KICK;
- if ((settings.Lines = ConvToInt(item)) == 0)
+ if ((settings.Lines = ConvToNum<unsigned int>(item)) == 0)
return false;
- if ((!stream.GetToken(item)) || ((settings.Seconds = InspIRCd::Duration(item)) == 0))
+ if (!InspIRCd::Duration(item, settings.Seconds))
+ return false;
+
+ if ((!stream.GetToken(item)) || (settings.Seconds == 0))
// Required parameter missing
return false;
if (stream.GetToken(item))
{
// There is a diff parameter, see if it's valid (> 0)
- if ((settings.Diff = ConvToInt(item)) == 0)
+ if ((settings.Diff = ConvToNum<unsigned int>(item)) == 0)
return false;
if (stream.GetToken(item))
{
// There is a backlog parameter, see if it's valid
- if ((settings.Backlog = ConvToInt(item)) == 0)
+ if ((settings.Backlog = ConvToNum<unsigned int>(item)) == 0)
return false;
// If there are still tokens, then it's invalid because we allow only 4
bool ValidateSettings(LocalUser* source, Channel* channel, const std::string& parameter, const ChannelSettings& settings)
{
- if (settings.Backlog && !ms.MaxBacklog)
+ if (ms.MaxLines && settings.Lines > ms.MaxLines)
{
- source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter,
- "Invalid repeat parameter. The server administrator has disabled backlog matching."));
+ source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format(
+ "Invalid repeat parameter. The line number you specified is too great. Maximum allowed is %u.", ms.MaxLines)));
return false;
}
- if (settings.Diff)
+ if (ms.MaxSecs && settings.Seconds > ms.MaxSecs)
{
- if (settings.Diff > ms.MaxDiff)
- {
- if (ms.MaxDiff == 0)
- source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter,
- "Invalid repeat parameter. The server administrator has disabled matching on edit distance."));
- else
- source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format(
- "Invalid repeat parameter. The distance you specified is too great. Maximum allowed is %u.", ms.MaxDiff)));
- return false;
- }
+ source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format(
+ "Invalid repeat parameter. The seconds you specified are too great. Maximum allowed is %u.", ms.MaxSecs)));
+ return false;
+ }
- if (ms.MaxLines && settings.Lines > ms.MaxLines)
- {
+ if (settings.Diff && settings.Diff > ms.MaxDiff)
+ {
+ if (ms.MaxDiff == 0)
+ source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter,
+ "Invalid repeat parameter. The server administrator has disabled matching on edit distance."));
+ else
source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format(
- "Invalid repeat parameter. The line number you specified is too great. Maximum allowed is %u.", ms.MaxLines)));
- return false;
- }
+ "Invalid repeat parameter. The distance you specified is too great. Maximum allowed is %u.", ms.MaxDiff)));
+ return false;
+ }
- if (ms.MaxSecs && settings.Seconds > ms.MaxSecs)
- {
+ if (settings.Backlog && settings.Backlog > ms.MaxBacklog)
+ {
+ if (ms.MaxBacklog == 0)
+ source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter,
+ "Invalid repeat parameter. The server administrator has disabled backlog matching."));
+ else
source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format(
- "Invalid repeat parameter. The seconds you specified is too great. Maximum allowed is %u.", ms.MaxSecs)));
- return false;
- }
+ "Invalid repeat paramter. The backlog you specified is too great. Maximum allowed is %u.", ms.MaxBacklog)));
+ return false;
}
return true;