/*
* InspIRCd -- Internet Relay Chat Daemon
*
- * Copyright (C) 2016 Attila Molnar <attilamolnar@hush.com>
+ * Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
+ * Copyright (C) 2018 linuxdaemon <linuxdaemon.irc@gmail.com>
+ * Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
+ * Copyright (C) 2018 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
void Load()
{
- rankstosee.clear();
+ RanksToSeeMap newranks;
ConfigTagList tags = ServerInstance->Config->ConfTags("hidemode");
for (ConfigIter i = tags.first; i != tags.second; ++i)
{
ConfigTag* tag = i->second;
- std::string modename = tag->getString("mode");
- unsigned int rank = tag->getInt("rank", 0, 0);
- if (!modename.empty() && rank)
- {
- ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Hiding the %s mode from users below rank %u", modename.c_str(), rank);
- rankstosee.insert(std::make_pair(modename, rank));
- }
+ const std::string modename = tag->getString("mode");
+ if (modename.empty())
+ throw ModuleException("<hidemode:mode> is empty at " + tag->getTagLocation());
+
+ unsigned int rank = tag->getUInt("rank", 0);
+ if (!rank)
+ throw ModuleException("<hidemode:rank> must be greater than 0 at " + tag->getTagLocation());
+
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Hiding the %s mode from users below rank %u", modename.c_str(), rank);
+ newranks.insert(std::make_pair(modename, rank));
}
+ rankstosee.swap(newranks);
}
};
const Modes::Change& curr = *i;
if (settings.GetRequiredRank(*curr.mh) <= rank)
{
- // No restriction on who can see this mode or there is one but the member's rank is sufficient
+ // No restriction on who can see this mode or there is one but the member's rank is sufficient
if (modechangelist)
modechangelist->push(curr);
if (!chan)
return MOD_RES_PASSTHRU;
+ if (user->HasPrivPermission("channels/auspex"))
+ return MOD_RES_PASSTHRU;
+
Membership* const memb = chan->GetUser(user);
if (!memb)
return MOD_RES_PASSTHRU;
Version GetVersion() CXX11_OVERRIDE
{
- return Version("Provides support for hiding mode changes", VF_VENDOR);
+ return Version("Allows mode changes to be hidden from users without a prefix mode ranked equal to or higher than a defined level.", VF_VENDOR);
}
};