diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-09-10 14:50:57 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-09-10 14:50:57 +0200 |
commit | c2fb4e4b9d7dc6f2ecc5d8f0054350ae8c9be986 (patch) | |
tree | 4409eeb12259e24652e27254ed42b8277dd86b72 /src | |
parent | 4ec37f1d2bf21f2edddec15e6d7c5570b37be214 (diff) |
Add m_hidelist that allows hiding the lists of listmodes
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_hidelist.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/modules/m_hidelist.cpp b/src/modules/m_hidelist.cpp new file mode 100644 index 000000000..f7a05ed0a --- /dev/null +++ b/src/modules/m_hidelist.cpp @@ -0,0 +1,80 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com> + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "inspircd.h" + +class ListWatcher : public ModeWatcher +{ + public: + ListWatcher(Module* mod, const std::string& modename) + : ModeWatcher(mod, modename, MODETYPE_CHANNEL) + { + } + + bool BeforeMode(User* user, User* destuser, Channel* chan, std::string& param, bool adding) + { + // Only handle listmode list requests + if (!param.empty()) + return true; + + // If the user requesting the list is a member of the channel see if they have the + // rank required to view the list + Membership* memb = chan->GetUser(user); + if ((memb) && (memb->getRank() >= HALFOP_VALUE)) + return true; + + if (user->HasPrivPermission("channels/auspex")) + return true; + + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have access to view the %s list", chan->name.c_str(), GetModeName().c_str()); + return false; + } +}; + +class ModuleHideList : public Module +{ + std::vector<ListWatcher*> watchers; + + public: + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE + { + stdalgo::delete_all(watchers); + watchers.clear(); + + ConfigTagList tags = ServerInstance->Config->ConfTags("hidelist"); + for (ConfigIter i = tags.first; i != tags.second; ++i) + { + ConfigTag* tag = i->second; + std::string modename = tag->getString("mode"); + watchers.push_back(new ListWatcher(this, modename)); + } + } + + ~ModuleHideList() + { + stdalgo::delete_all(watchers); + } + + Version GetVersion() CXX11_OVERRIDE + { + return Version("Provides support for hiding the list of listmodes", VF_VENDOR); + } +}; + +MODULE_INIT(ModuleHideList) |