2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2005, 2008 Robin Burchell <robin+git@viroteck.net>
6 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
7 * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
8 * Copyright (C) 2004 Christopher Hall <typobox43@gmail.com>
10 * This file is part of InspIRCd. InspIRCd is free software: you can
11 * redistribute it and/or modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation, version 2.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 /* $ModDesc: Allows opers to set +W to see when a user uses WHOIS on them */
28 /** Handle user mode +W
30 class SeeWhois : public SimpleUserModeHandler
33 SeeWhois(Module* Creator, bool IsOpersOnly) : SimpleUserModeHandler(Creator, "showwhois", 'W')
39 class WhoisNoticeCmd : public Command
42 WhoisNoticeCmd(Module* Creator) : Command(Creator,"WHOISNOTICE", 1)
44 flags_needed = FLAG_SERVERONLY;
47 void HandleFast(User* dest, User* src)
49 dest->WriteNotice("*** " + src->nick + " (" + src->ident + "@" +
50 (dest->HasPrivPermission("users/auspex") ? src->host : src->dhost) +
51 ") did a /whois on you");
54 CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
56 User* dest = ServerInstance->FindNick(parameters[0]);
60 User* source = ServerInstance->FindNick(parameters[1]);
62 if (IS_LOCAL(dest) && source)
63 HandleFast(dest, source);
69 class ModuleShowwhois : public Module
71 bool ShowWhoisFromOpers;
82 void init() CXX11_OVERRIDE
84 ConfigTag* tag = ServerInstance->Config->ConfValue("showwhois");
86 bool OpersOnly = tag->getBool("opersonly", true);
87 ShowWhoisFromOpers = tag->getBool("showfromopers", true);
89 sw = new SeeWhois(this, OpersOnly);
90 ServerInstance->Modules->AddService(*sw);
91 ServerInstance->Modules->AddService(cmd);
92 Implementation eventlist[] = { I_OnWhois };
93 ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
101 Version GetVersion() CXX11_OVERRIDE
103 return Version("Allows opers to set +W to see when a user uses WHOIS on them",VF_OPTCOMMON|VF_VENDOR);
106 void OnWhois(User* source, User* dest) CXX11_OVERRIDE
108 if (!dest->IsModeSet('W') || source == dest)
111 if (!ShowWhoisFromOpers && source->IsOper())
116 cmd.HandleFast(dest, source);
120 std::vector<std::string> params;
121 params.push_back(dest->server);
122 params.push_back("WHOISNOTICE");
123 params.push_back(dest->uuid);
124 params.push_back(source->uuid);
125 ServerInstance->PI->SendEncapsulatedData(params);
130 MODULE_INIT(ModuleShowwhois)