1 // operjoin module by typobox43
8 #include "helperfuncs.h"
10 /* $ModDesc: Forces opers to join the specified channel(s) on oper-up */
12 class ModuleOperjoin : public Module
19 int tokenize(const string &str, std::vector<std::string> &tokens)
21 // skip delimiters at beginning.
22 string::size_type lastPos = str.find_first_not_of(",", 0);
23 // find first "non-delimiter".
24 string::size_type pos = str.find_first_of(",", lastPos);
26 while (string::npos != pos || string::npos != lastPos)
28 // found a token, add it to the vector.
29 tokens.push_back(str.substr(lastPos, pos - lastPos));
30 // skip delimiters. Note the "not_of"
31 lastPos = str.find_first_not_of(",", pos);
32 // find next "non-delimiter"
33 pos = str.find_first_of(",", lastPos);
39 ModuleOperjoin(Server* Me)
43 conf = new ConfigReader;
44 operChan = conf->ReadValue("operjoin", "channel", 0);
47 void Implements(char* List)
49 List[I_OnPostOper] = List[I_OnRehash] = 1;
52 virtual void OnRehash(const std::string ¶meter)
55 conf = new ConfigReader;
58 virtual ~ModuleOperjoin()
63 virtual Version GetVersion()
65 return Version(1,0,0,1,VF_VENDOR);
68 virtual void OnPostOper(userrec* user, const std::string &opertype)
72 std::vector<std::string> operChans;
73 tokenize(operChan,operChans);
74 for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
75 chanrec::JoinUser(user, it->c_str(), false);
82 class ModuleOperjoinFactory : public ModuleFactory
85 ModuleOperjoinFactory()
89 ~ModuleOperjoinFactory()
93 virtual Module * CreateModule(Server* Me)
95 return new ModuleOperjoin(Me);
99 extern "C" void * init_module( void )
101 return new ModuleOperjoinFactory;