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/>.
25 /* $ModDesc: Shows a message to opers after oper-up, adds /opermotd */
27 static FileReader* opermotd;
29 CmdResult ShowOperMOTD(User* user)
31 if(!opermotd->FileSize())
33 user->WriteServ(std::string("425 ") + user->nick + std::string(" :OPERMOTD file is missing"));
37 user->WriteServ(std::string("375 ") + user->nick + std::string(" :- IRC Operators Message of the Day"));
39 for(int i=0; i != opermotd->FileSize(); i++)
41 user->WriteServ(std::string("372 ") + user->nick + std::string(" :- ") + opermotd->GetLine(i));
44 user->WriteServ(std::string("376 ") + user->nick + std::string(" :- End of OPERMOTD"));
52 class CommandOpermotd : public Command
55 CommandOpermotd(Module* Creator) : Command(Creator,"OPERMOTD", 0)
57 flags_needed = 'o'; syntax = "[<servername>]";
60 CmdResult Handle (const std::vector<std::string>& parameters, User* user)
62 return ShowOperMOTD(user);
67 class ModuleOpermotd : public Module
75 ConfigTag* conf = ServerInstance->Config->ConfValue("opermotd");
76 opermotd->LoadFile(conf->getString("file","opermotd"));
77 onoper = conf->getBool("onoper", true);
84 ServerInstance->AddCommand(&cmd);
85 opermotd = new FileReader;
87 Implementation eventlist[] = { I_OnRehash, I_OnOper };
88 ServerInstance->Modules->Attach(eventlist, this, 2);
91 virtual ~ModuleOpermotd()
97 virtual Version GetVersion()
99 return Version("Shows a message to opers after oper-up, adds /opermotd", VF_VENDOR);
102 virtual void OnOper(User* user, const std::string &opertype)
108 virtual void OnRehash(User* user)
114 MODULE_INIT(ModuleOpermotd)