1 // operjoin module by typobox43
11 /* $ModDesc: Forces opers to join the specified channel(s) on oper-up */
15 class ModuleOperjoin : public Module
22 int tokenize(const string &str, std::vector<std::string> &tokens)
24 // skip delimiters at beginning.
25 string::size_type lastPos = str.find_first_not_of(",", 0);
26 // find first "non-delimiter".
27 string::size_type pos = str.find_first_of(",", lastPos);
29 while (string::npos != pos || string::npos != lastPos)
31 // found a token, add it to the vector.
32 tokens.push_back(str.substr(lastPos, pos - lastPos));
33 // skip delimiters. Note the "not_of"
34 lastPos = str.find_first_not_of(",", pos);
35 // find next "non-delimiter"
36 pos = str.find_first_of(",", lastPos);
42 ModuleOperjoin(InspIRCd* Me)
46 conf = new ConfigReader(ServerInstance);
47 operChan = conf->ReadValue("operjoin", "channel", 0);
50 void Implements(char* List)
52 List[I_OnPostOper] = List[I_OnRehash] = 1;
55 virtual void OnRehash(const std::string ¶meter)
58 conf = new ConfigReader(ServerInstance);
61 virtual ~ModuleOperjoin()
66 virtual Version GetVersion()
68 return Version(1,0,0,1,VF_VENDOR);
71 virtual void OnPostOper(userrec* user, const std::string &opertype)
75 std::vector<std::string> operChans;
76 tokenize(operChan,operChans);
77 for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
78 chanrec::JoinUser(ServerInstance, user, it->c_str(), false);
85 class ModuleOperjoinFactory : public ModuleFactory
88 ModuleOperjoinFactory()
92 ~ModuleOperjoinFactory()
96 virtual Module * CreateModule(InspIRCd* Me)
98 return new ModuleOperjoin(Me);
102 extern "C" void * init_module( void )
104 return new ModuleOperjoinFactory;