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);
51 void Implements(char* List)
53 List[I_OnPostOper] = List[I_OnRehash] = 1;
56 virtual void OnRehash(User* user, const std::string ¶meter)
58 ConfigReader* conf = new ConfigReader(ServerInstance);
60 operChan = conf->ReadValue("operjoin", "channel", 0);
62 if (!operChan.empty())
63 tokenize(operChan,operChans);
68 virtual ~ModuleOperjoin()
72 virtual Version GetVersion()
74 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
77 virtual void OnPostOper(User* user, const std::string &opertype)
82 for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
83 if (ServerInstance->IsChannel(it->c_str()))
84 Channel::JoinUser(ServerInstance, user, it->c_str(), false, "", ServerInstance->Time(true));
89 MODULE_INIT(ModuleOperjoin)