1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Shows a message to opers after oper-up, adds /opermotd */
18 static FileReader* opermotd;
20 CmdResult ShowOperMOTD(User* user)
22 if(!opermotd->FileSize())
24 user->WriteServ(std::string("425 ") + user->nick + std::string(" :OPERMOTD file is missing"));
28 user->WriteServ(std::string("375 ") + user->nick + std::string(" :- IRC Operators Message of the Day"));
30 for(int i=0; i != opermotd->FileSize(); i++)
32 user->WriteServ(std::string("372 ") + user->nick + std::string(" :- ") + opermotd->GetLine(i));
35 user->WriteServ(std::string("376 ") + user->nick + std::string(" :- End of OPERMOTD"));
43 class CommandOpermotd : public Command
46 CommandOpermotd(Module* Creator) : Command(Creator,"OPERMOTD", 0)
48 flags_needed = 'o'; syntax = "[<servername>]";
51 CmdResult Handle (const std::vector<std::string>& parameters, User* user)
53 return ShowOperMOTD(user);
58 class ModuleOpermotd : public Module
66 ConfigTag* conf = ServerInstance->Config->ConfValue("opermotd");
67 opermotd->LoadFile(conf->getString("file","opermotd"));
68 onoper = conf->getBool("onoper", true);
75 ServerInstance->AddCommand(&cmd);
76 opermotd = new FileReader;
78 Implementation eventlist[] = { I_OnRehash, I_OnOper };
79 ServerInstance->Modules->Attach(eventlist, this, 2);
82 virtual ~ModuleOpermotd()
88 virtual Version GetVersion()
90 return Version("Shows a message to opers after oper-up, adds /opermotd", VF_VENDOR);
93 virtual void OnOper(User* user, const std::string &opertype)
99 virtual void OnRehash(User* user)
105 MODULE_INIT(ModuleOpermotd)