1 // opermotd module by typobox43
12 /* $ModDesc: Shows a message to opers after oper-up, adds /opermotd */
14 static FileReader* opermotd;
16 CmdResult 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"));
33 class cmd_opermotd : public command_t
36 cmd_opermotd (InspIRCd* Instance) : command_t(Instance,"OPERMOTD", 'o', 0)
38 this->source = "m_opermotd.so";
39 syntax = "[<servername>]";
42 CmdResult Handle (const char** parameters, int pcnt, userrec* user)
44 return ShowOperMOTD(user);
49 class ModuleOpermotd : public Module
51 cmd_opermotd* mycommand;
56 ConfigReader* conf = new ConfigReader(ServerInstance);
58 filename = conf->ReadValue("opermotd","file",0);
64 opermotd = new FileReader(ServerInstance, filename);
68 ModuleOpermotd(InspIRCd* Me)
72 mycommand = new cmd_opermotd(ServerInstance);
73 ServerInstance->AddCommand(mycommand);
74 opermotd = new FileReader(ServerInstance);
78 virtual ~ModuleOpermotd()
82 virtual Version GetVersion()
84 return Version(1,0,0,1,VF_VENDOR,API_VERSION);
87 void Implements(char* List)
89 List[I_OnRehash] = List[I_OnOper] = 1;
92 virtual void OnOper(userrec* user, const std::string &opertype)
97 virtual void OnRehash(const std::string ¶meter)
103 class ModuleOpermotdFactory : public ModuleFactory
106 ModuleOpermotdFactory()
110 ~ModuleOpermotdFactory()
114 virtual Module* CreateModule(InspIRCd* Me)
116 return new ModuleOpermotd(Me);
120 extern "C" void* init_module(void)
122 return new ModuleOpermotdFactory;