1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 #ifndef __CMD_ISON_H__
17 #define __CMD_ISON_H__
19 // include the common header files
24 /** Handle /ISON. These command handlers can be reloaded by the core,
25 * and handle basic RFC1459 commands. Commands within modules work
26 * the same way, however, they can be fully unloaded, where these
29 class CommandIson : public Command
32 /** Constructor for ison.
34 CommandIson ( Module* parent) : Command(parent,"ISON",0,0) { syntax = "<nick> {nick}"; }
36 * @param parameters The parameters to the comamnd
37 * @param pcnt The number of parameters passed to teh command
38 * @param user The user issuing the command
39 * @return A value from CmdResult to indicate command success or failure.
41 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
49 CmdResult CommandIson::Handle (const std::vector<std::string>& parameters, User *user)
51 std::map<User*,User*> ison_already;
53 std::string reply = std::string("303 ") + user->nick + " :";
55 for (unsigned int i = 0; i < parameters.size(); i++)
57 u = ServerInstance->FindNickOnly(parameters[i]);
58 if (ison_already.find(u) != ison_already.end())
63 reply.append(u->nick).append(" ");
64 if (reply.length() > 450)
66 user->WriteServ(reply);
67 reply = std::string("303 ") + user->nick + " :";
73 if ((i == parameters.size() - 1) && (parameters[i].find(' ') != std::string::npos))
75 /* Its a space seperated list of nicks (RFC1459 says to support this)
77 irc::spacesepstream list(parameters[i]);
80 while (list.GetToken(item))
82 u = ServerInstance->FindNickOnly(item);
83 if (ison_already.find(u) != ison_already.end())
88 reply.append(u->nick).append(" ");
89 if (reply.length() > 450)
91 user->WriteServ(reply);
92 reply = std::string("303 ") + user->nick + " :";
102 user->WriteServ(reply);
108 COMMAND_INIT(CommandIson)