2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5 * Copyright (C) 2005, 2007 Robin Burchell <robin+git@viroteck.net>
6 * Copyright (C) 2005-2006 Craig Edwards <craigedwards@brainbox.cc>
7 * Copyright (C) 2004 Christopher Hall <typobox43@gmail.com>
9 * This file is part of InspIRCd. InspIRCd is free software: you can
10 * redistribute it and/or modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation, version 2.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
38 class CommandOpermotd : public Command
43 CommandOpermotd(Module* Creator) : Command(Creator,"OPERMOTD", 0, 1)
45 flags_needed = 'o'; syntax = "[<servername>]";
48 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
50 if ((parameters.empty()) || (irc::equals(parameters[0], ServerInstance->Config->ServerName)))
51 ShowOperMOTD(user, true);
55 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
57 if ((!parameters.empty()) && (parameters[0].find('.') != std::string::npos))
58 return ROUTE_OPT_UCAST(parameters[0]);
59 return ROUTE_LOCALONLY;
62 void ShowOperMOTD(User* user, bool show_missing)
67 user->WriteRemoteNumeric(ERR_NOOPERMOTD, "OPERMOTD file is missing.");
71 user->WriteRemoteNumeric(RPL_OMOTDSTART, "Server operators message of the day");
73 for (file_cache::const_iterator i = opermotd.begin(); i != opermotd.end(); ++i)
75 user->WriteRemoteNumeric(RPL_OMOTD, InspIRCd::Format("- %s", i->c_str()));
78 user->WriteRemoteNumeric(RPL_ENDOFOMOTD, "End of OPERMOTD");
83 class ModuleOpermotd : public Module
94 Version GetVersion() CXX11_OVERRIDE
96 return Version("Shows a message to opers after oper-up and adds the OPERMOTD command", VF_VENDOR | VF_OPTCOMMON);
99 void OnOper(User* user, const std::string &opertype) CXX11_OVERRIDE
101 if (onoper && IS_LOCAL(user))
102 cmd.ShowOperMOTD(user, false);
105 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
107 cmd.opermotd.clear();
108 ConfigTag* conf = ServerInstance->Config->ConfValue("opermotd");
109 onoper = conf->getBool("onoper", true);
113 FileReader reader(conf->getString("file", "opermotd"));
114 cmd.opermotd = reader.GetVector();
115 InspIRCd::ProcessColors(cmd.opermotd);
117 catch (CoreException&)
119 // Nothing happens here as we do the error handling in ShowOperMOTD.
124 MODULE_INIT(ModuleOpermotd)