]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_kill.cpp
77fcfaa23b39f960d0c8d489c3aeef67fcc35a7a
[user/henk/code/inspircd.git] / src / cmd_kill.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "configreader.h"
16 #include "users.h"
17 #include "modules.h"
18 #include "wildcard.h"
19 #include "commands/cmd_kill.h"
20
21 extern "C" DllExport command_t* init_command(InspIRCd* Instance)
22 {
23         return new cmd_kill(Instance);
24 }
25
26 /** Handle /KILL
27  */
28 CmdResult cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
29 {
30         /* Allow comma seperated lists of users for /KILL (thanks w00t) */
31         if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
32                 return CMD_SUCCESS;
33
34         userrec *u = ServerInstance->FindNick(parameters[0]);
35         char killreason[MAXBUF];
36         char killoperreason[MAXBUF];
37         int MOD_RESULT = 0;
38
39         if (u)
40         {
41                 FOREACH_RESULT(I_OnKill, OnKill(user, u, parameters[1]));
42
43                 if (MOD_RESULT)
44                         return CMD_FAILURE;
45
46                 // generate two reasons here, one for users, one for opers. first, the user visible reason, which may change.
47                 if (*ServerInstance->Config->HideKillsServer)
48                 {
49                         // hidekills is on, use it
50                         snprintf(killreason, MAXQUIT, "Killed (%s (%s))", ServerInstance->Config->HideKillsServer, parameters[1]);
51                 }
52                 else
53                 {
54                         // hidekills is off, do nothing
55                         snprintf(killreason, MAXQUIT, "Killed (%s (%s))", user->nick, parameters[1]);
56                 }
57
58                 // opers are lucky ducks, they always see the real reason
59                 snprintf(killoperreason, MAXQUIT, "Killed (%s (%s))", user->nick, parameters[1]);
60
61                 if (!IS_LOCAL(u))
62                 {
63                         // remote kill
64                         ServerInstance->SNO->WriteToSnoMask('k',"Remote kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
65                         FOREACH_MOD(I_OnRemoteKill, OnRemoteKill(user, u, killreason));
66
67                         /*
68                          * IMPORTANT SHIT:
69                          *  There used to be a WriteCommonExcept() of the QUIT here. It seems to be unnecessary with QuitUser() right below, so it's gone.
70                          *  If it explodes painfully, put it back!
71                          */
72                 }
73                 else
74                 {
75                         // local kill
76                         ServerInstance->SNO->WriteToSnoMask('k',"Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
77                         ServerInstance->Log(DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1]);
78                         user->WriteTo(u, "KILL %s :%s!%s!%s (%s)", *ServerInstance->Config->HideKillsServer ? ServerInstance->Config->HideKillsServer : u->nick,
79                                         ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1]);
80                 }
81
82                 // send the quit out
83                 userrec::QuitUser(ServerInstance, u, killreason, killoperreason);
84         }
85         else
86         {
87                 user->WriteServ( "401 %s %s :No such nick/channel", user->nick, parameters[0]);
88                 return CMD_FAILURE;
89         }
90
91         return CMD_SUCCESS;
92 }
93