1 // opermotd module by typobox43
9 #include "helperfuncs.h"
12 /* $ModDesc: Shows a message to opers after oper-up, adds /opermotd */
14 static FileReader* opermotd;
19 ConfigReader* conf = new ConfigReader;
22 filename = conf->ReadValue("opermotd","file",0);
24 opermotd->LoadFile(filename);
28 void ShowOperMOTD(userrec* user)
30 if(!opermotd->FileSize())
32 user->WriteServ(std::string("425 ") + user->nick + std::string(" :OPERMOTD file is missing"));
36 user->WriteServ(std::string("375 ") + user->nick + std::string(" :- IRC Operators Message of the Day"));
38 for(int i=0; i != opermotd->FileSize(); i++)
40 user->WriteServ(std::string("372 ") + user->nick + std::string(" :- ") + opermotd->GetLine(i));
43 user->WriteServ(std::string("376 ") + user->nick + std::string(" :- End of OPERMOTD"));
47 class cmd_opermotd : public command_t
50 cmd_opermotd () : command_t("OPERMOTD", 'o', 0)
52 this->source = "m_opermotd.so";
53 syntax = "[<servername>]";
56 void Handle (const char** parameters, int pcnt, userrec* user)
62 class ModuleOpermotd : public Module
64 cmd_opermotd* mycommand;
66 ModuleOpermotd(InspIRCd* Me)
70 mycommand = new cmd_opermotd();
71 Srv->AddCommand(mycommand);
72 opermotd = new FileReader();
76 virtual ~ModuleOpermotd()
80 virtual Version GetVersion()
82 return Version(1,0,0,1,VF_VENDOR);
85 void Implements(char* List)
87 List[I_OnRehash] = List[I_OnOper] = 1;
90 virtual void OnOper(userrec* user, const std::string &opertype)
95 virtual void OnRehash(const std::string ¶meter)
102 class ModuleOpermotdFactory : public ModuleFactory
105 ModuleOpermotdFactory()
109 ~ModuleOpermotdFactory()
113 virtual Module* CreateModule(InspIRCd* Me)
115 return new ModuleOpermotd(Me);
120 extern "C" void* init_module(void)
122 return new ModuleOpermotdFactory;