]> jfr.im git - solanum.git/blob - extensions/umode_noctcp.c
explicitly show IP in SNO_BANNED snotes
[solanum.git] / extensions / umode_noctcp.c
1 /*
2 * umode_noctcp.c: user mode +C which blocks CTCPs to the user
3 *
4 * Copyright (c) 2016 M. Teufel
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice is present in all copies.
9 *
10 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
11 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
13 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
14 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
15 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
16 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
17 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
18 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
19 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20 * POSSIBILITY OF SUCH DAMAGE.
21 */
22
23 #include "stdinc.h"
24 #include "modules.h"
25 #include "hook.h"
26 #include "client.h"
27 #include "ircd.h"
28 #include "send.h"
29 #include "s_user.h"
30 #include "numeric.h"
31 #include "inline/stringops.h"
32
33 static const char umode_noctcp_desc[] =
34 "Adds user mode +C which blocks CTCPs to the user.";
35
36 static void umode_noctcp_process(void *);
37
38 mapi_hfn_list_av1 umode_noctcp_hfnlist[] = {
39 { "privmsg_user", umode_noctcp_process },
40 { NULL, NULL }
41 };
42
43 static void
44 umode_noctcp_process(void *data_)
45 {
46 hook_data_privmsg_user *data = data_;
47 if (!MyClient(data->target_p))
48 return;
49
50 if (data->approved || data->msgtype == MESSAGE_TYPE_NOTICE) {
51 return;
52 }
53
54 if (data->target_p->umodes & user_modes['C'] && *data->text == '\001' && rb_strncasecmp(data->text + 1, "ACTION", 6)) {
55 sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOUSER, form_str(ERR_CANNOTSENDTOUSER), data->target_p->name, "+C set");
56 data->approved = ERR_CANNOTSENDTOUSER;
57 return;
58 }
59 }
60
61 static int
62 _modinit(void)
63 {
64 user_modes['C'] = find_umode_slot();
65 construct_umodebuf();
66
67 return 0;
68 }
69
70 static void
71 _moddeinit(void)
72 {
73 user_modes['C'] = 0;
74 construct_umodebuf();
75 }
76
77 DECLARE_MODULE_AV2(umode_noctcp, _modinit, _moddeinit, NULL, NULL, umode_noctcp_hfnlist, NULL, NULL, umode_noctcp_desc);