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;
29 int tokenize(const string &str, std::vector<std::string> &tokens)
31 // skip delimiters at beginning.
32 string::size_type lastPos = str.find_first_not_of(",", 0);
33 // find first "non-delimiter".
34 string::size_type pos = str.find_first_of(",", lastPos);
36 while (string::npos != pos || string::npos != lastPos)
38 // found a token, add it to the vector.
39 tokens.push_back(str.substr(lastPos, pos - lastPos));
40 // skip delimiters. Note the "not_of"
41 lastPos = str.find_first_not_of(",", pos);
42 // find next "non-delimiter"
43 pos = str.find_first_of(",", lastPos);
49 ModuleOperjoin(InspIRCd* Me)
53 conf = new ConfigReader(ServerInstance);
54 operChan = conf->ReadValue("operjoin", "channel", 0);
56 if (!operChan.empty())
57 tokenize(operChan,operChans);
60 void Implements(char* List)
62 List[I_OnPostOper] = List[I_OnRehash] = 1;
65 virtual void OnRehash(userrec* user, const std::string ¶meter)
68 conf = new ConfigReader(ServerInstance);
69 operChan = conf->ReadValue("operjoin", "channel", 0);
71 if (!operChan.empty())
72 tokenize(operChan,operChans);
75 virtual ~ModuleOperjoin()
80 virtual Version GetVersion()
82 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
85 virtual void OnPostOper(userrec* user, const std::string &opertype)
90 for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
91 if (ServerInstance->IsChannel(it->c_str()))
92 chanrec::JoinUser(ServerInstance, user, it->c_str(), false);
97 class ModuleOperjoinFactory : public ModuleFactory
100 ModuleOperjoinFactory()
104 ~ModuleOperjoinFactory()
108 virtual Module * CreateModule(InspIRCd* Me)
110 return new ModuleOperjoin(Me);
114 extern "C" void * init_module( void )
116 return new ModuleOperjoinFactory;