X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_repeat.cpp;h=ef62e9ab10bdec3aeb60b1a52bb61d7b05822d6f;hb=b7716ed57704b2b2bcc665a590aecc8f02de631d;hp=75105ca0d5796718b5bb6738e5a3c52a63a93650;hpb=91e0af0fc4889f20d2f63426f8fe379674fc0393;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index 75105ca0d..ef62e9ab1 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -140,18 +140,20 @@ class RepeatMode : public ParamMode > ChannelSettings settings; if (!ParseSettings(source, parameter, settings)) { - source->WriteNotice("*** Invalid syntax. Syntax is {[~*]}[lines]:[time]{:[difference]}{:[backlog]}"); + source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, + "Invalid repeat syntax. Syntax is {[~*]}[lines]:[time]{:[difference]}{:[backlog]}.")); return MODEACTION_DENY; } if ((settings.Backlog > 0) && (settings.Lines > settings.Backlog)) { - source->WriteNotice("*** You can't set needed lines higher than backlog"); + source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, + "Invalid repeat syntax. You can't set needed lines higher than backlog.")); return MODEACTION_DENY; } LocalUser* localsource = IS_LOCAL(source); - if ((localsource) && (!ValidateSettings(localsource, settings))) + if ((localsource) && (!ValidateSettings(localsource, channel, parameter, settings))) return MODEACTION_DENY; ext.set(channel, settings); @@ -231,15 +233,15 @@ class RepeatMode : public ParamMode > 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); @@ -302,36 +304,42 @@ class RepeatMode : public ParamMode > return true; } - bool ValidateSettings(LocalUser* source, const ChannelSettings& settings) + 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->WriteNotice("*** 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->WriteNotice("*** The server administrator has disabled matching on edit distance"); - else - source->WriteNotice("*** The distance you specified is too great. Maximum allowed is " + ConvToStr(ms.MaxDiff)); - return false; - } + 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; + } - if (ms.MaxLines && settings.Lines > ms.MaxLines) - { - source->WriteNotice("*** The line number you specified is too great. Maximum allowed is " + ConvToStr(ms.MaxLines)); - return false; - } + 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 distance you specified is too great. Maximum allowed is %u.", ms.MaxDiff))); + return false; + } - if (ms.MaxSecs && settings.Seconds > ms.MaxSecs) - { - source->WriteNotice("*** The seconds you specified is too great. Maximum allowed is " + ConvToStr(ms.MaxSecs)); - return false; - } + 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 paramter. The backlog you specified is too great. Maximum allowed is %u.", ms.MaxBacklog))); + return false; } return true; @@ -355,12 +363,12 @@ class RepeatModule : public Module rm.ReadConfig(); } - ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE + ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE { - if (target_type != TYPE_CHANNEL || !IS_LOCAL(user)) + if (target.type != MessageTarget::TYPE_CHANNEL || !IS_LOCAL(user)) return MOD_RES_PASSTHRU; - Channel* chan = reinterpret_cast(dest); + Channel* chan = target.Get(); ChannelSettings* settings = rm.ext.get(chan); if (!settings) return MOD_RES_PASSTHRU; @@ -373,7 +381,7 @@ class RepeatModule : public Module if (res == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; - if (rm.MatchLine(memb, settings, text)) + if (rm.MatchLine(memb, settings, details.text)) { if (settings->Action == ChannelSettings::ACT_BLOCK) {