The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download | Blog | Stats
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

cmd_ison Class Reference

Handle /ISON. More...

#include <cmd_ison.h>

Inheritance diagram for cmd_ison:

Inheritance graph
[legend]
Collaboration diagram for cmd_ison:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 cmd_ison (InspIRCd *Instance)
 Constructor for ison.
CmdResult Handle (const char **parameters, int pcnt, userrec *user)
 Handle command.

Detailed Description

Handle /ISON.

These command handlers can be reloaded by the core, and handle basic RFC1459 commands. Commands within modules work the same way, however, they can be fully unloaded, where these may not.

Definition at line 27 of file cmd_ison.h.


Constructor & Destructor Documentation

cmd_ison::cmd_ison InspIRCd Instance  )  [inline]
 

Constructor for ison.

Definition at line 32 of file cmd_ison.h.

References command_t::syntax.

00032 : command_t(Instance,"ISON",0,0) { syntax = "<nick> {nick}"; }


Member Function Documentation

CmdResult cmd_ison::Handle const char **  parameters,
int  pcnt,
userrec user
[virtual]
 

Handle command.

Parameters:
parameters The parameters to the comamnd
pcnt The number of parameters passed to teh command
user The user issuing the command
Returns:
A value from CmdResult to indicate command success or failure.

Implements command_t.

Definition at line 25 of file cmd_ison.cpp.

References CMD_SUCCESS, InspIRCd::FindNick(), irc::sepstream::GetToken(), userrec::nick, command_t::ServerInstance, userrec::Visibility, VisData::VisibleTo(), and userrec::WriteServ().

00026 {
00027         std::map<userrec*,userrec*> ison_already;
00028         userrec *u;
00029         std::string reply = std::string("303 ") + user->nick + " :";
00030 
00031         for (int i = 0; i < pcnt; i++)
00032         {
00033                 u = ServerInstance->FindNick(parameters[i]);
00034                 if (ison_already.find(u) != ison_already.end())
00035                         continue;
00036 
00037                 if (u)
00038                 {
00039                         if (u->Visibility && !u->Visibility->VisibleTo(user))
00040                                 continue;
00041 
00042                         reply.append(u->nick).append(" ");
00043                         if (reply.length() > 450)
00044                         {
00045                                 user->WriteServ(reply);
00046                                 reply = std::string("303 ") + user->nick + " :";
00047                         }
00048                         ison_already[u] = u;
00049                 }
00050                 else
00051                 {
00052                         if ((i == pcnt-1) && (strchr(parameters[i],' ')))
00053                         {
00054                                 /* Its a space seperated list of nicks (RFC1459 says to support this)
00055                                  */
00056                                 irc::spacesepstream list(parameters[i]);
00057                                 std::string item;
00058 
00059                                 while (list.GetToken(item))
00060                                 {
00061                                         u = ServerInstance->FindNick(item);
00062                                         if (ison_already.find(u) != ison_already.end())
00063                                                 continue;
00064 
00065                                         if (u)
00066                                         {
00067                                                 if (u->Visibility && !u->Visibility->VisibleTo(user))
00068                                                         continue;
00069 
00070                                                 reply.append(u->nick).append(" ");
00071                                                 if (reply.length() > 450)
00072                                                 {
00073                                                         user->WriteServ(reply);
00074                                                         reply = std::string("303 ") + user->nick + " :";
00075                                                 }
00076                                                 ison_already[u] = u;
00077                                         }
00078                                 }
00079                         }
00080                 }
00081         }
00082 
00083         if (!reply.empty())
00084                 user->WriteServ(reply);
00085 
00086         return CMD_SUCCESS;
00087 }


The documentation for this class was generated from the following files: