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_kill Class Reference

Handle /KILL. More...

#include <cmd_kill.h>

Inheritance diagram for cmd_kill:

Inheritance graph
[legend]
Collaboration diagram for cmd_kill:

Collaboration graph
[legend]
List of all members.

Public Member Functions

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

Detailed Description

Handle /KILL.

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_kill.h.


Constructor & Destructor Documentation

cmd_kill::cmd_kill InspIRCd Instance  )  [inline]
 

Constructor for kill.

Definition at line 32 of file cmd_kill.h.

References command_t::syntax.

00032 : command_t(Instance,"KILL",'o',2) { syntax = "<nickname> <reason>"; }


Member Function Documentation

CmdResult cmd_kill::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 28 of file cmd_kill.cpp.

References CMD_FAILURE, CMD_SUCCESS, InspIRCd::Config, DEFAULT, InspIRCd::FindNick(), FOREACH_MOD, FOREACH_RESULT, ServerConfig::HideKillsServer, connection::host, I_OnKill, I_OnRemoteKill, userrec::ident, IS_LOCAL, InspIRCd::Log(), CommandParser::LoopCall(), MAXBUF, MAXQUIT, userrec::nick, InspIRCd::Parser, userrec::QuitUser(), command_t::ServerInstance, ServerConfig::ServerName, InspIRCd::SNO, userrec::Write(), userrec::WriteServ(), and SnomaskManager::WriteToSnoMask().

00029 {
00030         /* Allow comma seperated lists of users for /KILL (thanks w00t) */
00031         if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
00032                 return CMD_SUCCESS;
00033 
00034         userrec *u = ServerInstance->FindNick(parameters[0]);
00035         char killreason[MAXBUF];
00036         int MOD_RESULT = 0;
00037 
00038         if (u)
00039         {
00040                 /*
00041                  * Here, we need to decide how to munge kill messages. Whether to hide killer, what to show opers, etc.
00042                  * We only do this when the command is being issued LOCALLY, for remote KILL, we just copy the message we got.
00043                  *
00044                  * This conditional is so that we only append the "Killed (" prefix ONCE. If killer is remote, then the kill
00045                  * just gets processed and passed on, otherwise, if they are local, it gets prefixed. Makes sense :-) -- w00t
00046                  */
00047                 if (IS_LOCAL(user))
00048                 {
00049                         /*
00050                          * Moved this event inside the IS_LOCAL check also, we don't want half the network killing a user
00051                          * and the other half not. This would be a bad thing. ;p -- w00t
00052                          */
00053                         FOREACH_RESULT(I_OnKill, OnKill(user, u, parameters[1]));
00054 
00055                         if (MOD_RESULT)
00056                                 return CMD_FAILURE;
00057 
00058                         if (*ServerInstance->Config->HideKillsServer)
00059                         {
00060                                 // hidekills is on, use it
00061                                 snprintf(killreason, MAXQUIT, "Killed (%s (%s))", ServerInstance->Config->HideKillsServer, parameters[1]);
00062                         }
00063                         else
00064                         {
00065                                 // hidekills is off, do nothing
00066                                 snprintf(killreason, MAXQUIT, "Killed (%s (%s))", user->nick, parameters[1]);
00067                         }
00068                 }
00069                 else
00070                 {
00071                         /* Leave it alone, remote server has already formatted it */
00072                         snprintf(killreason, MAXQUIT, "%s", parameters[1]);
00073                 }
00074 
00075                 /*
00076                  * Now we need to decide whether or not to send a local or remote snotice. Currently this checking is a little flawed.
00077                  * No time to fix it right now, so left a note. -- w00t
00078                  */
00079                 if (!IS_LOCAL(u))
00080                 {
00081                         // remote kill
00082                         ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
00083                         FOREACH_MOD(I_OnRemoteKill, OnRemoteKill(user, u, killreason, killreason));
00084                 }
00085                 else
00086                 {
00087                         // local kill
00088                         /*
00089                          * XXX - this isn't entirely correct, servers A - B - C, oper on A, client on C. Oper kills client, A and B will get remote kill
00090                          * snotices, C will get a local kill snotice. this isn't accurate, and needs fixing at some stage. -- w00t
00091                          */
00092                         ServerInstance->SNO->WriteToSnoMask('k',"Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
00093                         ServerInstance->Log(DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1]);
00094 
00095                         u->Write(":%s KILL %s :%s!%s!%s (%s)", *ServerInstance->Config->HideKillsServer ? ServerInstance->Config->HideKillsServer : user->GetFullHost(),
00096                                         u->nick,
00097                                         ServerInstance->Config->ServerName,
00098                                         user->dhost,
00099                                         *ServerInstance->Config->HideKillsServer ? ServerInstance->Config->HideKillsServer : user->nick,
00100                                         parameters[1]);
00101                 }
00102 
00103                 // send the quit out
00104                 userrec::QuitUser(ServerInstance, u, killreason);
00105         }
00106         else
00107         {
00108                 user->WriteServ( "401 %s %s :No such nick/channel", user->nick, parameters[0]);
00109                 return CMD_FAILURE;
00110         }
00111 
00112         return CMD_SUCCESS;
00113 }


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