]> jfr.im git - solanum.git/blame - extensions/override_kick_immunity.c
extensions/extb_extgecos: support CIDR masks in $x extbans (#414)
[solanum.git] / extensions / override_kick_immunity.c
CommitLineData
ead77e93
EK
1#include "stdinc.h"
2#include "modules.h"
3#include "hook.h"
4#include "client.h"
5#include "ircd.h"
6#include "send.h"
7#include "numeric.h"
8#include "s_user.h"
9#include "s_conf.h"
10
11static const char override_kick_immunity_desc[] =
12 "Prevents +p users (oper override) from being kicked from any channel";
13
14static void can_kick(void *data);
15
16mapi_hfn_list_av1 override_kick_immunity_hfnlist[] = {
82436efb 17 { "can_kick", can_kick, HOOK_HIGHEST },
ead77e93
EK
18 { NULL, NULL }
19};
20
21static void
22can_kick(void *vdata)
23{
24 hook_data_channel_approval *data = vdata;
25
26 if (data->target->umodes & user_modes['p'])
27 {
28 if (data->client->umodes & user_modes['p'])
29 {
30 /* Using oper-override to kick an oper
31 * who's also using oper-override, better
32 * report what happened.
33 */
34 sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is using oper-override on %s (KICK %s)",
35 get_oper_name(data->client), data->chptr->chname, data->target->name);
36 }
37 else
38 {
39 /* Like cmode +M, let's report any attempt
40 * to kick the immune oper.
41 */
42 sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s attempted to kick %s from %s (who is +p)",
43 data->client->name, data->target->name, data->chptr->chname);
44 sendto_one_numeric(data->client, ERR_ISCHANSERVICE, "%s %s :Cannot kick immune IRC operators.",
45 data->target->name, data->chptr->chname);
46 data->approved = 0;
47 }
48 return;
49 }
50}
51
52DECLARE_MODULE_AV2(override_kick_immunity, NULL, NULL, NULL, NULL,
53 override_kick_immunity_hfnlist, NULL, NULL, override_kick_immunity_desc);