2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2018-2019 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2012-2014 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
8 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
9 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
10 * Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
12 * This file is part of InspIRCd. InspIRCd is free software: you can
13 * redistribute it and/or modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation, version 2.
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 class ModuleOperLog : public Module
33 void init() CXX11_OVERRIDE
35 ServerInstance->SNO->EnableSnomask('r', "OPERLOG");
38 Version GetVersion() CXX11_OVERRIDE
40 return Version("Allows the server administrator to make the server log when a server operator-only command is executed.", VF_VENDOR);
43 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
45 tosnomask = ServerInstance->Config->ConfValue("operlog")->getBool("tosnomask", false);
48 ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
50 /* If the command doesnt appear to be valid, we dont want to mess with it. */
52 return MOD_RES_PASSTHRU;
54 if ((user->IsOper()) && (user->HasCommandPermission(command)))
56 Command* thiscommand = ServerInstance->Parser.GetHandler(command);
57 if ((thiscommand) && (thiscommand->flags_needed == 'o'))
59 std::string msg = "[" + user->GetFullRealHost() + "] " + command + " " + stdalgo::string::join(parameters);
60 ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "OPERLOG: " + msg);
62 ServerInstance->SNO->WriteGlobalSno('r', msg);
66 return MOD_RES_PASSTHRU;
69 void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
76 MODULE_INIT(ModuleOperLog)