summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-09-06 08:48:19 +0100
committerPeter Powell <petpow@saberuk.com>2018-02-02 12:54:59 +0000
commit4132a44396d8fa3d23f87b5cbea5b928aa09769f (patch)
tree501fc26e8f434be71255c37777faaa5a54cd32d1
parentc2376ac6f49ab01794a21a3e9bb7c1b3c5a1c2d8 (diff)
Allow the maximum length of a chanfilter message to be configured.
-rw-r--r--docs/conf/modules.conf.example4
-rw-r--r--src/modules/m_chanfilter.cpp18
2 files changed, 17 insertions, 5 deletions
diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example
index 2941fafbe..24a2ae7b2 100644
--- a/docs/conf/modules.conf.example
+++ b/docs/conf/modules.conf.example
@@ -386,7 +386,9 @@
#
# If hidemask is set to yes, the user will not be shown the mask when
# his/her message is blocked.
-#<chanfilter hidemask="yes">
+#
+# If maxlen is set then it defines the maximum length of a filter entry.
+#<chanfilter hidemask="yes" maxlen="50">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Channel history module: Displays the last 'X' lines of chat to a user
diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp
index 70535a475..dd11cb514 100644
--- a/src/modules/m_chanfilter.cpp
+++ b/src/modules/m_chanfilter.cpp
@@ -40,10 +40,13 @@ enum
class ChanFilter : public ListModeBase
{
public:
+ unsigned long maxlen;
+
ChanFilter(Module* Creator) : ListModeBase(Creator, "filter", 'g', "End of channel spamfilter list", 941, 940, false, "chanfilter") { }
- bool ValidateParam(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE {
- if (word.length() > 35)
+ bool ValidateParam(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE
+ {
+ if (word.length() > maxlen)
{
user->WriteNumeric(Numerics::InvalidModeParameter(chan, this, word, "Word is too long for the spamfilter list"));
return false;
@@ -84,7 +87,9 @@ class ModuleChanFilter : public Module
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
- hidemask = ServerInstance->Config->ConfValue("chanfilter")->getBool("hidemask");
+ ConfigTag* tag = ServerInstance->Config->ConfValue("chanfilter");
+ hidemask = tag->getBool("hidemask");
+ cf.maxlen = tag->getInt("maxlen", 35, 10, 100);
cf.DoRehash();
}
@@ -121,7 +126,12 @@ class ModuleChanFilter : public Module
Version GetVersion() CXX11_OVERRIDE
{
- return Version("Provides channel-specific censor lists (like mode +G but varies from channel to channel)", VF_VENDOR);
+ // We don't send any link data if the length is 35 for compatibility with the 2.0 branch.
+ std::string maxfilterlen;
+ if (cf.maxlen != 35)
+ maxfilterlen.assign(ConvToStr(cf.maxlen));
+
+ return Version("Provides channel-specific censor lists (like mode +G but varies from channel to channel)", VF_VENDOR, maxfilterlen);
}
};