+ // If the CTCP is not an action then skip it.
+ if (!irc::equals(ctcpname, "ACTION"))
+ return MOD_RES_PASSTHRU;
+ }
+
+ // If the message is shorter than the minimum length
+ // then we don't need to do anything else.
+ size_t length = message.length();
+ if (length < 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 = message.begin(); iter != message.end(); ++iter)
+ {
+ unsigned char chr = static_cast<unsigned char>(*iter);
+ if (uppercase.test(chr))
+ upper += 1;
+ else if (!lowercase.test(chr))
+ length -= 1;
+ }
+
+ // Calculate the percentage which is upper case. If the
+ // message was entirely symbols then it can't contain
+ // any upper case letters.
+ if (length > 0 && round((upper * 100) / length) >= percent)
+ {
+ user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, InspIRCd::Format("Your message cannot contain %d%% or more capital letters if it's longer than %d characters", percent, minlen));
+ return MOD_RES_DENY;