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/>.
22 #include "core_channel.h"
24 CommandNames::CommandNames(Module* parent)
25 : Command(parent, "NAMES", 0, 0)
26 , secretmode(parent, "secret")
28 syntax = "{<channel>{,<channel>}}";
33 CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User *user)
37 if (!parameters.size())
39 user->WriteNumeric(RPL_ENDOFNAMES, "* :End of /NAMES list.");
43 if (CommandParser::LoopCall(user, this, parameters, 0))
46 c = ServerInstance->FindChan(parameters[0]);
49 // Show the NAMES list if one of the following is true:
50 // - the channel is not secret
51 // - the user doing the /NAMES is inside the channel
52 // - the user doing the /NAMES has the channels/auspex privilege
54 bool has_user = c->HasUser(user);
55 if ((!c->IsModeSet(secretmode)) || (has_user) || (user->HasPrivPermission("channels/auspex")))
57 c->UserList(user, has_user);
62 user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str());