1 // opermotd module by typobox43
9 #include "helperfuncs.h"
11 /* $ModDesc: Shows a message to opers after oper-up, adds /opermotd */
16 void do_opermotd(char** parameters, int pcnt, userrec* user);
20 ConfigReader* conf = new ConfigReader;
23 filename = conf->ReadValue("opermotd","file",0);
25 opermotd->LoadFile(filename);
29 void ShowOperMOTD(userrec* user) {
31 if(!opermotd->FileSize()) {
33 Srv->SendServ(user->fd,std::string("425 ") + user->nick + std::string(" :OPERMOTD file is missing"));
38 Srv->SendServ(user->fd,std::string("375 ") + user->nick + std::string(" :- IRC Operators Message of the Day"));
40 for(int i=0; i != opermotd->FileSize(); i++) {
42 Srv->SendServ(user->fd,std::string("372 ") + user->nick + std::string(" :- ") + opermotd->GetLine(i));
46 Srv->SendServ(user->fd,std::string("376 ") + user->nick + std::string(" :- End of OPERMOTD"));
50 void do_opermotd(char** parameters, int pcnt, userrec* user) {
56 class ModuleOpermotd : public Module {
64 Srv->AddCommand("OPERMOTD",do_opermotd,'o',0,"m_opermotd.so");
66 opermotd = new FileReader();
71 virtual ~ModuleOpermotd() {
77 virtual Version GetVersion() {
79 return Version(1,0,0,1,VF_VENDOR);
83 virtual void OnOper(userrec* user) {
89 virtual void OnRehash() {
97 class ModuleOpermotdFactory : public ModuleFactory {
101 ModuleOpermotdFactory() {
105 ~ModuleOpermotdFactory() {
109 virtual Module* CreateModule() {
111 return new ModuleOpermotd;
117 extern "C" void* init_module(void) {
119 return new ModuleOpermotdFactory;