]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add a shun option for cleaning problematic allowed commands.
authorSadie Powell <sadie@witchery.services>
Sun, 27 Sep 2020 02:43:16 +0000 (03:43 +0100)
committerSadie Powell <sadie@witchery.services>
Sun, 27 Sep 2020 10:37:42 +0000 (11:37 +0100)
src/modules/m_shun.cpp

index 6be91ce671b23d1a70c193919bdcd73607b97f8c..307e6a69496852e63bd19284cf7c2c2c054731fb 100644 (file)
@@ -154,6 +154,7 @@ class ModuleShun : public Module, public Stats::EventListener
  private:
        CommandShun cmd;
        ShunFactory shun;
+       insp::flat_set<std::string, irc::insensitive_swo> cleanedcommands;
        insp::flat_set<std::string, irc::insensitive_swo> enabledcommands;
        bool affectopers;
        bool allowtags;
@@ -210,6 +211,11 @@ class ModuleShun : public Module, public Stats::EventListener
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("shun");
 
+               cleanedcommands.clear();
+               irc::spacesepstream cleanedcmds(tag->getString("cleanedcommands", "AWAY PART QUIT"));
+               for (std::string cleanedcmd; cleanedcmds.GetToken(cleanedcmd); )
+                       cleanedcommands.insert(cleanedcmd);
+
                enabledcommands.clear();
                irc::spacesepstream enabledcmds(tag->getString("enabledcommands", "ADMIN OPER PING PONG QUIT", 1));
                for (std::string enabledcmd; enabledcmds.GetToken(enabledcmd); )
@@ -244,18 +250,26 @@ class ModuleShun : public Module, public Stats::EventListener
                                        tag++;
                        }
                }
-               if (command == "QUIT")
-               {
-                       /* Allow QUIT but dont show any quit message */
-                       parameters.clear();
-               }
-               else if ((command == "PART") && (parameters.size() > 1))
+
+               if (cleanedcommands.count(command))
                {
-                       /* same for PART */
-                       parameters.pop_back();
+                       if (command == "AWAY" && !parameters.empty())
+                       {
+                               // Allow away but only for unsetting.
+                               parameters.clear();
+                       }
+                       else if (command == "PART" && parameters.size() > 1)
+                       {
+                               // Allow part but strip the message.
+                               parameters.pop_back();
+                       }
+                       else if (command == "QUIT" && !parameters.empty())
+                       {
+                               // Allow quit but strip the message.
+                               parameters.clear();
+                       }
                }
 
-               /* if we're here, allow the command. */
                return MOD_RES_PASSTHRU;
        }