1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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;
25 int tokenize(const std::string &str, std::vector<std::string> &tokens)
27 // skip delimiters at beginning.
28 std::string::size_type lastPos = str.find_first_not_of(",", 0);
29 // find first "non-delimiter".
30 std::string::size_type pos = str.find_first_of(",", lastPos);
32 while (std::string::npos != pos || std::string::npos != lastPos)
34 // found a token, add it to the vector.
35 tokens.push_back(str.substr(lastPos, pos - lastPos));
36 // skip delimiters. Note the "not_of"
37 lastPos = str.find_first_not_of(",", pos);
38 // find next "non-delimiter"
39 pos = str.find_first_of(",", lastPos);
45 ModuleOperjoin(InspIRCd* Me) : Module(Me)
48 Implementation eventlist[] = { I_OnPostOper, I_OnRehash };
49 ServerInstance->Modules->Attach(eventlist, this, 2);
53 virtual void OnRehash(User* user, const std::string ¶meter)
55 ConfigReader* conf = new ConfigReader(ServerInstance);
57 operChan = conf->ReadValue("operjoin", "channel", 0);
58 override = conf->ReadFlag("operjoin", "override", "0", 0);
60 if (!operChan.empty())
61 tokenize(operChan,operChans);
66 virtual ~ModuleOperjoin()
70 virtual Version GetVersion()
72 return Version(1,2,0,1,VF_VENDOR,API_VERSION);
75 virtual void OnPostOper(User* user, const std::string &opertype, const std::string &opername)
80 for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
81 if (ServerInstance->IsChannel(it->c_str()))
82 Channel::JoinUser(ServerInstance, user, it->c_str(), override, "", false, ServerInstance->Time());
87 MODULE_INIT(ModuleOperjoin)