2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2018-2019 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 Daniel De Graaf <danieldg@inspircd.org>
9 * Copyright (C) 2007, 2009 Dennis Friis <peavey@inspircd.org>
10 * Copyright (C) 2006 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/>.
41 class CommandOpermotd : public Command
46 CommandOpermotd(Module* Creator) : Command(Creator,"OPERMOTD", 0, 1)
48 flags_needed = 'o'; syntax = "[<servername>]";
51 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
53 if ((parameters.empty()) || (irc::equals(parameters[0], ServerInstance->Config->ServerName)))
54 ShowOperMOTD(user, true);
58 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
60 if ((!parameters.empty()) && (parameters[0].find('.') != std::string::npos))
61 return ROUTE_OPT_UCAST(parameters[0]);
62 return ROUTE_LOCALONLY;
65 void ShowOperMOTD(User* user, bool show_missing)
70 user->WriteRemoteNumeric(ERR_NOOPERMOTD, "OPERMOTD file is missing.");
74 user->WriteRemoteNumeric(RPL_OMOTDSTART, "Server operators message of the day");
76 for (file_cache::const_iterator i = opermotd.begin(); i != opermotd.end(); ++i)
78 user->WriteRemoteNumeric(RPL_OMOTD, InspIRCd::Format(" %s", i->c_str()));
81 user->WriteRemoteNumeric(RPL_ENDOFOMOTD, "End of OPERMOTD");
86 class ModuleOpermotd : public Module
97 Version GetVersion() CXX11_OVERRIDE
99 return Version("Shows a message to opers after oper-up and adds the OPERMOTD command", VF_VENDOR | VF_OPTCOMMON);
102 void OnOper(User* user, const std::string &opertype) CXX11_OVERRIDE
104 if (onoper && IS_LOCAL(user))
105 cmd.ShowOperMOTD(user, false);
108 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
110 cmd.opermotd.clear();
111 ConfigTag* conf = ServerInstance->Config->ConfValue("opermotd");
112 onoper = conf->getBool("onoper", true);
116 FileReader reader(conf->getString("file", "opermotd"));
117 cmd.opermotd = reader.GetVector();
118 InspIRCd::ProcessColors(cmd.opermotd);
120 catch (CoreException&)
122 // Nothing happens here as we do the error handling in ShowOperMOTD.
127 MODULE_INIT(ModuleOpermotd)