2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
6 * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
8 * This file is part of InspIRCd. InspIRCd is free software: you can
9 * redistribute it and/or modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation, version 2.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 /* $ModDesc: Provides support for hiding oper status with user mode +H */
26 /** Handles user mode +H
28 class HideOper : public SimpleUserModeHandler
31 HideOper(Module* Creator) : SimpleUserModeHandler(Creator, "hideoper", 'H')
37 class ModuleHideOper : public Module
44 if (!ServerInstance->Modes->AddMode(&hm))
45 throw ModuleException("Could not add new modes!");
46 Implementation eventlist[] = { I_OnWhoisLine, I_OnSendWhoLine };
47 ServerInstance->Modules->Attach(eventlist, this, 2);
51 virtual ~ModuleHideOper()
55 virtual Version GetVersion()
57 return Version("Provides support for hiding oper status with user mode +H", VF_VENDOR);
60 ModResult OnWhoisLine(User* user, User* dest, int &numeric, std::string &text)
62 /* Dont display numeric 313 (RPL_WHOISOPER) if they have +H set and the
63 * person doing the WHOIS is not an oper
66 return MOD_RES_PASSTHRU;
68 if (!dest->IsModeSet('H'))
69 return MOD_RES_PASSTHRU;
71 if (!user->HasPrivPermission("users/auspex"))
74 return MOD_RES_PASSTHRU;
77 void OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, std::string& line)
79 if (user->IsModeSet('H') && !source->HasPrivPermission("users/auspex"))
81 // hide the "*" that marks the user as an oper from the /WHO line
82 std::string::size_type pos = line.find("*");
83 if (pos != std::string::npos)
85 // hide the line completely if doing a "/who * o" query
86 if (params.size() > 1 && params[1].find('o') != std::string::npos)
93 MODULE_INIT(ModuleHideOper)