]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_kill.cpp
Add a metric assload of TRANSLATE macros to modules.
[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 "commands/cmd_kill.h"
16
17 extern "C" DllExport command_t* init_command(InspIRCd* Instance)
18 {
19         return new cmd_kill(Instance);
20 }
21
22 /** Handle /KILL
23  */
24 CmdResult cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
25 {
26         /* Allow comma seperated lists of users for /KILL (thanks w00t) */
27         if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
28                 return CMD_SUCCESS;
29
30         userrec *u = ServerInstance->FindNick(parameters[0]);
31         char killreason[MAXBUF];
32         char killoperreason[MAXBUF];
33         int MOD_RESULT = 0;
34
35         if (u)
36         {
37                 /*
38                  * Here, we need to decide how to munge kill messages. Whether to hide killer, what to show opers, etc.
39                  * We only do this when the command is being issued LOCALLY, for remote KILL, we just copy the message we got.
40                  *
41                  * This conditional is so that we only append the "Killed (" prefix ONCE. If killer is remote, then the kill
42                  * just gets processed and passed on, otherwise, if they are local, it gets prefixed. Makes sense :-) -- w00t
43                  */
44                 if (IS_LOCAL(user))
45                 {
46                         /*
47                          * Moved this event inside the IS_LOCAL check also, we don't want half the network killing a user
48                          * and the other half not. This would be a bad thing. ;p -- w00t
49                          */
50                         FOREACH_RESULT(I_OnKill, OnKill(user, u, parameters[1]));
51
52                         if (MOD_RESULT)
53                                 return CMD_FAILURE;
54
55                         if (*ServerInstance->Config->HideKillsServer)
56                         {
57                                 // hidekills is on, use it
58                                 snprintf(killreason, MAXQUIT, "Killed (%s (%s))", ServerInstance->Config->HideKillsServer, parameters[1]);
59                         }
60                         else
61                         {
62                                 // hidekills is off, do nothing
63                                 snprintf(killreason, MAXQUIT, "Killed (%s (%s))", user->nick, parameters[1]);
64                         }
65
66                         // opers are lucky ducks, they always see the real reason
67                         snprintf(killoperreason, MAXQUIT, "Killed (%s (%s))", user->nick, parameters[1]);
68                 }
69                 else
70                 {
71                         snprintf(killreason, MAXQUIT, "%s", parameters[1]);
72                         /*
73                          * XXX - yes, this means opers will probably see a censored kill remotely. this needs fixing.
74                          * maybe a version of QuitUser that doesn't take nor propegate an oper reason? -- w00t
75                          */
76                         snprintf(killoperreason, MAXQUIT, "%s", parameters[1]);
77                 }
78
79                 /*
80                  * Now we need to decide whether or not to send a local or remote snotice. Currently this checking is a little flawed.
81                  * No time to fix it right now, so left a note. -- w00t
82                  */
83                 if (!IS_LOCAL(u))
84                 {
85                         // remote kill
86                         ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
87                         FOREACH_MOD(I_OnRemoteKill, OnRemoteKill(user, u, killreason, killoperreason));
88                 }
89                 else
90                 {
91                         // local kill
92                         /*
93                          * 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
94                          * snotices, C will get a local kill snotice. this isn't accurate, and needs fixing at some stage. -- w00t
95                          */
96                         ServerInstance->SNO->WriteToSnoMask('k',"Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
97                         ServerInstance->Log(DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1]);
98                         user->WriteTo(u, "KILL %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost,
99                                         *ServerInstance->Config->HideKillsServer ? ServerInstance->Config->HideKillsServer : user->nick, parameters[1]);
100                 }
101
102                 // send the quit out
103                 userrec::QuitUser(ServerInstance, u, killreason, killoperreason);
104         }
105         else
106         {
107                 user->WriteServ( "401 %s %s :No such nick/channel", user->nick, parameters[0]);
108                 return CMD_FAILURE;
109         }
110
111         return CMD_SUCCESS;
112 }
113