2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2020 Sadie Powell <sadie@witchery.services>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "core_info.h"
30 CommandServList::CommandServList(Module* parent)
31 : SplitCommand(parent, "SERVLIST")
32 , invisiblemode(parent, "invisible")
34 allow_empty_last_param = false;
35 syntax = "[<mask> [<type>]]";
38 CmdResult CommandServList::HandleLocal(LocalUser* user, const Params& parameters)
40 const std::string& mask = parameters.empty() ? "*" : parameters[0];
41 const bool has_type = parameters.size() > 1;
42 for (UserManager::ULineList::const_iterator iter = ServerInstance->Users.all_ulines.begin(); iter != ServerInstance->Users.all_ulines.end(); ++iter)
45 if (uline->IsModeSet(invisiblemode) || !InspIRCd::Match(uline->nick, mask))
48 if (has_type && (!user->IsOper() || !InspIRCd::Match(user->oper->name, parameters[2 ])))
51 Numeric::Numeric numeric(RPL_SERVLIST);
54 .push(uline->server->GetName())
56 .push(user->IsOper() ? user->oper->name : "*")
58 .push(uline->GetRealName());
59 user->WriteNumeric(numeric);
61 user->WriteNumeric(RPL_SERVLISTEND, mask, has_type ? parameters[1] : "*", "End of service listing");