]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_list.cpp
Don't show channels where all users are invisible and therefore usercount is 0
[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 using namespace std;
18
19 #include "inspircd_config.h"
20 #include "inspircd.h"
21 #include "inspircd_io.h"
22 #include <string>
23 #ifdef GCC3
24 #include <ext/hash_map>
25 #else
26 #include <hash_map>
27 #endif
28 #include "users.h"
29 #include "ctables.h"
30 #include "globals.h"
31 #include "modules.h"
32 #include "dynamic.h"
33 #include "message.h"
34 #include "commands.h"
35 #include "inspstring.h"
36 #include "helperfuncs.h"
37 #include "hashcomp.h"
38 #include "typedefs.h"
39 #include "cmd_list.h"
40
41 extern chan_hash chanlist;
42
43 void cmd_list::Handle (char **parameters, int pcnt, userrec *user)
44 {
45         WriteServ(user->fd,"321 %s Channel :Users Name",user->nick);
46         for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++)
47         {
48                 // if the channel is not private/secret, OR the user is on the channel anyway
49                 bool n = i->second->HasUser(user);
50                 if (((!(i->second->binarymodes & CM_PRIVATE)) && (!(i->second->binarymodes & CM_SECRET))) || (n))
51                 {
52                         long users = usercount_i(i->second);
53                         if (users)
54                                 WriteServ(user->fd,"322 %s %s %d :[+%s] %s",user->nick,i->second->name,users,chanmodes(i->second,n),i->second->topic);
55                 }
56         }
57         WriteServ(user->fd,"323 %s :End of channel list.",user->nick);
58 }
59
60
61