2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 class CommandUserhost : public Command
27 UserModeReference hideopermode;
30 /** Constructor for userhost.
32 CommandUserhost(Module* parent)
33 : Command(parent,"USERHOST", 1)
34 , hideopermode(parent, "hideoper")
36 syntax = "<nick> [<nick> ...]";
39 * @param parameters The parameters to the command
40 * @param user The user issuing the command
41 * @return A value from CmdResult to indicate command success or failure.
43 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
46 CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, User *user)
48 const bool has_privs = user->HasPrivPermission("users/auspex");
52 unsigned int max = parameters.size();
56 for (unsigned int i = 0; i < max; i++)
58 User *u = ServerInstance->FindNickOnly(parameters[i]);
60 if ((u) && (u->registered == REG_ALL))
66 // XXX: +H hidden opers must not be shown as opers
67 if ((u == user) || (has_privs) || (!u->IsModeSet(hideopermode)))
72 retbuf += (u->IsAway() ? '-' : '+');
75 retbuf += (((u == user) || (has_privs)) ? u->host : u->dhost);
80 user->WriteNumeric(RPL_USERHOST, retbuf);
85 COMMAND_INIT(CommandUserhost)