1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 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 * ---------------------------------------------------
21 /* $ModDesc: Shows a message to opers after oper-up, adds /opermotd */
23 static FileReader* opermotd;
25 CmdResult ShowOperMOTD(userrec* user)
27 if(!opermotd->FileSize())
29 user->WriteServ(std::string("425 ") + user->nick + std::string(" :OPERMOTD file is missing"));
32 user->WriteServ(std::string("375 ") + user->nick + std::string(" :- IRC Operators Message of the Day"));
33 for(int i=0; i != opermotd->FileSize(); i++)
35 user->WriteServ(std::string("372 ") + user->nick + std::string(" :- ") + opermotd->GetLine(i));
37 user->WriteServ(std::string("376 ") + user->nick + std::string(" :- End of OPERMOTD"));
44 class cmd_opermotd : public command_t
47 cmd_opermotd (InspIRCd* Instance) : command_t(Instance,"OPERMOTD", 'o', 0)
49 this->source = "m_opermotd.so";
50 syntax = "[<servername>]";
53 CmdResult Handle (const char** parameters, int pcnt, userrec* user)
55 return ShowOperMOTD(user);
60 class ModuleOpermotd : public Module
62 cmd_opermotd* mycommand;
67 ConfigReader* conf = new ConfigReader(ServerInstance);
69 filename = conf->ReadValue("opermotd","file",0);
75 opermotd = new FileReader(ServerInstance, filename);
79 ModuleOpermotd(InspIRCd* Me)
83 mycommand = new cmd_opermotd(ServerInstance);
84 ServerInstance->AddCommand(mycommand);
85 opermotd = new FileReader(ServerInstance);
89 virtual ~ModuleOpermotd()
93 virtual Version GetVersion()
95 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
98 void Implements(char* List)
100 List[I_OnRehash] = List[I_OnOper] = 1;
103 virtual void OnOper(userrec* user, const std::string &opertype)
108 virtual void OnRehash(userrec* user, const std::string ¶meter)
114 class ModuleOpermotdFactory : public ModuleFactory
117 ModuleOpermotdFactory()
121 ~ModuleOpermotdFactory()
125 virtual Module* CreateModule(InspIRCd* Me)
127 return new ModuleOpermotd(Me);
131 extern "C" void* init_module(void)
133 return new ModuleOpermotdFactory;