/*
* InspIRCd -- Internet Relay Chat Daemon
*
- * Copyright (C) 2019 Peter Powell <petpow@saberuk.com>
+ * 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
* redistribute it and/or modify it under the terms of the GNU General Public
// Check that the mode actually exists.
ModeHandler* mh = ServerInstance->Modes->FindMode(chr, type);
- if (!chr)
- throw ModuleException(InspIRCd::Format("Non-existent mode '%c' was specified in <disabled:%s> at %s",
+ if (!mh)
+ throw ModuleException(InspIRCd::Format("Nonexistent mode '%c' was specified in <disabled:%s> at %s",
chr, field.c_str(), tag->getTagLocation().c_str()));
// Disable the mode.
// Check that the command actually exists.
Command* handler = ServerInstance->Parser.GetHandler(command);
if (!handler)
- throw ModuleException(InspIRCd::Format("Non-existent command '%s' was specified in <disabled:commands> at %s",
+ 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.
// The user has tried to change a disabled mode!
const char* what = mh->GetModeType() == MODETYPE_CHANNEL ? "channel" : "user";
- WriteLog("%s was blocked from executing the disabled %s mode %c (%s)",
- user->GetFullRealHost().c_str(), what, mh->GetModeChar(), mh->name.c_str());
+ WriteLog("%s was blocked from %ssetting the disabled %s mode %c (%s)",
+ user->GetFullRealHost().c_str(), adding ? "" : "un",
+ what, mh->GetModeChar(), mh->name.c_str());
if (fakenonexistent)
{
// 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 unknown mode char to me");
+ 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;
}
Version GetVersion() CXX11_OVERRIDE
{
- return Version("Provides support for disabling commands and modes", VF_VENDOR);
+ return Version("Allows commands, channel modes, and user modes to be disabled.", VF_VENDOR);
}
};