]>
Commit | Line | Data |
---|---|---|
35940724 | 1 | /* |
a6f63a82 | 2 | * Solanum: a slightly advanced ircd |
35940724 AC |
3 | * chm_nonotice: block NOTICEs (+T mode). |
4 | * | |
3fc0499e | 5 | * Copyright (c) 2012 Ariadne Conill <ariadne@dereferenced.org> |
35940724 AC |
6 | * |
7 | * Permission to use, copy, modify, and/or distribute this software for any | |
8 | * purpose with or without fee is hereby granted, provided that the above | |
9 | * copyright notice and this permission notice is present in all copies. | |
10 | * | |
11 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
12 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
14 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
15 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
16 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
17 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
18 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
19 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
20 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
21 | * POSSIBILITY OF SUCH DAMAGE. | |
22 | */ | |
23 | ||
24 | #include "stdinc.h" | |
25 | #include "modules.h" | |
26 | #include "hook.h" | |
27 | #include "client.h" | |
28 | #include "ircd.h" | |
29 | #include "send.h" | |
30 | #include "s_conf.h" | |
31 | #include "s_user.h" | |
32 | #include "s_serv.h" | |
33 | #include "numeric.h" | |
34 | #include "chmode.h" | |
bd0d352f | 35 | #include "messages.h" |
35940724 AC |
36 | #include "inline/stringops.h" |
37 | ||
eeabf33a EM |
38 | static const char chm_nonotice_desc[] = |
39 | "Adds channel mode +T which blocks notices to the channel."; | |
40 | ||
35940724 AC |
41 | static unsigned int mode_nonotice; |
42 | ||
82436efb | 43 | static void chm_nonotice_process(void *); |
35940724 AC |
44 | |
45 | mapi_hfn_list_av1 chm_nonotice_hfnlist[] = { | |
82436efb | 46 | { "privmsg_channel", chm_nonotice_process }, |
35940724 AC |
47 | { NULL, NULL } |
48 | }; | |
49 | ||
50 | static void | |
82436efb | 51 | chm_nonotice_process(void *data_) |
35940724 | 52 | { |
82436efb EM |
53 | hook_data_privmsg_channel *data = data_; |
54 | ||
35940724 AC |
55 | /* don't waste CPU if message is already blocked */ |
56 | if (data->approved || data->msgtype != MESSAGE_TYPE_NOTICE) | |
57 | return; | |
58 | ||
0d0f34c3 KB |
59 | /* block all notices except CTCPs; use chm_noctcp to block CTCPs. */ |
60 | if (data->chptr->mode.mode & mode_nonotice && *data->text != '\001') | |
35940724 | 61 | { |
0d0f34c3 KB |
62 | sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOCHAN, form_str(ERR_CANNOTSENDTOCHAN), data->chptr->chname); |
63 | data->approved = ERR_CANNOTSENDTOCHAN; | |
35940724 AC |
64 | return; |
65 | } | |
66 | } | |
67 | ||
68 | static int | |
69 | _modinit(void) | |
70 | { | |
71 | mode_nonotice = cflag_add('T', chm_simple); | |
72 | if (mode_nonotice == 0) | |
73 | return -1; | |
74 | ||
75 | return 0; | |
76 | } | |
77 | ||
78 | static void | |
79 | _moddeinit(void) | |
80 | { | |
81 | cflag_orphan('T'); | |
82 | } | |
83 | ||
581dad19 | 84 | DECLARE_MODULE_AV2(chm_nonotice, _modinit, _moddeinit, NULL, NULL, chm_nonotice_hfnlist, NULL, NULL, chm_nonotice_desc); |