]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Do not allow operators to be kicked from +M channels. | |
3 | * -- kaniini | |
4 | */ | |
5 | ||
6 | #include "stdinc.h" | |
7 | #include "modules.h" | |
8 | #include "hook.h" | |
9 | #include "client.h" | |
10 | #include "ircd.h" | |
11 | #include "send.h" | |
12 | #include "hash.h" | |
13 | #include "s_conf.h" | |
14 | #include "s_user.h" | |
15 | #include "s_serv.h" | |
16 | #include "numeric.h" | |
17 | #include "privilege.h" | |
18 | #include "s_newconf.h" | |
19 | #include "chmode.h" | |
20 | ||
21 | static const char chm_operpeace_desc[] = | |
22 | "Adds channel mode +M which prohibits operators from being kicked"; | |
23 | ||
24 | static void hdl_can_kick(hook_data_channel_approval *); | |
25 | ||
26 | mapi_hfn_list_av1 chm_operpeace_hfnlist[] = { | |
27 | { "can_kick", (hookfn) hdl_can_kick }, | |
28 | { NULL, NULL } | |
29 | }; | |
30 | ||
31 | static unsigned int mymode; | |
32 | ||
33 | static int | |
34 | _modinit(void) | |
35 | { | |
36 | mymode = cflag_add('M', chm_hidden); | |
37 | if (mymode == 0) | |
38 | return -1; | |
39 | ||
40 | return 0; | |
41 | } | |
42 | ||
43 | static void | |
44 | _moddeinit(void) | |
45 | { | |
46 | cflag_orphan('M'); | |
47 | } | |
48 | ||
49 | DECLARE_MODULE_AV2(chm_operpeace, _modinit, _moddeinit, NULL, NULL, chm_operpeace_hfnlist, NULL, NULL, chm_operpeace_desc); | |
50 | ||
51 | static void | |
52 | hdl_can_kick(hook_data_channel_approval *data) | |
53 | { | |
54 | struct Client *source_p = data->client; | |
55 | struct Client *who = data->target; | |
56 | struct Channel *chptr = data->chptr; | |
57 | ||
58 | if(IsOper(source_p)) | |
59 | return; | |
60 | ||
61 | if((chptr->mode.mode & mymode) && HasPrivilege(who, "oper:receive_immunity")) | |
62 | { | |
63 | sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s attempted to kick %s from %s (which is +M)", | |
64 | source_p->name, who->name, chptr->chname); | |
65 | sendto_one_numeric(source_p, ERR_ISCHANSERVICE, "%s %s :Cannot kick IRC operators from that channel.", | |
66 | who->name, chptr->chname); | |
67 | data->approved = 0; | |
68 | } | |
69 | } |