1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 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 * ---------------------------------------------------
16 #include "commands/cmd_list.h"
21 extern "C" command_t* init_command(InspIRCd* Instance)
23 return new cmd_list(Instance);
26 CmdResult cmd_list::Handle (const char** parameters, int pcnt, userrec *user)
28 int minusers = 0, maxusers = 0;
30 user->WriteServ("321 %s Channel :Users Name",user->nick);
32 /* Work around mIRC suckyness. YOU SUCK, KHALED! */
35 if (*parameters[0] == '<')
37 maxusers = atoi(parameters[0]+1);
40 else if (*parameters[0] == '>')
42 minusers = atoi(parameters[0]+1);
47 for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); i++)
49 // attempt to match a glob pattern
50 long users = i->second->GetUserCounter();
52 bool too_few = (minusers && (users <= minusers));
53 bool too_many = (maxusers && (users >= maxusers));
55 if (too_many || too_few)
58 if (pcnt && (!match(i->second->name, parameters[0]) || (*i->second->topic && !match(i->second->topic, parameters[0]))))
61 // if the channel is not private/secret, OR the user is on the channel anyway
62 bool n = i->second->HasUser(user);
63 if ((i->second->modes[CM_PRIVATE]) && (!n))
66 user->WriteServ("322 %s *",user->nick,i->second->name);
70 if (((!(i->second->modes[CM_PRIVATE])) && (!(i->second->modes[CM_SECRET]))) || (n))
72 long users = i->second->GetUserCounter();
74 user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,users,i->second->ChanModes(n),i->second->topic);
78 user->WriteServ("323 %s :End of channel list.",user->nick);