2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2012-2013, 2016 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
8 * Copyright (C) 2009 Thomas Stagner <aquanight@inspircd.org>
9 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
10 * Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
11 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
12 * Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
14 * This file is part of InspIRCd. InspIRCd is free software: you can
15 * redistribute it and/or modify it under the terms of the GNU General Public
16 * License as published by the Free Software Foundation, version 2.
18 * This program is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 class ModuleOperLevels : public Module
33 Version GetVersion() CXX11_OVERRIDE
35 return Version("Allows the server administrator to define ranks for server operators which prevent lower ranked server operators from using /KILL on higher ranked server operators.", VF_VENDOR);
38 ModResult OnKill(User* source, User* dest, const std::string &reason) CXX11_OVERRIDE
40 // oper killing an oper?
41 if (dest->IsOper() && source->IsOper())
43 unsigned long dest_level = ConvToNum<unsigned long>(dest->oper->getConfig("level"));
44 unsigned long source_level = ConvToNum<unsigned long>(source->oper->getConfig("level"));
46 if (dest_level > source_level)
50 ServerInstance->SNO->WriteGlobalSno('a', "Oper %s (level %lu) attempted to /KILL a higher level oper: %s (level %lu), reason: %s",
51 source->nick.c_str(), source_level, dest->nick.c_str(), dest_level, reason.c_str());
53 dest->WriteNotice("*** Oper " + source->nick + " attempted to /KILL you!");
54 source->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper %s is a higher level than you", dest->nick.c_str()));
58 return MOD_RES_PASSTHRU;
62 MODULE_INIT(ModuleOperLevels)