1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 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 (InspIRCd* Instance) : Command(Instance,"OPERMOTD", "o", 0)
48 this->source = "m_opermotd.so";
49 syntax = "[<servername>]";
52 CmdResult Handle (const std::vector<std::string>& parameters, User* user)
54 return ShowOperMOTD(user);
59 class ModuleOpermotd : public Module
61 CommandOpermotd* mycommand;
67 ConfigReader* conf = new ConfigReader(ServerInstance);
69 filename = conf->ReadValue("opermotd","file",0);
75 opermotd = new FileReader(ServerInstance, filename);
76 onoper = conf->ReadFlag("opermotd","onoper","yes",0);
80 ModuleOpermotd(InspIRCd* Me)
84 mycommand = new CommandOpermotd(ServerInstance);
85 ServerInstance->AddCommand(mycommand);
86 opermotd = new FileReader(ServerInstance);
88 Implementation eventlist[] = { I_OnRehash, I_OnOper };
89 ServerInstance->Modules->Attach(eventlist, this, 2);
92 virtual ~ModuleOpermotd()
96 virtual Version GetVersion()
98 return Version("$Id$", VF_VENDOR, API_VERSION);
102 virtual void OnOper(User* user, const std::string &opertype)
108 virtual void OnRehash(User* user, const std::string ¶meter)
114 MODULE_INIT(ModuleOpermotd)