]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_list.cpp
3371fc738b96dfb371172bda9f9f741da8054845
[user/henk/code/inspircd.git] / src / cmd_list.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #include "users.h"
18 #include "inspircd.h"
19 #include "commands/cmd_list.h"
20 #include "wildcard.h"
21
22 /** Handle /LIST
23  */
24 extern "C" command_t* init_command(InspIRCd* Instance)
25 {
26         return new cmd_list(Instance);
27 }
28
29 CmdResult cmd_list::Handle (const char** parameters, int pcnt, userrec *user)
30 {
31         user->WriteServ("321 %s Channel :Users Name",user->nick);
32
33         /* Work around mIRC suckyness. YOU SUCK, KHALED! */
34         if ((pcnt == 1) && (*parameters[0] == '<'))
35                 pcnt = 0;
36
37         for (chan_hash::const_iterator i = ServerInstance->chanlist.begin(); i != ServerInstance->chanlist.end(); i++)
38         {
39                 // attempt to match a glob pattern
40                 if (pcnt && !match(i->second->name, parameters[0]))
41                         continue;
42                 // if the channel is not private/secret, OR the user is on the channel anyway
43                 bool n = i->second->HasUser(user);
44                 if (((!(i->second->modes[CM_PRIVATE])) && (!(i->second->modes[CM_SECRET]))) || (n))
45                 {
46                         long users = i->second->GetUserCounter();
47                         if (users)
48                                 user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,users,i->second->ChanModes(n),i->second->topic);
49                 }
50         }
51         user->WriteServ("323 %s :End of channel list.",user->nick);
52
53         return CMD_SUCCESS;
54 }