1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
20 /* $ModDesc: Forces opers to join the specified channel(s) on oper-up */
24 class ModuleOperjoin : public Module
31 int tokenize(const string &str, std::vector<std::string> &tokens)
33 // skip delimiters at beginning.
34 string::size_type lastPos = str.find_first_not_of(",", 0);
35 // find first "non-delimiter".
36 string::size_type pos = str.find_first_of(",", lastPos);
38 while (string::npos != pos || string::npos != lastPos)
40 // found a token, add it to the vector.
41 tokens.push_back(str.substr(lastPos, pos - lastPos));
42 // skip delimiters. Note the "not_of"
43 lastPos = str.find_first_not_of(",", pos);
44 // find next "non-delimiter"
45 pos = str.find_first_of(",", lastPos);
51 ModuleOperjoin(InspIRCd* Me)
55 conf = new ConfigReader(ServerInstance);
56 operChan = conf->ReadValue("operjoin", "channel", 0);
59 void Implements(char* List)
61 List[I_OnPostOper] = List[I_OnRehash] = 1;
64 virtual void OnRehash(const std::string ¶meter)
67 conf = new ConfigReader(ServerInstance);
70 virtual ~ModuleOperjoin()
75 virtual Version GetVersion()
77 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
80 virtual void OnPostOper(userrec* user, const std::string &opertype)
84 std::vector<std::string> operChans;
85 tokenize(operChan,operChans);
86 for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
87 chanrec::JoinUser(ServerInstance, user, it->c_str(), false);
94 class ModuleOperjoinFactory : public ModuleFactory
97 ModuleOperjoinFactory()
101 ~ModuleOperjoinFactory()
105 virtual Module * CreateModule(InspIRCd* Me)
107 return new ModuleOperjoin(Me);
111 extern "C" void * init_module( void )
113 return new ModuleOperjoinFactory;