1 // opermotd module by typobox43
12 /* $ModDesc: Shows a message to opers after oper-up, adds /opermotd */
14 static FileReader* opermotd;
16 CmdResult ShowOperMOTD(userrec* user)
18 if(!opermotd->FileSize())
20 user->WriteServ(std::string("425 ") + user->nick + std::string(" :OPERMOTD file is missing"));
23 user->WriteServ(std::string("375 ") + user->nick + std::string(" :- IRC Operators Message of the Day"));
24 for(int i=0; i != opermotd->FileSize(); i++)
26 user->WriteServ(std::string("372 ") + user->nick + std::string(" :- ") + opermotd->GetLine(i));
28 user->WriteServ(std::string("376 ") + user->nick + std::string(" :- End of OPERMOTD"));
35 class cmd_opermotd : public command_t
38 cmd_opermotd (InspIRCd* Instance) : command_t(Instance,"OPERMOTD", 'o', 0)
40 this->source = "m_opermotd.so";
41 syntax = "[<servername>]";
44 CmdResult Handle (const char** parameters, int pcnt, userrec* user)
46 return ShowOperMOTD(user);
51 class ModuleOpermotd : public Module
53 cmd_opermotd* mycommand;
58 ConfigReader* conf = new ConfigReader(ServerInstance);
60 filename = conf->ReadValue("opermotd","file",0);
66 opermotd = new FileReader(ServerInstance, filename);
70 ModuleOpermotd(InspIRCd* Me)
74 mycommand = new cmd_opermotd(ServerInstance);
75 ServerInstance->AddCommand(mycommand);
76 opermotd = new FileReader(ServerInstance);
80 virtual ~ModuleOpermotd()
84 virtual Version GetVersion()
86 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
89 void Implements(char* List)
91 List[I_OnRehash] = List[I_OnOper] = 1;
94 virtual void OnOper(userrec* user, const std::string &opertype)
99 virtual void OnRehash(const std::string ¶meter)
105 class ModuleOpermotdFactory : public ModuleFactory
108 ModuleOpermotdFactory()
112 ~ModuleOpermotdFactory()
116 virtual Module* CreateModule(InspIRCd* Me)
118 return new ModuleOpermotd(Me);
122 extern "C" void* init_module(void)
124 return new ModuleOpermotdFactory;