X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_repeat.cpp;h=e6568732b68aa74d6cd32d21b92033bec17175a8;hb=b191657921845a26128e910bfff0f21251e98ee4;hp=bd42061662a1ba2b9dd1a89e97a1a46a57295857;hpb=8ec9a73a91ad1c7009fd3055fbad7c980b5e1732;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index bd4206166..e6568732b 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -1,6 +1,12 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2019 Robby + * Copyright (C) 2018-2019 linuxdaemon + * Copyright (C) 2018 Matt Schatz + * Copyright (C) 2017-2019 Sadie Powell + * Copyright (C) 2015 James Lu + * Copyright (C) 2013-2015 Attila Molnar * Copyright (C) 2013 Daniel Vassdal * * This file is part of InspIRCd. InspIRCd is free software: you can @@ -34,7 +40,7 @@ class ChannelSettings unsigned int Backlog; unsigned int Lines; unsigned int Diff; - unsigned int Seconds; + unsigned long Seconds; void serialize(std::string& out) const { @@ -84,6 +90,7 @@ class RepeatMode : public ParamMode > unsigned int MaxBacklog; unsigned int MaxDiff; unsigned int MaxMessageSize; + std::string KickMessage; ModuleSettings() : MaxLines(0), MaxSecs(0), MaxBacklog(0), MaxDiff() { } }; @@ -125,6 +132,7 @@ class RepeatMode : public ParamMode > : ParamMode >(Creator, "repeat", 'E') , MemberInfoExt("repeat_memb", ExtensionItem::EXT_MEMBERSHIP, Creator) { + syntax = "[~|*]:[:][:]"; } void OnUnset(User* source, Channel* chan) CXX11_OVERRIDE @@ -140,15 +148,14 @@ class RepeatMode : public ParamMode > ChannelSettings settings; if (!ParseSettings(source, parameter, settings)) { - source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, - "Invalid repeat syntax. Syntax is {[~*]}[lines]:[time]{:[difference]}{:[backlog]}.")); + source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); 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.")); + "You can't set lines higher than backlog.")); return MODEACTION_DENY; } @@ -245,6 +252,8 @@ class RepeatMode : public ParamMode > if (newsize > ServerInstance->Config->Limits.MaxLine) newsize = ServerInstance->Config->Limits.MaxLine; Resize(newsize); + + ms.KickMessage = conf->getString("kickmessage", "Repeat flood"); } std::string GetModuleSettings() const @@ -252,6 +261,11 @@ class RepeatMode : public ParamMode > return ConvToStr(ms.MaxLines) + ":" + ConvToStr(ms.MaxSecs) + ":" + ConvToStr(ms.MaxDiff) + ":" + ConvToStr(ms.MaxBacklog); } + std::string GetKickMessage() const + { + return ms.KickMessage; + } + void SerializeParam(Channel* chan, const ChannelSettings* chset, std::string& out) { chset->serialize(out); @@ -277,7 +291,7 @@ class RepeatMode : public ParamMode > if ((settings.Lines = ConvToNum(item)) == 0) return false; - if ((!stream.GetToken(item)) || ((settings.Seconds = InspIRCd::Duration(item)) == 0)) + if ((!stream.GetToken(item)) || !InspIRCd::Duration(item, settings.Seconds) || (settings.Seconds == 0)) // Required parameter missing return false; @@ -309,14 +323,14 @@ class RepeatMode : public ParamMode > if (ms.MaxLines && settings.Lines > ms.MaxLines) { 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))); + "The line number you specified is too big. Maximum allowed is %u.", ms.MaxLines))); return false; } if (ms.MaxSecs && settings.Seconds > ms.MaxSecs) { 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))); + "The seconds you specified are too big. Maximum allowed is %u.", ms.MaxSecs))); return false; } @@ -324,10 +338,10 @@ class RepeatMode : public ParamMode > { if (ms.MaxDiff == 0) source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, - "Invalid repeat parameter. The server administrator has disabled matching on edit distance.")); + "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))); + "The distance you specified is too big. Maximum allowed is %u.", ms.MaxDiff))); return false; } @@ -335,10 +349,10 @@ class RepeatMode : public ParamMode > { if (ms.MaxBacklog == 0) source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, - "Invalid repeat parameter. The server administrator has disabled backlog matching.")); + "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))); + "The backlog you specified is too big. Maximum allowed is %u.", ms.MaxBacklog))); return false; } @@ -396,7 +410,7 @@ class RepeatModule : public Module ServerInstance->Modes->Process(ServerInstance->FakeClient, chan, NULL, changelist); } - memb->chan->KickUser(ServerInstance->FakeClient, user, "Repeat flood"); + memb->chan->KickUser(ServerInstance->FakeClient, user, rm.GetKickMessage()); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; @@ -409,7 +423,7 @@ class RepeatModule : public Module Version GetVersion() CXX11_OVERRIDE { - return Version("Provides the +E channel mode - for blocking of similar messages", VF_COMMON|VF_VENDOR, rm.GetModuleSettings()); + return Version("Adds channel mode E (repeat) which helps protect against spammers which spam the same message repeatedly.", VF_COMMON|VF_VENDOR, rm.GetModuleSettings()); } };