X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_anticaps.cpp;h=8f020ed03d1410d9319025bff2c084b5d9fbee45;hb=5a2af6ded883d71c6c4c9f1497cca1721f8b0742;hp=6b0c192bea0147e68dcd610414f3d4187e59de65;hpb=36e6dc7bc8c21db2f8fa63c96b3e3aa23886e056;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_anticaps.cpp b/src/modules/m_anticaps.cpp index 6b0c192be..8f020ed03 100644 --- a/src/modules/m_anticaps.cpp +++ b/src/modules/m_anticaps.cpp @@ -75,7 +75,7 @@ class AntiCapsMode : public ParamMode(minlenstr); if (result < 1 || result > ServerInstance->Config->Limits.MaxLine) return false; @@ -89,7 +89,7 @@ class AntiCapsMode : public ParamMode(percentstr); if (result < 1 || result > 100) return false; @@ -101,9 +101,10 @@ class AntiCapsMode : public ParamMode >(Creator, "anticaps", 'B') { + syntax = "{ban|block|mute|kick|kickban}::"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) + ModeAction OnSet(User* source, Channel* channel, std::string& parameter) CXX11_OVERRIDE { irc::sepstream stream(parameter, ':'); AntiCapsMethod method; @@ -113,7 +114,7 @@ class AntiCapsMode : public ParamModeWriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, "Invalid anticaps mode parameter. Syntax: :{minlen}:{percent}.")); + source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); return MODEACTION_DENY; } @@ -148,7 +149,7 @@ class AntiCapsMode : public ParamModeminlen)); out.push_back(':'); - out.append(ConvToStr(acs->percent)); + out.append(ConvNumeric(acs->percent)); } }; @@ -173,7 +174,7 @@ class ModuleAntiCaps : public Module void InformUser(Channel* channel, User* user, const std::string& message) { - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, channel, message + " and was blocked."); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, channel->name, message + " and was blocked."); } public: @@ -216,23 +217,18 @@ class ModuleAntiCaps : public Module // If the user is exempt from anticaps then we don't need // to do anything else. ModResult result = CheckExemption::Call(exemptionprov, user, channel, "anticaps"); - if (result == MOD_RES_ALLOW) + if (result == MOD_RES_ALLOW) return MOD_RES_PASSTHRU; // If the message is a CTCP then we skip it unless it is - // an ACTION in which case we skip the prefix and suffix. - std::string::const_iterator text_begin = details.text.begin(); - std::string::const_iterator text_end = details.text.end(); - if (details.text[0] == '\1') + // an ACTION in which case we just check against the body. + std::string ctcpname; + std::string msgbody(details.text); + if (details.IsCTCP(ctcpname, msgbody)) { // If the CTCP is not an action then skip it. - if (details.text.compare(0, 8, "\1ACTION ", 8)) + if (!irc::equals(ctcpname, "ACTION")) return MOD_RES_PASSTHRU; - - // Skip the CTCP message characters. - text_begin += 8; - if (*details.text.rbegin() == '\1') - text_end -= 1; } // Retrieve the anticaps config. This should never be @@ -243,14 +239,14 @@ class ModuleAntiCaps : public Module // If the message is shorter than the minimum length then // we don't need to do anything else. - size_t length = std::distance(text_begin, text_end); + size_t length = msgbody.length(); if (length < config->minlen) return MOD_RES_PASSTHRU; // Count the characters to see how many upper case and // ignored (non upper or lower) characters there are. size_t upper = 0; - for (std::string::const_iterator iter = text_begin; iter != text_end; ++iter) + for (std::string::const_iterator iter = msgbody.begin(); iter != msgbody.end(); ++iter) { unsigned char chr = static_cast(*iter); if (uppercase.test(chr)) @@ -302,7 +298,7 @@ class ModuleAntiCaps : public Module Version GetVersion() CXX11_OVERRIDE { - return Version("Provides support for punishing users that send capitalised messages.", VF_COMMON|VF_VENDOR); + return Version("Provides support for punishing users that send capitalised messages", VF_COMMON|VF_VENDOR); } };