]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_disable.cpp
Improve the message sent when a mode does not exist.
[user/henk/code/inspircd.git] / src / modules / m_disable.cpp
index 9791ec7ebd8ee981f5f6385c23e1323ee6d2ab9e..6ba5243c92962cfd9021db4cf05839f7beacac40 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2019-2020 Sadie Powell <sadie@witchery.services>
  *   Copyright (C) 2019 Robby <robby@chatbelgie.be>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
@@ -55,7 +55,7 @@ class ModuleDisable : public Module
 
                        // Check that the mode actually exists.
                        ModeHandler* mh = ServerInstance->Modes->FindMode(chr, type);
-                       if (!chr)
+                       if (!mh)
                                throw ModuleException(InspIRCd::Format("Nonexistent mode '%c' was specified in <disabled:%s> at %s",
                                        chr, field.c_str(), tag->getTagLocation().c_str()));
 
@@ -93,8 +93,8 @@ class ModuleDisable : public Module
                                throw ModuleException(InspIRCd::Format("Nonexistent command '%s' was specified in <disabled:commands> at %s",
                                        command.c_str(), tag->getTagLocation().c_str()));
 
-                       // Prevent admins from disabling COMMANDS and MODULES for transparency reasons.
-                       if (handler->name == "COMMANDS" || handler->name == "MODULES")
+                       // Prevent admins from disabling MODULES for transparency reasons.
+                       if (handler->name == "MODULES")
                                continue;
 
                        // Disable the command.
@@ -171,8 +171,9 @@ class ModuleDisable : public Module
                {
                        // The server administrator has specified that disabled modes should be
                        // treated as if they do not exist.
-                       user->WriteNumeric(mh->GetModeType() == MODETYPE_CHANNEL ? ERR_UNKNOWNMODE : ERR_UNKNOWNSNOMASK,
-                               mh->GetModeChar(), "is an unknown mode character");
+                       int numeric = (mh->GetModeType() == MODETYPE_CHANNEL ? ERR_UNKNOWNMODE : ERR_UNKNOWNSNOMASK);
+                       const char* typestr = (mh->GetModeType() == MODETYPE_CHANNEL ? "channel" : "user");
+                       user->WriteNumeric(numeric, mh->GetModeChar(), InspIRCd::Format("is not a recognised %s mode.", typestr));
                        return MOD_RES_DENY;
                }