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";
52 syntax = "[<servername>]";
55 void Handle (const char** parameters, int pcnt, userrec* user)
61 class ModuleOpermotd : public Module
63 cmd_opermotd* mycommand;
65 ModuleOpermotd(Server* Me)
69 mycommand = new cmd_opermotd();
70 Srv->AddCommand(mycommand);
71 opermotd = new FileReader();
75 virtual ~ModuleOpermotd()
79 virtual Version GetVersion()
81 return Version(1,0,0,1,VF_VENDOR);
84 void Implements(char* List)
86 List[I_OnRehash] = List[I_OnOper] = 1;
89 virtual void OnOper(userrec* user, const std::string &opertype)
94 virtual void OnRehash(const std::string ¶meter)
101 class ModuleOpermotdFactory : public ModuleFactory
104 ModuleOpermotdFactory()
108 ~ModuleOpermotdFactory()
112 virtual Module* CreateModule(Server* Me)
114 return new ModuleOpermotd(Me);
119 extern "C" void* init_module(void)
121 return new ModuleOpermotdFactory;