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)
47 Implementation eventlist[] = { I_OnPostOper, I_OnRehash };
48 ServerInstance->Modules->Attach(eventlist, this, 2);
52 virtual void OnRehash(User* user, const std::string ¶meter)
54 ConfigReader* conf = new ConfigReader(ServerInstance);
56 operChan = conf->ReadValue("operjoin", "channel", 0);
58 if (!operChan.empty())
59 tokenize(operChan,operChans);
64 virtual ~ModuleOperjoin()
68 virtual Version GetVersion()
70 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
73 virtual void OnPostOper(User* user, const std::string &opertype)
78 for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
79 if (ServerInstance->IsChannel(it->c_str()))
80 Channel::JoinUser(ServerInstance, user, it->c_str(), false, "", false, ServerInstance->Time(true));
85 MODULE_INIT(ModuleOperjoin)