1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/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;
66 ConfigReader* conf = new ConfigReader(ServerInstance);
68 filename = conf->ReadValue("opermotd","file",0);
74 opermotd = new FileReader(ServerInstance, filename);
78 ModuleOpermotd(InspIRCd* Me)
82 mycommand = new CommandOpermotd(ServerInstance);
83 ServerInstance->AddCommand(mycommand);
84 opermotd = new FileReader(ServerInstance);
86 Implementation eventlist[] = { I_OnRehash, I_OnOper };
87 ServerInstance->Modules->Attach(eventlist, this, 2);
90 virtual ~ModuleOpermotd()
94 virtual Version GetVersion()
96 return Version(1,2,0,1,VF_VENDOR,API_VERSION);
100 virtual void OnOper(User* user, const std::string &opertype)
105 virtual void OnRehash(User* user, const std::string ¶meter)
111 MODULE_INIT(ModuleOpermotd)