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/>.
27 class CommandOpermotd : public Command
32 CommandOpermotd(Module* Creator) : Command(Creator,"OPERMOTD", 0, 1)
34 flags_needed = 'o'; syntax = "[<servername>]";
37 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
39 if ((parameters.empty()) || (parameters[0] == ServerInstance->Config->ServerName))
44 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
46 if ((!parameters.empty()) && (parameters[0].find('.') != std::string::npos))
47 return ROUTE_OPT_UCAST(parameters[0]);
48 return ROUTE_LOCALONLY;
51 void ShowOperMOTD(User* user)
55 user->WriteRemoteNumeric(455, "OPERMOTD file is missing");
59 user->WriteRemoteNumeric(RPL_MOTDSTART, "- IRC Operators Message of the Day");
61 for (file_cache::const_iterator i = opermotd.begin(); i != opermotd.end(); ++i)
63 user->WriteRemoteNumeric(RPL_MOTD, InspIRCd::Format("- %s", i->c_str()));
66 user->WriteRemoteNumeric(RPL_ENDOFMOTD, "- End of OPERMOTD");
71 class ModuleOpermotd : public Module
82 Version GetVersion() CXX11_OVERRIDE
84 return Version("Shows a message to opers after oper-up, adds /opermotd", VF_VENDOR | VF_OPTCOMMON);
87 void OnOper(User* user, const std::string &opertype) CXX11_OVERRIDE
89 if (onoper && IS_LOCAL(user))
90 cmd.ShowOperMOTD(user);
93 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
96 ConfigTag* conf = ServerInstance->Config->ConfValue("opermotd");
97 onoper = conf->getBool("onoper", true);
101 FileReader reader(conf->getString("file", "opermotd"));
102 cmd.opermotd = reader.GetVector();
103 InspIRCd::ProcessColors(cmd.opermotd);
105 catch (CoreException&)
107 // Nothing happens here as we do the error handling in ShowOperMOTD.
112 MODULE_INIT(ModuleOpermotd)