1 // opermotd module by typobox43
7 #include "helperfuncs.h"
9 /* $ModDesc: Shows a message to opers after oper-up, adds /opermotd */
14 void do_opermotd(char** parameters, int pcnt, userrec* user);
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"));
36 Srv->SendServ(user->fd,std::string("375 ") + user->nick + std::string(" :- IRC Operators Message of the Day"));
38 for(int i=0; i != opermotd->FileSize(); i++) {
40 Srv->SendServ(user->fd,std::string("372 ") + user->nick + std::string(" :- ") + opermotd->GetLine(i));
44 Srv->SendServ(user->fd,std::string("376 ") + user->nick + std::string(" :- End of OPERMOTD"));
48 void do_opermotd(char** parameters, int pcnt, userrec* user) {
54 class ModuleOpermotd : public Module {
62 Srv->AddCommand("OPERMOTD",do_opermotd,'o',0,"m_opermotd.so");
64 opermotd = new FileReader();
69 virtual ~ModuleOpermotd() {
75 virtual Version GetVersion() {
77 return Version(1,0,0,1,VF_VENDOR);
81 virtual void OnOper(userrec* user) {
87 virtual void OnRehash() {
95 class ModuleOpermotdFactory : public ModuleFactory {
99 ModuleOpermotdFactory() {
103 ~ModuleOpermotdFactory() {
107 virtual Module* CreateModule() {
109 return new ModuleOpermotd;
115 extern "C" void* init_module(void) {
117 return new ModuleOpermotdFactory;