]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_classban.cpp
Add support for blocking tag messages with the deaf mode.
[user/henk/code/inspircd.git] / src / modules / m_classban.cpp
index 066834079c1444a597afdd245aa9047db7e0cdde..b2cbb1e597d75cc2054a7698ad828c722710bb8f 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2016 Johanna Abrahamsson <johanna-a@mjao.org>
+ *   Copyright (C) 2020 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2016 Johanna A <johanna-a@users.noreply.github.com>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
 
 class ModuleClassBan : public Module
 {
+ private:
+       std::string space;
+       std::string underscore;
+
  public:
+       ModuleClassBan()
+               : space(" ")
+               , underscore("_")
+       {
+       }
+
        ModResult OnCheckBan(User* user, Channel* c, const std::string& mask) CXX11_OVERRIDE
        {
                LocalUser* localUser = IS_LOCAL(user);
                if ((localUser) && (mask.length() > 2) && (mask[0] == 'n') && (mask[1] == ':'))
                {
-                       if (InspIRCd::Match(localUser->GetClass()->name, mask.substr(2)))
+                       // Replace spaces with underscores as they're prohibited in mode parameters.
+                       std::string classname(localUser->GetClass()->name);
+                       stdalgo::string::replace_all(classname, space, underscore);
+                       if (InspIRCd::Match(classname, mask.substr(2)))
                                return MOD_RES_DENY;
+
                }
                return MOD_RES_PASSTHRU;
        }
@@ -40,7 +55,7 @@ class ModuleClassBan : public Module
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Class 'n' - Connection class ban", VF_VENDOR | VF_OPTCOMMON);
+               return Version("Adds the n: extended ban which check whether users are in a connect class matching the specified glob pattern.", VF_VENDOR | VF_OPTCOMMON);
        }
 };