2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 class ListWatcher : public ModeWatcher
25 ListWatcher(Module* mod, const std::string& modename)
26 : ModeWatcher(mod, modename, MODETYPE_CHANNEL)
30 bool BeforeMode(User* user, User* destuser, Channel* chan, std::string& param, bool adding)
32 // Only handle listmode list requests
36 // If the user requesting the list is a member of the channel see if they have the
37 // rank required to view the list
38 Membership* memb = chan->GetUser(user);
39 if ((memb) && (memb->getRank() >= HALFOP_VALUE))
42 if (user->HasPrivPermission("channels/auspex"))
45 user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have access to view the %s list", chan->name.c_str(), GetModeName().c_str());
50 class ModuleHideList : public Module
52 std::vector<ListWatcher*> watchers;
55 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
57 stdalgo::delete_all(watchers);
60 ConfigTagList tags = ServerInstance->Config->ConfTags("hidelist");
61 for (ConfigIter i = tags.first; i != tags.second; ++i)
63 ConfigTag* tag = i->second;
64 std::string modename = tag->getString("mode");
65 watchers.push_back(new ListWatcher(this, modename));
71 stdalgo::delete_all(watchers);
74 Version GetVersion() CXX11_OVERRIDE
76 return Version("Provides support for hiding the list of listmodes", VF_VENDOR);
80 MODULE_INIT(ModuleHideList)