1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
15 #include "commands/cmd_list.h"
19 extern "C" DllExport Command* init_command(InspIRCd* Instance)
21 return new CommandList(Instance);
24 CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User *user)
26 int minusers = 0, maxusers = 0;
28 user->WriteNumeric(321, "%s Channel :Users Name",user->nick.c_str());
30 /* Work around mIRC suckyness. YOU SUCK, KHALED! */
31 if (parameters.size() == 1)
33 if (parameters[0][0] == '<')
35 maxusers = atoi((parameters[0].c_str())+1);
37 else if (parameters[0][0] == '>')
39 minusers = atoi((parameters[0].c_str())+1);
43 for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); i++)
45 // attempt to match a glob pattern
46 long users = i->second->GetUserCounter();
48 bool too_few = (minusers && (users <= minusers));
49 bool too_many = (maxusers && (users >= maxusers));
51 if (too_many || too_few)
54 if (parameters.size() && (parameters[0][0] != '<' && parameters[0][0] != '>'))
56 if (!InspIRCd::Match(i->second->name, parameters[0]) && !InspIRCd::Match(i->second->topic, parameters[0]))
60 // if the channel is not private/secret, OR the user is on the channel anyway
61 bool n = (i->second->HasUser(user) || user->HasPrivPermission("channels/auspex"));
63 if (!n && i->second->IsModeSet('p'))
65 /* Channel is +p and user is outside/not privileged */
66 user->WriteNumeric(322, "%s * %ld :",user->nick.c_str(), users);
70 if (n || !i->second->IsModeSet('s'))
72 /* User is in the channel/privileged, channel is not +s */
73 user->WriteNumeric(322, "%s %s %ld :[+%s] %s",user->nick.c_str(),i->second->name.c_str(),users,i->second->ChanModes(n),i->second->topic.c_str());
77 user->WriteNumeric(323, "%s :End of channel list.",user->nick.c_str());