]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Allow the maximum length of a chanfilter message to be configured.
authorPeter Powell <petpow@saberuk.com>
Wed, 6 Sep 2017 07:48:19 +0000 (08:48 +0100)
committerPeter Powell <petpow@saberuk.com>
Fri, 2 Feb 2018 12:54:59 +0000 (12:54 +0000)
docs/conf/modules.conf.example
src/modules/m_chanfilter.cpp

index 2941fafbe7a4ae17d98a732ca3424eb5c8551926..24a2ae7b21d9ee2984a82641b0cd7465dfc3eaf1 100644 (file)
 #
 # 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
index 70535a475e05e089a08abf0a2a7718a54b7f17d6..dd11cb5144e8c358a2440050e11120593cc446d2 100644 (file)
@@ -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);
        }
 };