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 * ---------------------------------------------------
16 /* $ModDesc: Forces opers to join the specified channel(s) on oper-up */
18 class ModuleOperjoin : public Module
22 std::vector<std::string> operChans;
24 int tokenize(const string &str, std::vector<std::string> &tokens)
26 // skip delimiters at beginning.
27 string::size_type lastPos = str.find_first_not_of(",", 0);
28 // find first "non-delimiter".
29 string::size_type pos = str.find_first_of(",", lastPos);
31 while (string::npos != pos || string::npos != lastPos)
33 // found a token, add it to the vector.
34 tokens.push_back(str.substr(lastPos, pos - lastPos));
35 // skip delimiters. Note the "not_of"
36 lastPos = str.find_first_not_of(",", pos);
37 // find next "non-delimiter"
38 pos = str.find_first_of(",", lastPos);
44 ModuleOperjoin(InspIRCd* Me) : Module(Me)
49 void Implements(char* List)
51 List[I_OnPostOper] = List[I_OnRehash] = 1;
54 virtual void OnRehash(userrec* user, const std::string ¶meter)
56 ConfigReader* conf = new ConfigReader(ServerInstance);
58 operChan = conf->ReadValue("operjoin", "channel", 0);
60 if (!operChan.empty())
61 tokenize(operChan,operChans);
66 virtual ~ModuleOperjoin()
70 virtual Version GetVersion()
72 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
75 virtual void OnPostOper(userrec* user, const std::string &opertype)
80 for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
81 if (ServerInstance->IsChannel(it->c_str()))
82 chanrec::JoinUser(ServerInstance, user, it->c_str(), false, "", ServerInstance->Time(true));
87 MODULE_INIT(ModuleOperjoin)