1 // opermotd module by typobox43
12 /* $ModDesc: Shows a message to opers after oper-up, adds /opermotd */
14 static FileReader* opermotd;
16 void ShowOperMOTD(userrec* user)
18 if(!opermotd->FileSize())
20 user->WriteServ(std::string("425 ") + user->nick + std::string(" :OPERMOTD file is missing"));
23 user->WriteServ(std::string("375 ") + user->nick + std::string(" :- IRC Operators Message of the Day"));
24 for(int i=0; i != opermotd->FileSize(); i++)
26 user->WriteServ(std::string("372 ") + user->nick + std::string(" :- ") + opermotd->GetLine(i));
28 user->WriteServ(std::string("376 ") + user->nick + std::string(" :- End of OPERMOTD"));
31 class cmd_opermotd : public command_t
34 cmd_opermotd (InspIRCd* Instance) : command_t(Instance,"OPERMOTD", 'o', 0)
36 this->source = "m_opermotd.so";
37 syntax = "[<servername>]";
40 void Handle (const char** parameters, int pcnt, userrec* user)
47 class ModuleOpermotd : public Module
49 cmd_opermotd* mycommand;
54 ConfigReader* conf = new ConfigReader(ServerInstance);
56 filename = conf->ReadValue("opermotd","file",0);
62 opermotd = new FileReader(ServerInstance, filename);
66 ModuleOpermotd(InspIRCd* Me)
70 mycommand = new cmd_opermotd(ServerInstance);
71 ServerInstance->AddCommand(mycommand);
72 opermotd = new FileReader(ServerInstance);
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)
101 class ModuleOpermotdFactory : public ModuleFactory
104 ModuleOpermotdFactory()
108 ~ModuleOpermotdFactory()
112 virtual Module* CreateModule(InspIRCd* Me)
114 return new ModuleOpermotd(Me);
118 extern "C" void* init_module(void)
120 return new ModuleOpermotdFactory;