1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides support for hiding oper status with user mode +H */
18 /** Handles user mode +H
20 class HideOper : public ModeHandler
23 HideOper(Module* Creator) : ModeHandler(Creator, "hideoper", 'H', PARAM_NONE, MODETYPE_USER)
28 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
32 if (!dest->IsModeSet('H'))
34 dest->SetMode('H',true);
35 return MODEACTION_ALLOW;
40 if (dest->IsModeSet('H'))
42 dest->SetMode('H',false);
43 return MODEACTION_ALLOW;
47 return MODEACTION_DENY;
51 class ModuleHideOper : public Module
58 if (!ServerInstance->Modes->AddMode(&hm))
59 throw ModuleException("Could not add new modes!");
60 Implementation eventlist[] = { I_OnWhoisLine, I_OnSendWhoLine };
61 ServerInstance->Modules->Attach(eventlist, this, 2);
65 virtual ~ModuleHideOper()
69 virtual Version GetVersion()
71 return Version("Provides support for hiding oper status with user mode +H", VF_VENDOR);
74 ModResult OnWhoisLine(User* user, User* dest, int &numeric, std::string &text)
76 /* Dont display numeric 313 (RPL_WHOISOPER) if they have +H set and the
77 * person doing the WHOIS is not an oper
80 return MOD_RES_PASSTHRU;
82 if (!dest->IsModeSet('H'))
83 return MOD_RES_PASSTHRU;
85 if (!user->HasPrivPermission("users/auspex"))
88 return MOD_RES_PASSTHRU;
91 void OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, std::string& line)
93 if (user->IsModeSet('H') && !source->HasPrivPermission("users/auspex"))
95 // hide the "*" that marks the user as an oper from the /WHO line
96 std::string::size_type pos = line.find("* ");
97 if (pos != std::string::npos)
99 // hide the line completely if doing a "/who * o" query
100 if (params.size() > 1 && params[1].find('o') != std::string::npos)
107 MODULE_INIT(ModuleHideOper)