2005-12-16 18:10:38 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2006-12-15 21:45:30 +00:00
|
|
|
* InspIRCd: (C) 2002-2007 InspIRCd Development Team
|
|
|
|
* See: http://www.inspircd.org/wiki/index.php/Credits
|
2005-12-16 18:10:38 +00:00
|
|
|
*
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2006-08-10 14:43:29 +00:00
|
|
|
#include "inspircd.h"
|
2007-05-21 18:36:25 +00:00
|
|
|
#include "users.h"
|
2006-04-20 18:48:52 +00:00
|
|
|
#include "commands/cmd_ison.h"
|
2005-12-16 18:10:38 +00:00
|
|
|
|
2007-05-19 15:56:42 +00:00
|
|
|
extern "C" DllExport command_t* init_command(InspIRCd* Instance)
|
2006-09-03 00:09:38 +00:00
|
|
|
{
|
|
|
|
return new cmd_ison(Instance);
|
|
|
|
}
|
|
|
|
|
2006-09-15 14:25:10 +00:00
|
|
|
/** Handle /ISON
|
|
|
|
*/
|
2006-09-06 17:21:59 +00:00
|
|
|
CmdResult cmd_ison::Handle (const char** parameters, int pcnt, userrec *user)
|
2005-12-16 18:10:38 +00:00
|
|
|
{
|
2006-12-24 23:25:43 +00:00
|
|
|
std::map<userrec*,userrec*> ison_already;
|
2006-03-09 00:29:20 +00:00
|
|
|
userrec *u;
|
2006-12-24 23:25:43 +00:00
|
|
|
std::string reply = std::string("303 ") + user->nick + " :";
|
2006-03-09 00:29:20 +00:00
|
|
|
|
2005-12-16 18:10:38 +00:00
|
|
|
for (int i = 0; i < pcnt; i++)
|
|
|
|
{
|
2006-08-10 14:43:29 +00:00
|
|
|
u = ServerInstance->FindNick(parameters[i]);
|
2006-12-24 23:25:43 +00:00
|
|
|
if (ison_already.find(u) != ison_already.end())
|
|
|
|
continue;
|
2006-03-09 00:29:20 +00:00
|
|
|
|
2005-12-16 18:10:38 +00:00
|
|
|
if (u)
|
|
|
|
{
|
2006-12-24 23:25:43 +00:00
|
|
|
reply.append(u->nick).append(" ");
|
|
|
|
if (reply.length() > 450)
|
|
|
|
{
|
|
|
|
user->WriteServ(reply);
|
|
|
|
reply = std::string("303 ") + user->nick + " :";
|
|
|
|
}
|
|
|
|
ison_already[u] = u;
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|
2007-01-30 23:26:56 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((i == pcnt-1) && (strchr(parameters[i],' ')))
|
|
|
|
{
|
|
|
|
/* Its a space seperated list of nicks (RFC1459 says to support this)
|
|
|
|
*/
|
|
|
|
irc::spacesepstream list(parameters[i]);
|
|
|
|
std::string item = "*";
|
|
|
|
while (((item = list.GetToken()) != ""))
|
|
|
|
{
|
2007-01-30 23:33:13 +00:00
|
|
|
u = ServerInstance->FindNick(item);
|
2007-01-30 23:26:56 +00:00
|
|
|
if (ison_already.find(u) != ison_already.end())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (u)
|
|
|
|
{
|
2007-05-04 15:02:17 +00:00
|
|
|
if (u->Visibility && !u->Visibility->VisibleTo(user))
|
|
|
|
continue;
|
|
|
|
|
2007-01-30 23:26:56 +00:00
|
|
|
reply.append(u->nick).append(" ");
|
|
|
|
if (reply.length() > 450)
|
|
|
|
{
|
|
|
|
user->WriteServ(reply);
|
|
|
|
reply = std::string("303 ") + user->nick + " :";
|
|
|
|
}
|
|
|
|
ison_already[u] = u;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* There will only be one of these, we can bail after. */
|
|
|
|
break;
|
|
|
|
}
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|
2006-03-09 00:29:20 +00:00
|
|
|
|
2006-12-24 23:25:43 +00:00
|
|
|
if (!reply.empty())
|
|
|
|
user->WriteServ(reply);
|
2006-09-06 17:21:59 +00:00
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|
2006-09-06 17:21:59 +00:00
|
|
|
|