]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_operjoin.cpp
Merge insp20
[user/henk/code/inspircd.git] / src / modules / m_operjoin.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
5  *   Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
6  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
7  *   Copyright (C) 2005-2007 Robin Burchell <robin+git@viroteck.net>
8  *   Copyright (C) 2006-2007 Craig Edwards <craigedwards@brainbox.cc>
9  *   Copyright (C) 2004 Christopher Hall <typobox43@gmail.com>
10  *
11  * This file is part of InspIRCd.  InspIRCd is free software: you can
12  * redistribute it and/or modify it under the terms of the GNU General Public
13  * License as published by the Free Software Foundation, version 2.
14  *
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  */
23
24
25 #include "inspircd.h"
26
27 class ModuleOperjoin : public Module
28 {
29                 std::vector<std::string> operChans;
30                 bool override;
31
32         public:
33                 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
34                 {
35                         ConfigTag* tag = ServerInstance->Config->ConfValue("operjoin");
36
37                         override = tag->getBool("override", false);
38                         irc::commasepstream ss(tag->getString("channel"));
39                         operChans.clear();
40
41                         for (std::string channame; ss.GetToken(channame); )
42                                 operChans.push_back(channame);
43                 }
44
45                 Version GetVersion() CXX11_OVERRIDE
46                 {
47                         return Version("Forces opers to join the specified channel(s) on oper-up", VF_VENDOR);
48                 }
49
50                 void OnPostOper(User* user, const std::string &opertype, const std::string &opername) CXX11_OVERRIDE
51                 {
52                         LocalUser* localuser = IS_LOCAL(user);
53                         if (!localuser)
54                                 return;
55
56                         for (std::vector<std::string>::const_iterator i = operChans.begin(); i != operChans.end(); ++i)
57                                 if (ServerInstance->IsChannel(*i))
58                                         Channel::JoinUser(localuser, *i, override);
59
60                         irc::commasepstream ss(localuser->oper->getConfig("autojoin"));
61                         for (std::string channame; ss.GetToken(channame); )
62                         {
63                                 if (ServerInstance->IsChannel(channame))
64                                         Channel::JoinUser(localuser, channame, override);
65                         }
66                 }
67 };
68
69 MODULE_INIT(ModuleOperjoin)