1 // opermotd module by typobox43
9 #include "helperfuncs.h"
11 /* $ModDesc: Shows a message to opers after oper-up, adds /opermotd */
13 static FileReader* opermotd;
18 ConfigReader* conf = new ConfigReader;
21 filename = conf->ReadValue("opermotd","file",0);
23 opermotd->LoadFile(filename);
27 void ShowOperMOTD(userrec* user)
29 if(!opermotd->FileSize())
31 Srv->SendServ(user->fd,std::string("425 ") + user->nick + std::string(" :OPERMOTD file is missing"));
35 Srv->SendServ(user->fd,std::string("375 ") + user->nick + std::string(" :- IRC Operators Message of the Day"));
37 for(int i=0; i != opermotd->FileSize(); i++)
39 Srv->SendServ(user->fd,std::string("372 ") + user->nick + std::string(" :- ") + opermotd->GetLine(i));
42 Srv->SendServ(user->fd,std::string("376 ") + user->nick + std::string(" :- End of OPERMOTD"));
46 class cmd_opermotd : public command_t
49 cmd_opermotd () : command_t("OPERMOTD", 'o', 0)
51 this->source = "m_opermotd.so";
54 void Handle (char** parameters, int pcnt, userrec* user)
60 class ModuleOpermotd : public Module
62 cmd_opermotd* mycommand;
64 ModuleOpermotd(Server* Me)
68 mycommand = new cmd_opermotd();
69 Srv->AddCommand(mycommand);
70 opermotd = new FileReader();
74 virtual ~ModuleOpermotd()
78 virtual Version GetVersion()
80 return Version(1,0,0,1,VF_VENDOR);
83 void Implements(char* List)
85 List[I_OnRehash] = List[I_OnOper] = 1;
88 virtual void OnOper(userrec* user, std::string opertype)
93 virtual void OnRehash(std::string parameter)
100 class ModuleOpermotdFactory : public ModuleFactory
103 ModuleOpermotdFactory()
107 ~ModuleOpermotdFactory()
111 virtual Module* CreateModule(Server* Me)
113 return new ModuleOpermotd(Me);
118 extern "C" void* init_module(void)
120 return new ModuleOpermotdFactory;