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