2005-12-16 18:10:38 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2006-01-15 15:59:11 +00:00
|
|
|
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
|
2005-12-16 18:10:38 +00:00
|
|
|
* E-mail:
|
2006-01-15 15:59:11 +00:00
|
|
|
* <brain@chatspike.net>
|
|
|
|
* <Craig@chatspike.net>
|
2005-12-16 18:10:38 +00:00
|
|
|
*
|
|
|
|
* Written by Craig Edwards, Craig McLure, and others.
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "users.h"
|
2006-08-09 16:35:24 +00:00
|
|
|
#include "inspircd.h"
|
2006-04-20 18:55:46 +00:00
|
|
|
#include "commands/cmd_list.h"
|
2006-08-18 00:56:26 +00:00
|
|
|
#include "wildcard.h"
|
2005-12-16 18:10:38 +00:00
|
|
|
|
2006-09-15 14:25:10 +00:00
|
|
|
/** Handle /LIST
|
|
|
|
*/
|
2006-09-03 00:09:38 +00:00
|
|
|
extern "C" command_t* init_command(InspIRCd* Instance)
|
|
|
|
{
|
|
|
|
return new cmd_list(Instance);
|
|
|
|
}
|
|
|
|
|
2006-09-06 17:21:59 +00:00
|
|
|
CmdResult cmd_list::Handle (const char** parameters, int pcnt, userrec *user)
|
2005-12-16 18:10:38 +00:00
|
|
|
{
|
2006-08-08 18:59:13 +00:00
|
|
|
user->WriteServ("321 %s Channel :Users Name",user->nick);
|
2006-10-22 20:02:33 +00:00
|
|
|
|
|
|
|
/* Work around mIRC suckyness. YOU SUCK, KHALED! */
|
|
|
|
if ((pcnt == 1) && (*parameters[0] == '<'))
|
|
|
|
pcnt = 0;
|
|
|
|
|
2006-08-09 16:35:24 +00:00
|
|
|
for (chan_hash::const_iterator i = ServerInstance->chanlist.begin(); i != ServerInstance->chanlist.end(); i++)
|
2005-12-16 18:10:38 +00:00
|
|
|
{
|
2006-08-18 00:56:26 +00:00
|
|
|
// attempt to match a glob pattern
|
|
|
|
if (pcnt && !match(i->second->name, parameters[0]))
|
|
|
|
continue;
|
2005-12-16 18:10:38 +00:00
|
|
|
// if the channel is not private/secret, OR the user is on the channel anyway
|
2006-03-09 00:04:39 +00:00
|
|
|
bool n = i->second->HasUser(user);
|
2006-03-12 14:49:30 +00:00
|
|
|
if (((!(i->second->modes[CM_PRIVATE])) && (!(i->second->modes[CM_SECRET]))) || (n))
|
2005-12-16 18:10:38 +00:00
|
|
|
{
|
2006-08-09 17:52:10 +00:00
|
|
|
long users = i->second->GetUserCounter();
|
2006-03-09 00:35:57 +00:00
|
|
|
if (users)
|
2006-08-10 14:43:29 +00:00
|
|
|
user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,users,i->second->ChanModes(n),i->second->topic);
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|
|
|
|
}
|
2006-08-08 18:59:13 +00:00
|
|
|
user->WriteServ("323 %s :End of channel list.",user->nick);
|
2006-09-06 17:21:59 +00:00
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|