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 * ---------------------------------------------------
19 /* $ModDesc: Forces opers to join the specified channel(s) on oper-up */
21 class ModuleOperjoin : public Module
25 std::vector<std::string> operChans;
27 int tokenize(const string &str, std::vector<std::string> &tokens)
29 // skip delimiters at beginning.
30 string::size_type lastPos = str.find_first_not_of(",", 0);
31 // find first "non-delimiter".
32 string::size_type pos = str.find_first_of(",", lastPos);
34 while (string::npos != pos || string::npos != lastPos)
36 // found a token, add it to the vector.
37 tokens.push_back(str.substr(lastPos, pos - lastPos));
38 // skip delimiters. Note the "not_of"
39 lastPos = str.find_first_not_of(",", pos);
40 // find next "non-delimiter"
41 pos = str.find_first_of(",", lastPos);
47 ModuleOperjoin(InspIRCd* Me) : Module(Me)
52 void Implements(char* List)
54 List[I_OnPostOper] = List[I_OnRehash] = 1;
57 virtual void OnRehash(userrec* user, const std::string ¶meter)
59 ConfigReader* conf = new ConfigReader(ServerInstance);
61 operChan = conf->ReadValue("operjoin", "channel", 0);
63 if (!operChan.empty())
64 tokenize(operChan,operChans);
69 virtual ~ModuleOperjoin()
73 virtual Version GetVersion()
75 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
78 virtual void OnPostOper(userrec* user, const std::string &opertype)
83 for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
84 if (ServerInstance->IsChannel(it->c_str()))
85 chanrec::JoinUser(ServerInstance, user, it->c_str(), false, "", ServerInstance->Time(true));
90 class ModuleOperjoinFactory : public ModuleFactory
93 ModuleOperjoinFactory()
97 ~ModuleOperjoinFactory()
101 virtual Module * CreateModule(InspIRCd* Me)
103 return new ModuleOperjoin(Me);
107 extern "C" DllExport void * init_module( void )
109 return new ModuleOperjoinFactory;