Debian Codegraph @

modules/contrib/src/os_kill.c

raw
1 /*
2 * Copyright (c) 2005 William Pitcock, et al.
3 * Rights to this code are as documented in doc/LICENSE.
4 *
5 * Kill users through services, requested by christel@freenode.
6 *
7 * This differs from the ircd /kill command in that it does not show to
8 * normal users who issued the kill, although the reason will usually be
9 * shown. This is useful in cases where a kline would normally be used,
10 * but would not remove the user, but the user cannot (fully) reconnect.
11 */
12
13 #include "atheme-compat.h"
14
15 static void
16 os_cmd_kill(sourceinfo_t *si, int parc, char *parv[])
17 {
18 user_t *target;
19
20 if(!parv[0] || !parv[1])
21 {
22 command_fail(si, fault_badparams, "Usage: \2KILL\2 <target> <reason>");
23 return;
24 }
25
26 if(!(target = user_find_named(parv[0])))
27 {
28 command_fail(si, fault_nosuch_target, "\2%s\2 is not on the network", parv[0]);
29 return;
30 }
31
32 logcommand(si, CMDLOG_ADMIN, "KILL: \2%s\2 (reason: \2%s\2)", target->nick, parv[1]);
33 command_success_nodata(si, "\2%s\2 has been killed.", target->nick);
34
35 kill_user(si->service->me, target, "Requested: %s", parv[1]);
36 }
37
38 static command_t os_kill = {
39 .name = "KILL",
40 .desc = N_("Kill a user with Services."),
41 .access = PRIV_OMODE,
42 .maxparc = 2,
43 .cmd = &os_cmd_kill,
44 .help = { .path = "contrib/kill" },
45 };
46
47 static void
48 mod_init(module_t *const restrict m)
49 {
50 service_named_bind_command("operserv", &os_kill);
51 }
52
53 static void
54 mod_deinit(const module_unload_intent_t intent)
55 {
56 service_named_unbind_command("operserv", &os_kill);
57 }
58
59 SIMPLE_DECLARE_MODULE_V1("contrib/os_kill", MODULE_UNLOAD_CAPABILITY_OK)